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_5573_I
Write a program that calculates the sum of all prime numbers up to a given number $n$. Constraints * $2 \leq n \leq 10^4$ Input A single integer $n$ is provided in the first line. Output Print the sum of all prime numbers less than or equal to $n$. Examples Input 10 Output 17 Input 20 Output 77
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 is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(25) == False def test_sum_of_primes_below_10(): assert sum_of_primes(10...
[ { "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 all prime numbers less than or equal to n.", "function_declaration": "def sum_of_primes(n):", "func...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005573", "row_id": 5573, "seed_ids": "[14912]" }
0.624925
Taco_5573
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3933b24e67e8bd225fd5742f93b92838928d7367
3a698fca0c469b647cb00123fa945b94c697a65c
v1.0
instruct
Taco
Taco_5574_I
A magical garden is designed using a system of interconnected water pipes. Each pipe either directs water in one of four cardinal directions (North, South, East, West). The connections between the pipes determine the water flow in the garden. The layout of the pipes and the flow they create can be described by a sequen...
def normalize_description(description): """ Normalize the pipe description by sorting elements and handling rotations. """ parts = description.split() n = int(parts[0]) elements = parts[1:] def rotate90(elements): rotated = [] for el in elements: if el == 'N': ...
from solution import compare_descriptions, check_pipe_systems def test_compare_identical_descriptions(): desc1 = "12 1 N 1 E 2 S 2 W" desc2 = "12 1 N 1 E 2 S 2 W" assert compare_descriptions(desc1, desc2) == True def test_compare_different_descriptions_rotation(): desc1 = "12 1 N 1 E 2 S 2 W" desc...
[ { "docstring": "Normalize the pipe description by sorting elements and handling rotations.", "function_declaration": "def normalize_description(description):", "function_name": "normalize_description", "parameter_list": "(description)" }, { "docstring": "Compare two descriptions to check if ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def normalize_description(description):\n \"\"\"\n Normalize the description by sorting and considering all rotations.\n \"\"\"\n return sorted(descrip...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00005574", "row_id": 5574, "seed_ids": "[13881]" }
0.544362
Taco_5574
I
[ "normalize_description", "compare_descriptions", "check_pipe_systems" ]
3
[ [ "check_pipe_systems", "compare_descriptions" ], [ "compare_descriptions", "normalize_description" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c3b5f011c09117665b909d23d0c3f7a4543511da
3fb4e47a41504334bcf4b0f821b61e92ad0aed94
v1.0
instruct
Taco
Taco_5591_I
In a distant kingdom, there is a carnival held every year, and one of the main attractions is an entertaining game where participants have to guess a hidden sequence of numbers. The game master gives a few hints to help the participants. You are given an array of integers `A` of size `N` and an integer `D`. The game m...
def compute_hints(N, D, A): """ Given an array A of size N and an integer D, compute the maximum and minimum difference within each subarray of length D. """ results = [] for i in range(N - D + 1): subarray = A[i:i + D] difference = max(subarray) - min(subarray) results.a...
from solution import compute_hints, parse_input, hints_from_input def test_compute_hints(): assert compute_hints(6, 3, [1, 3, 4, 1, 5, 2]) == [3, 3, 4, 4] assert compute_hints(5, 2, [1, 2, 3, 4, 5]) == [1, 1, 1, 1] assert compute_hints(4, 4, [1, 1, 1, 1]) == [0] assert compute_hints(3, 1, [5, 4, 3]) ==...
[ { "docstring": "Given an array A of size N and an integer D, compute the maximum and minimum difference\nwithin each subarray of length D.", "function_declaration": "def compute_hints(N, D, A):", "function_name": "compute_hints", "parameter_list": "(N, D, A)" }, { "docstring": "Parse the inp...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_hints(N, D, A):\n \"\"\"\n Calculate the absolute difference between the maximum and minimum values\n for every subarray of length D in the ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005591", "row_id": 5591, "seed_ids": "[8741]" }
0.70915
Taco_5591
I
[ "compute_hints", "parse_input", "hints_from_input" ]
3
[ [ "hints_from_input", "compute_hints" ], [ "hints_from_input", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
470b0a1188c0206dccbfb1a4ec3a41667616fa3c
71b9ba9aecd6e96e8d727361090f59996332ffb7
v1.0
instruct
Taco
Taco_5655_I
Given a binary tree, your task is to delete a node with a given key and return the new root of the modified tree. If the key value is not present in the tree, then do not change the tree and return the original root. The tree should maintain its Binary Search Tree (BST) properties after deletion. Example 1: Input: ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def deleteNode(root: TreeNode, key: int) -> TreeNode: if not root: return root if key < root.val: root.left = deleteNode(root.left, key) elif...
def build_tree_from_list(vals): if not vals: return None root = TreeNode(vals[0]) queue = [root] i = 1 while i < len(vals): curr = queue.pop(0) if vals[i] is not None: curr.left = TreeNode(vals[i]) queue.append(curr.left) i += 1 ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key=0, left=None, right=None):\n self.val = key\n self.left = left\n self.right = right\n\ndef deleteN...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005655", "row_id": 5655, "seed_ids": "[18004]" }
0.613488
Taco_5655
I
[ "deleteNode", "findMin" ]
2
[ [ "deleteNode", "findMin" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
bdee12398b598d08cc1de2f1f67c34bddce5d8cc
e45f256980d46865614d41c8a90fcfd6e8b3a1d7
v1.0
instruct
Taco
Taco_5675_I
You are given an array of integers and a set of queries. Each query asks for the sum of a subarray defined by a range of indices. Your task is to preprocess the array so that each query can be answered efficiently. -----Input:----- - The first line contains an integer $N$, the number of elements in the array. - The se...
def preprocess_array(arr): """ Preprocess the input array to create a prefix sum array to allow efficient range sum queries. """ prefix_sums = [0] * (len(arr) + 1) for i in range(1, len(arr) + 1): prefix_sums[i] = prefix_sums[i - 1] + arr[i - 1] return prefix_sums def range_sum(prefix_s...
from solution import preprocess_array, range_sum, process_queries def test_preprocess_array(): arr = [1, 2, 3, 4, 5, 6] expected_prefix_sums = [0, 1, 3, 6, 10, 15, 21] assert preprocess_array(arr) == expected_prefix_sums def test_range_sum(): arr = [1, 2, 3, 4, 5, 6] prefix_sums = preprocess_array...
[ { "docstring": "Preprocess the input array to create a prefix sum array to allow efficient range sum queries.", "function_declaration": "def preprocess_array(arr):", "function_name": "preprocess_array", "parameter_list": "(arr)" }, { "docstring": "Calculate the sum of the subarray arr[L:R+1]...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_array(arr):\n \"\"\"\n Preprocesses the array to create a prefix sum array.\n \n Parameters:\n arr (list): List of integers.\n \n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005675", "row_id": 5675, "seed_ids": "[22410]" }
0.723988
Taco_5675
I
[ "preprocess_array", "range_sum", "process_queries" ]
3
[ [ "process_queries", "preprocess_array" ], [ "process_queries", "range_sum" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
80ad9acd76d2de8f2f9d6054f5289bc779fcb16c
d85b6e2e9080b450f81147ce1baa9e989316ed0f
v1.0
instruct
Taco
Taco_5678_I
Write a function `isPalindrome` that takes the head of a singly linked list as input and determines if the list is a palindrome. Input: The input line contains an integer T, denoting the number of test cases. Each test case contains two lines: the first line contains an integer N (size of the linked list). The second l...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def isPalindrome(head): """ Returns True if the linked list is a palindrome, False otherwise. """ if not head or not head.next: return True # Find the middle of the linked list slo...
import pytest from solution import create_linked_list, isPalindrome, check_palindromes def test_isPalindrome(): assert isPalindrome(create_linked_list([1, 2, 1])) == True assert isPalindrome(create_linked_list([1, 2, 3, 4])) == False assert isPalindrome(create_linked_list([1, 2, 2, 1])) == True assert ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef isPalindrome(head: ListNode) -> bool:\n # Co...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005678", "row_id": 5678, "seed_ids": "[8124]" }
0.715756
Taco_5678
I
[ "isPalindrome", "create_linked_list", "check_palindromes" ]
3
[ [ "check_palindromes", "create_linked_list" ], [ "check_palindromes", "isPalindrome" ] ]
2
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
09eea2b04af897ee965b9be189b3ac23595d9677
0ad60499c83bcb0ca523ff4f73bcbd05471d53be
v1.0
instruct
Taco
Taco_5745_I
You have been given an array of integers representing the number of pages in N books, and an integer K representing the number of students. Your task is to allocate books to each student in such a way that - Each student gets at least one book. - The maximum number of pages assigned to a student is minimized. To achie...
def can_allocate(pages, N, K, max_pages): """ Helper function to determine if it is possible to allocate books such that the maximum number of pages assigned to any student does not exceed max_pages. """ student_count = 1 current_pages = 0 for i in range(N): if pages[i] > ma...
def test_single_book_multiple_students(): assert allocate_books([10], 1, 1) == 10 def test_multiple_books_single_student(): assert allocate_books([10, 20, 30, 40], 4, 1) == 100 def test_multiple_books_multiple_students(): assert allocate_books([12, 34, 67, 90], 4, 2) == 113 def test_minimum_pages(): ...
[ { "docstring": "Helper function to determine if it is possible to allocate\nbooks such that the maximum number of pages assigned to any\nstudent does not exceed max_pages.", "function_declaration": "def can_allocate(pages, N, K, max_pages):", "function_name": "can_allocate", "parameter_list": "(page...
[ 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 feasible(pages, n, k, mid):\n required_students = 1\n current_pages = 0\n \n for i in range(n):\n if current_pages + pages[i] <= mid:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005745", "row_id": 5745, "seed_ids": "[18530]" }
0.761456
Taco_5745
I
[ "can_allocate", "allocate_books" ]
2
[ [ "allocate_books", "can_allocate" ] ]
1
[]
false
[]
false
pytest
false
[]
true
cf725d7750c209daf1b47524d14f8d561d58239d
0fe3e509356936727d68a434fd9c74c64d6682f2
v1.0
instruct
Taco
Taco_5751_I
Given an `n`-length array of integers, `A`, write a function to determine whether it's possible to partition the array into two non-empty subarrays, such that the product of the sums of these subarrays is a perfect square. ### Input Format - The first line contains a single integer `n`, the size of array `A`. - The se...
import math def is_product_of_sums_perfect_square(n, A): total_sum = sum(A) prefix_sum = 0 for i in range(n - 1): prefix_sum += A[i] rest_sum = total_sum - prefix_sum product = prefix_sum * rest_sum if is_perfect_square(product): return "YES" return...
from solution import is_product_of_sums_perfect_square def test_example_0(): n = 4 A = [1, 2, 3, 4] assert is_product_of_sums_perfect_square(n, A) == "YES" def test_example_1(): n = 3 A = [1, 6, 5] assert is_product_of_sums_perfect_square(n, A) == "NO" def test_single_element_each(): n = ...
[ { "docstring": null, "function_declaration": "def is_product_of_sums_perfect_square(n, A):", "function_name": "is_product_of_sums_perfect_square", "parameter_list": "(n, A)" }, { "docstring": null, "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_squa...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef can_partition_to_perfect_square(n, A):\n total_sum = sum(A)\n prefix_sum = 0\n \n for i in range(n - 1):\n prefix_sum += A[i]...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005751", "row_id": 5751, "seed_ids": "[10509]" }
0.646071
Taco_5751
I
[ "is_product_of_sums_perfect_square", "is_perfect_square" ]
2
[ [ "is_product_of_sums_perfect_square", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bd5bd981bd8c0a1ac1b180ddab368c42df888fe3
3f8a31bd4e1562be9997382b337a42acaa944b7b
v1.0
instruct
Taco
Taco_5763_I
You are given a binary tree and an integer K. Your task is to find the length of the longest path where each node's value is distinct and the sum of the values does not exceed K. ### Input Format - The first line contains an integer T, denoting the number of test cases. - Each test case starts with an integer N, the...
class TreeNode: def __init__(self, value=0): self.value = value self.left = None self.right = None def build_tree(nodes, edges): if not nodes: return None node_dict = {i + 1: TreeNode(value) for i, value in enumerate(nodes)} for u, v in edges: if node_d...
import pytest from solution import process_input_and_solve def test_case1(capsys): input_str = """1 5 10 20 30 40 50 1 2 1 3 2 4 2 5 80""" expected_output = "3\n" process_input_and_solve(input_str) captured = capsys.readouterr() assert captured.out == expected_output def test_case2(capsys): in...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.children = []\n\ndef construct_tree(nodes, edges):\n node_objs = [Tree...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005763", "row_id": 5763, "seed_ids": "[2276]" }
0.729416
Taco_5763
I
[ "build_tree", "longest_path_sum_k", "process_input_and_solve" ]
3
[ [ "process_input_and_solve", "build_tree" ], [ "process_input_and_solve", "longest_path_sum_k" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
a38a04aeace3355cb9a8957c2765985305013c44
56eb0fed8ee2c11fb59677cf4227f8f39498cf63
v1.0
instruct
Taco
Taco_5786_I
Problem You have been tasked to help a number-moving robot that operates on a grid to return to its home base after a series of commands. The robot starts at the origin of the grid (0, 0). The robot receives two types of instructions: 1. "Move x y": This command tells the robot to move from its current position to (...
def final_position(commands): """ Determine the robot's final position after executing a series of commands. :param commands: List of strings representing the commands. :return: A tuple of integers representing the final x, y coordinates of the robot. """ position = (0, 0) for comm...
from solution import final_position, process_commands def test_example_1(): commands = [ "5", "Move 1 2", "Move 3 4", "Return", "Move -1 -1", "Move 5 5" ] assert process_commands(commands) == "5 5" def test_example_2(): commands = [ "3", ...
[ { "docstring": "Determine the robot's final position after executing a series of commands.\n\n:param commands: List of strings representing the commands.\n:return: A tuple of integers representing the final x, y coordinates of the robot.", "function_declaration": "def final_position(commands):", "functi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def final_robot_position(commands):\n \"\"\"\n Determines the final position of the robot on the grid after the given series of commands.\n \n Args:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005786", "row_id": 5786, "seed_ids": "[3522]" }
0.654213
Taco_5786
I
[ "final_position", "process_commands" ]
2
[ [ "process_commands", "final_position" ] ]
1
[]
false
[]
false
pytest
true
[]
true
849aefe7a25da29983781f9893197d2efce5bac3
15feb05c1f4c9460a63cb879889e966fed677557
v1.0
instruct
Taco
Taco_5804_I
You are given an integer n. Check if it is a prime number and also a palindrome. A prime number is a natural number greater than 1 that has no divisors other than 1 and itself. A palindrome is a number that reads the same backward as forward. INPUT: First line of input contains t, the total number of test cases. Th...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def is_palindrome(n): return str(n) == str(n)[::-1] def is_prime_palindrome(n):...
from solution import is_prime, is_palindrome, is_prime_palindrome, solution def test_is_prime(): assert is_prime(11) == True assert is_prime(101) == True assert is_prime(10) == False assert is_prime(1) == False assert is_prime(2) == True assert is_prime(4) == False def test_is_palindrome(): ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": null,...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00005804", "row_id": 5804, "seed_ids": "[828]" }
0.695994
Taco_5804
I
[ "is_prime", "is_palindrome", "is_prime_palindrome", "solution" ]
4
[ [ "is_prime_palindrome", "is_palindrome" ], [ "is_prime_palindrome", "is_prime" ], [ "solution", "is_prime_palindrome" ] ]
3
[]
false
[]
false
pytest
true
[]
true
0bbb09f5b1016f80c671f8f7917cf7cd89bf0c4a
e0597e1b38bdb8dc39123bbfbd9f34a55702d175
v1.0
instruct
Taco
Taco_5806_I
## Your task You have a small pond in your backyard which you have populated with several species of fish, denoted by an array of species names. Among these species, there are some predatory fish that tend to decrease the number of other fish over time. You are given a list of predation rules that define which species...
import random def simulate_fish_population(fish_population, predation_rules, days): population = fish_population[:] for _ in range(days): predate(population, predation_rules) return population def predate(population, predation_rules): # Create a copy of the population to maintain the...
from solution import simulate_fish_population def test_no_predation(): fish_population = ["bass", "salmon"] predation_rules = {} days = 3 assert simulate_fish_population(fish_population, predation_rules, days) == ["bass", "salmon"] def test_simple_case(): fish_population = ["bass", "trout"] pr...
[ { "docstring": null, "function_declaration": "def simulate_fish_population(fish_population, predation_rules, days):", "function_name": "simulate_fish_population", "parameter_list": "(fish_population, predation_rules, days)" }, { "docstring": null, "function_declaration": "def predate(pop...
[ 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 random\nfrom typing import List, Dict\n\ndef simulate_fish_population(fish_population: List[str], predation_rules: Dict[str, List[str]], days: int) -> List[...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005806", "row_id": 5806, "seed_ids": "[17915]" }
0.534143
Taco_5806
I
[ "simulate_fish_population", "predate" ]
2
[ [ "simulate_fish_population", "predate" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc72a68f7f0fa31630bd913b23216b9c7fa243b1
59f0057cc50fcc2e29ab34e2864bd2f4a86c6021
v1.0
instruct
Taco
Taco_5850_I
A village of goblins has recently learned about the magic of computing and is trying to develop a system to manage their community. They have a list of unique tasks they need to perform each day. Each task appears only once in their daily schedule but can range in importance. Each task has a name and a priority level....
def sort_tasks(task_list): """ Sorts the tasks based on their priority while maintaining the original order for tasks with the same priority. Parameters: task_list (list of tuples): A list of tuples where each tuple contains a task name and its priority. Returns: list of tuples...
def test_example_case(): input_str = "5\nclean 2\ncook 3\nstudy 1\nmeditate 2\ngarden 3" expected_output = "study 1\nclean 2\nmeditate 2\ncook 3\ngarden 3" assert manage_tasks(input_str) == expected_output def test_all_same_priority(): input_str = "3\nclean 1\ncook 1\nstudy 1" expected_output = "cl...
[ { "docstring": "Sorts the tasks based on their priority while maintaining the original order\nfor tasks with the same priority.\n\nParameters:\ntask_list (list of tuples): A list of tuples where each tuple contains a task\nname and its priority.\n\nReturns:\nlist of tuples: A sorted list of tasks based on their...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_tasks_by_priority(task_list):\n \"\"\"\n Sorts tasks by priority while preserving the relative order of tasks with the same priority.\n \n Arg...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005850", "row_id": 5850, "seed_ids": "[13082]" }
0.54581
Taco_5850
I
[ "sort_tasks", "format_tasks", "manage_tasks" ]
3
[ [ "manage_tasks", "format_tasks" ], [ "manage_tasks", "sort_tasks" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3d2b78962ed36afaead01691abc2c9af41cb5e6c
88a0b64825219d7e4af42cfe998250ea123f6030
v1.0
instruct
Taco
Taco_5860_I
A number is called a palindromic number if it remains the same when its digits are reversed. For example, 121 and 1331 are palindromic numbers, while 123 and 1321 are not. Given a number $n$, check if $n$ is a palindromic number. -----Input----- The first line of the input contains an integer $t$ ($1 \leq t \leq 10^3...
def is_palindromic_number(n): """ Check if the given number n is a palindromic number. """ n_str = str(n) return n_str == n_str[::-1] def palindromic_numbers(t, numbers): """ For a list of numbers, determine if each one is a palindromic number. """ results = [] for number in num...
from solution import is_palindromic_number, palindromic_numbers def test_is_palindromic_number(): assert is_palindromic_number(121) == True assert is_palindromic_number(123) == False assert is_palindromic_number(1331) == True assert is_palindromic_number(56765) == True assert is_palindromic_number(...
[ { "docstring": "Check if the given number n is a palindromic number.", "function_declaration": "def is_palindromic_number(n):", "function_name": "is_palindromic_number", "parameter_list": "(n)" }, { "docstring": "For a list of numbers, determine if each one is a palindromic number.", "fu...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_palindromic_number(n):\n \"\"\"\n Check if the given number n is a palindromic number.\n \"\"\"\n str_n = str(n)\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005860", "row_id": 5860, "seed_ids": "[14605]" }
0.736436
Taco_5860
I
[ "is_palindromic_number", "palindromic_numbers" ]
2
[ [ "palindromic_numbers", "is_palindromic_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02fb359a00268e5c937df9fe620787421d981839
3bc9b8860b3cbe3604240e8c5a5bdb90c40b2b8d
v1.0
instruct
Taco
Taco_5900_I
In a city, there is a famous rectangular garden that is a popular spot for morning joggers. The garden has been divided into a grid of `m x n` blocks, where each block can either contain a tree or be empty. Joggers prefer to run on paths that do not contain any trees. You need to determine the length of the longest pos...
def longest_path(m, n, garden): from collections import deque if garden[0][0] == '1' or garden[m-1][n-1] == '1': return "NA" directions = [(0, 1), (1, 0)] queue = deque([((0, 0), 0)]) visited = set([(0, 0)]) while queue: (x, y), length = queue.popleft() ...
def test_example1(): m, n = 3, 3 grid = "0 0 1\n1 0 0\n0 0 0" assert get_longest_path(m, n, grid) == 4 def test_example2(): m, n = 3, 3 grid = "0 0 1\n1 1 0\n0 0 0" assert get_longest_path(m, n, grid) == "NA" def test_single_block_passable(): m, n = 1, 1 grid = "0" assert get_longe...
[ { "docstring": null, "function_declaration": "def longest_path(m, n, garden):", "function_name": "longest_path", "parameter_list": "(m, n, garden)" }, { "docstring": null, "function_declaration": "def get_longest_path(m, n, grid_string):", "function_name": "get_longest_path", "pa...
[ 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 longest_path(m, n, grid):\n from collections import deque\n\n if grid[0][0] == '1' or grid[m-1][n-1] == '1':\n return \"NA\"\n\n directions = [...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005900", "row_id": 5900, "seed_ids": "[5752]" }
0.677156
Taco_5900
I
[ "longest_path", "get_longest_path" ]
2
[ [ "get_longest_path", "longest_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5946e3bd195e206a516d7dbd9190badd21bc33df
afa35875c3b1f82b6efe9fa68cb6cd752ff33f9e
v1.0
instruct
Taco
Taco_5917_I
Diana loves playing with numbers. One day, she thought of an interesting game with her friends. The game is to find the smallest positive number that is missing from a given list of integers. For instance, if the given list is [3, 4, -1, 1], the smallest positive number missing from the list is 2. Your task is to he...
def find_missing_positive(nums): """ Finds the smallest positive number missing from the list. """ n = len(nums) for i in range(n): while 1 <= nums[i] <= n and nums[nums[i] - 1] != nums[i]: # Swap nums[i] with the number at its correct position nums[nums[i] - 1], nums...
def test_example_case(): assert smallest_missing_positive_number(5, [3, 4, -1, 1, 2]) == 5 def test_all_negative_numbers(): # Should return 1 since 1 is the smallest positive number assert smallest_missing_positive_number(4, [-1, -2, -3, -4]) == 1 def test_all_positive_continuous_numbers(): # No missi...
[ { "docstring": "Finds the smallest positive number missing from the list.", "function_declaration": "def find_missing_positive(nums):", "function_name": "find_missing_positive", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def smallest_missing_positive_numb...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_smallest_missing_positive(nums):\n \"\"\"\n Returns the smallest positive number that is missing from the list nums.\n \"\"\"\n # Separate out...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005917", "row_id": 5917, "seed_ids": "[12920]" }
0.607507
Taco_5917
I
[ "find_missing_positive", "smallest_missing_positive_number" ]
2
[ [ "smallest_missing_positive_number", "find_missing_positive" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f4b62661158b8fe7ea5333ce4d8c2990e07e0413
a23e0bcba9f4be3232f89ce6c7e917707cf38480
v1.0
instruct
Taco
Taco_5927_I
A website maintenance team needs to distribute its tasks for the upcoming week. Each task needs a certain number of hours to be completed and brings a certain number of satisfaction points when completed. The manager wants to maximize the total satisfaction points while adhering to the weekly working hours constraint. ...
def knapsack_max_satisfaction(tasks, max_hours): n = len(tasks) dp = [0] * (max_hours + 1) for hours, satisfaction in tasks: for h in range(max_hours, hours - 1, -1): dp[h] = max(dp[h], dp[h - hours] + satisfaction) return dp def max_satisfaction_points(tasks, queries): ...
from solution import knapsack_max_satisfaction, max_satisfaction_points def test_knapsack_max_satisfaction(): tasks = [(4, 5), (3, 7), (2, 10)] dp = knapsack_max_satisfaction(tasks, 10) assert dp[5] == 17 assert dp[6] == 17 assert dp[10] == 22 def test_max_satisfaction_points(): tasks = [(4, 5...
[ { "docstring": null, "function_declaration": "def knapsack_max_satisfaction(tasks, max_hours):", "function_name": "knapsack_max_satisfaction", "parameter_list": "(tasks, max_hours)" }, { "docstring": null, "function_declaration": "def max_satisfaction_points(tasks, queries):", "funct...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_satisfaction(n, tasks, q, queries):\n \"\"\"\n Function to calculate the maximum satisfaction points achievable within a given number of hours.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005927", "row_id": 5927, "seed_ids": "[2979]" }
0.700728
Taco_5927
I
[ "knapsack_max_satisfaction", "max_satisfaction_points" ]
2
[ [ "max_satisfaction_points", "knapsack_max_satisfaction" ] ]
1
[]
false
[]
false
pytest
true
[]
true
565c1be104bb3458f9205f5d4fa1b757de17b367
5b40a7d0a0dc39c23947805e7d36fce1a75b9a75
v1.0
instruct
Taco
Taco_6025_I
CodeMasterBot loves prime numbers and is interested in finding the smallest prime number greater than a given number. He could use some help with a program that can efficiently find such prime numbers for a given set of queries. Your task is to write a program that takes multiple test cases, with each test case consis...
import math def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True...
from solution import next_prime def test_next_prime_after_10(): assert next_prime(10) == 11 def test_next_prime_after_29(): assert next_prime(29) == 31 def test_next_prime_after_100(): assert next_prime(100) == 101 def test_next_prime_after_1(): assert next_prime(1) == 2 def test_next_prime_after_5...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Function to find the smallest prime number greater than N.", "function_declaration": "def next_prime(N):", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006025", "row_id": 6025, "seed_ids": "[22742]" }
0.619781
Taco_6025
I
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9b3706f252d743b0c2476fb9aee88194fab34204
a848d474c8c56112b0ee68399e4e56532d4bc2d6
v1.0
instruct
Taco
Taco_6026_I
-----INOI 2018, Problem 1, Multiple Paths----- Naveen is a software developer taking part in a treasure hunt adventure. The hunt involves navigating through a maze of N junctions connected by M paths. The junctions are numbered 1 through N. Naveen begins at junction 1 and the treasure is located at junction N. Each pat...
import heapq def minimal_max_path_difficulty(N, M, S, paths, P, stations): adj = [[] for _ in range(N + 1)] for u, v, d in paths: adj[u].append((v, d)) adj[v].append((u, d)) # Use a priority queue for modified Dijkstra’s algorithm pq = [(0, 1, S)] # (max difficulty on route, curre...
def test_minimal_max_path_difficulty(): assert solve_test(5, 6, 5, [(1, 2, 1), (2, 3, 2), (3, 4, 3), (1, 3, 4), (4, 5, 5), (2, 5, 3)], 2, [3]) == 3 assert solve_test(5, 5, 3, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 5, 1), (1, 4, 2)], 5, [2, 3, 4]) == 2 assert solve_test(3, 3, 10, [(1, 2, 4), (2, 3, 6), (1, 3,...
[ { "docstring": null, "function_declaration": "def minimal_max_path_difficulty(N, M, S, paths, P, stations):", "function_name": "minimal_max_path_difficulty", "parameter_list": "(N, M, S, paths, P, stations)" }, { "docstring": null, "function_declaration": "def solve():", "function_na...
[ 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\nfrom collections import defaultdict, deque\n\ndef minimal_maximum_difficulty(N, M, S, paths, P, stations):\n adj = defaultdict(list)\n for u, v...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006026", "row_id": 6026, "seed_ids": "[13916]" }
0.662302
Taco_6026
I
[ "minimal_max_path_difficulty", "solve" ]
2
[ [ "solve", "minimal_max_path_difficulty" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d334db4a473824255b7782ad1bd1470072dd1294
79db2e8eef9effd51196b879edb517d540e83a28
v1.0
instruct
Taco
Taco_6080_I
Given a list of integers, implement a function `rotate_list` that rotates the list to the right by `k` steps, where `k` is a non-negative integer. This should be done in-place without using extra space for another list. If `k` is greater than the length of the list, it should rotate the list multiple times. Function S...
def rotate_list(nums, k): """ Rotates the list nums to the right by k steps in-place. """ n = len(nums) k = k % n # In case k is greater than the length of the list # Reverse the whole list reverse(nums, 0, n - 1) # Reverse the first k elements reverse(nums, 0, k - 1) # Reverse...
from solution import rotate_list def test_rotate_list_basic(): nums = [1, 2, 3, 4, 5, 6, 7] rotate_list(nums, 3) assert nums == [5, 6, 7, 1, 2, 3, 4] def test_rotate_list_negative(): nums = [-1, -100, 3, 99] rotate_list(nums, 2) assert nums == [3, 99, -1, -100] def test_rotate_list_zero_steps...
[ { "docstring": "Rotates the list nums to the right by k steps in-place.", "function_declaration": "def rotate_list(nums, k):", "function_name": "rotate_list", "parameter_list": "(nums, k)" }, { "docstring": "Reverses the sublist of nums from start to end indices in-place.", "function_dec...
[ 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 typing import List\n\ndef rotate_list(nums: List[int], k: int) -> None:\n \"\"\"\n Rotates the list to the right by k steps in place.\n \"\"\"\n n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006080", "row_id": 6080, "seed_ids": "[2564]" }
0.751316
Taco_6080
I
[ "rotate_list", "reverse" ]
2
[ [ "rotate_list", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
310ec7a7db36842704b290dbcbdf9b43bc2e4f15
838d9fd2a881f219f6c4e6277a2117412011d2b4
v1.0
instruct
Taco
Taco_6159_I
A robotic assistant is tasked with arranging a row of books by their thickness. The assistant is given an array representing the thickness of each book in their current order, and it must determine the minimum number of swaps needed to arrange the books in non-decreasing order of their thickness. The robotic assistant ...
def minimum_adjacent_swaps(arr): """ Returns the minimum number of adjacent swaps needed to sort the array in non-decreasing order. """ swaps = 0 n = len(arr) # A modified Bubble Sort to count the swaps for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1...
from solution import robotic_assistant def test_given_example(): assert robotic_assistant(5, [4, 3, 1, 2, 5]) == 5 def test_already_sorted(): assert robotic_assistant(5, [1, 2, 3, 4, 5]) == 0 def test_reverse_sorted(): assert robotic_assistant(5, [5, 4, 3, 2, 1]) == 10 def test_with_duplicates()...
[ { "docstring": "Returns the minimum number of adjacent swaps needed to sort the array in non-decreasing order.", "function_declaration": "def minimum_adjacent_swaps(arr):", "function_name": "minimum_adjacent_swaps", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_swaps_to_sort(arr):\n \"\"\"\n Function to find the minimum number of swaps required to sort the array using adjacent swaps.\n \"\"\"\n n = len...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006159", "row_id": 6159, "seed_ids": "[15604]" }
0.628954
Taco_6159
I
[ "minimum_adjacent_swaps", "robotic_assistant" ]
2
[ [ "robotic_assistant", "minimum_adjacent_swaps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b2a92896c2ac2e4216d60704d6135e5fb00d470
441f3793a374eeb5cab3a2c60be280969b181e06
v1.0
instruct
Taco
Taco_6183_I
Patterndash is a competitive board game played on an n x n grid. Two players, Alice and Bob, alternate turns to place their respective marks, 'A' for Alice and 'B' for Bob, on the grid. Alice always starts first. The goal is to get a continuous straight line (either horizontal, vertical, or diagonal) of exactly k (1 < ...
def check_winner(board, n, k): def has_winner(char): # Check rows for row in range(n): for col in range(n - k + 1): if all(board[row][col + i] == char for i in range(k)): return True # Check columns for col in range(n): ...
from solution import patterndash def test_alice_wins_diagonal(): n = 5 k = 4 grid = [ ['A', '.', '.', '.', '.'], ['.', 'A', '.', '.', '.'], ['.', '.', 'A', '.', '.'], ['.', '.', '.', 'A', '.'], ['.', '.', '.', '.', '.'] ] assert patterndash(n, k, grid) == 'Al...
[ { "docstring": null, "function_declaration": "def check_winner(board, n, k):", "function_name": "check_winner", "parameter_list": "(board, n, k)" }, { "docstring": null, "function_declaration": "def patterndash(n, k, grid):", "function_name": "patterndash", "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": "def pattern_dash_winner(n, k, board):\n def check_line(line, player):\n \"\"\"\n Checks if a specific line contains a continuous sequence of 'play...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00006183", "row_id": 6183, "seed_ids": "[20668]" }
0.602789
Taco_6183
I
[ "check_winner", "patterndash" ]
2
[ [ "patterndash", "check_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
49c1d61f33848cb0af36329dad483da2ccf677b0
e2f3c6c2b9d217897ff47f43a3e15caacb27c936
v1.0
instruct
Taco
Taco_6239_I
A group of archaeologists has discovered an ancient and complex system of interconnected underground tunnels. Each tunnel connects two chamber entrances, and the chambers are numbered 1 through $N$. To prevent getting lost, the archaeologists want to know if it's possible to travel from one chamber to another through t...
def find_connected_components(n, tunnels): from collections import defaultdict, deque # Create adjacency list adjacency_list = defaultdict(list) for a, b in tunnels: adjacency_list[a].append(b) adjacency_list[b].append(a) # To keep track of visited nodes and components ...
def test_are_chambers_connected(): n = 3 tunnels = [(1, 2), (2, 3)] queries = [(1, 2), (1, 3), (2, 3)] assert are_chambers_connected(n, tunnels, queries) == ["YES", "YES", "YES"] n = 4 tunnels = [(1, 2), (2, 3), (3, 4), (4, 1), (1, 3), (2, 4)] queries = [(1, 3), (2, 4), (1, 4)] asse...
[ { "docstring": null, "function_declaration": "def find_connected_components(n, tunnels):", "function_name": "find_connected_components", "parameter_list": "(n, tunnels)" }, { "docstring": null, "function_declaration": "def are_chambers_connected(n, tunnels, queries):", "function_name...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def dfs(graph, start, visited):\n stack = [start]\n while stack:\n node = stack.pop()\n if not visited[node]:\n visited[node] = True...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006239", "row_id": 6239, "seed_ids": "[14794]" }
0.644496
Taco_6239
I
[ "find_connected_components", "are_chambers_connected" ]
2
[ [ "are_chambers_connected", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fa2f6d3535e7d19e4e44f3de8dd3948b1ebcf90e
b030f520612586b7f50603153bbecc7cbb151f26
v1.0
instruct
Taco
Taco_6320_I
A company has a scheduling system for their employees but recently encountered difficulties in managing overlapping shifts. To resolve this, they decided to write a program that can automatically merge overlapping intervals of employee shifts and come up with a new schedule that has only non-overlapping intervals. Eac...
def merge_intervals(intervals): """ Merge overlapping intervals and return the merged intervals sorted by starting times. :param intervals: List of intervals where each interval is a list of two integers [start, end) :return: List of merged intervals """ if not intervals: return [] ...
from solution import merge_intervals, read_and_merge_intervals def test_merge_intervals_case1(): intervals = [[1, 3], [2, 4], [5, 7]] result = merge_intervals(intervals) assert result == [[1, 4], [5, 7]] def test_merge_intervals_case2(): intervals = [[1, 2], [2, 3], [3, 4], [5, 6], [7, 8]] result ...
[ { "docstring": "Merge overlapping intervals and return the merged intervals sorted by starting times.\n\n:param intervals: List of intervals where each interval is a list of two integers [start, end)\n:return: List of merged intervals", "function_declaration": "def merge_intervals(intervals):", "functio...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_intervals(intervals):\n \"\"\"\n Merges overlapping intervals and returns a list of non-overlapping intervals.\n \n :param intervals: List of...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006320", "row_id": 6320, "seed_ids": "[12516]" }
0.621435
Taco_6320
I
[ "merge_intervals", "read_and_merge_intervals" ]
2
[ [ "read_and_merge_intervals", "merge_intervals" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0384fb422f18ce1a739c143853640c0b15a6758c
2fa6873b49570aabf2df6e702d92960a19516b16
v1.0
instruct
Taco
Taco_6434_I
Given a string consisting of uppercase English letters, determine the maximum number of palindrome substrings that can be made by removing at most one character from the string. Note that substrings should be as long as possible. Input: - A single line containing a string `s` (1 ≤ |s| ≤ 100). Output: - A single integ...
def is_palindrome(s): """ Helper function to check if a string is a palindrome. """ return s == s[::-1] def max_palindrome_substrings(s): """ Determines the maximum number of palindrome substrings that can be made by removing at most one character from the string. """ n = len(s) ...
def test_max_palindrome_substrings(): assert max_palindrome_substrings("ABA") == 3 assert max_palindrome_substrings("A") == 1 assert max_palindrome_substrings("ABC") == 1 assert max_palindrome_substrings("AAB") == 2 assert max_palindrome_substrings("AABB") == 2 assert max_palindrome_substrings("...
[ { "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 the maximum number of palindrome substrings\nthat can be made by removing at most o...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_palindrome_substrings(s):\n n = len(s)\n \n def is_palindrome(sub):\n return sub == sub[::-1]\n \n if is_palindrome(s):\n retu...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00006434", "row_id": 6434, "seed_ids": "[18706]" }
0.807039
Taco_6434
I
[ "is_palindrome", "max_palindrome_substrings" ]
2
[ [ "max_palindrome_substrings", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4fbd7f35ba70feccc69b23841ad858516e01004a
5a3b70997b9a2ccc16494b123adef7eee74e6568
v1.0
instruct
Taco
Taco_6461_I
Given an array a_1, a_2, ..., a_{n} of n integers, find the sum of all the prime numbers in the array. A number x is said to be a prime number if it is greater than 1 and has no positive divisors other than 1 and itself. -----Input----- The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of eleme...
def is_prime(num): """ Returns True if num is a prime number, False otherwise. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(29) == True assert is_prime(30) == False...
[ { "docstring": "Returns True if num is a prime number, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers in the given array arr.", "function_declaration": "def su...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, False otherwise.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00006461", "row_id": 6461, "seed_ids": "[6563]" }
0.654258
Taco_6461
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ba7b39568d4e547efac0ffe0c162b6e1ea79454
a69c1be542289c3fa4a05f99d28e0d1108853025
v1.0
instruct
Taco
Taco_6483_I
Alex is a robotics engineer working on a simulation for autonomous drones. Each drone within the simulation moves in a three-dimensional space. The coordinates are denoted as (x, y, z). Drones need to communicate with each other to form a network. Each drone can establish a communication link with another drone if th...
import math def euclidean_distance(a, b): """ Calculates the Euclidean distance between two points a and b in 3D space. """ return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2 + (a[2] - b[2])**2) def find_connected_components(drones, distance_threshold): """ Finds the number of connected comp...
from solution import communication_network def test_case_1(): m, d = 4, 5 coordinates = [ (0, 0, 0), (3, 4, 0), (7, 1, 5), (2, 2, 2) ] assert communication_network(m, d, coordinates) == 2 def test_case_2(): m, d = 3, 3 coordinates = [ (1, 2, 3), ...
[ { "docstring": "Calculates the Euclidean distance between two points a and b in 3D space.", "function_declaration": "def euclidean_distance(a, b):", "function_name": "euclidean_distance", "parameter_list": "(a, b)" }, { "docstring": "Finds the number of connected components in the network of...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef find_connected_components(m, d, positions):\n def distance(drone1, drone2):\n return math.sqrt((drone1[0] - drone2[0])**2 + (drone1[1]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006483", "row_id": 6483, "seed_ids": "[19767]" }
0.636211
Taco_6483
I
[ "euclidean_distance", "find_connected_components", "communication_network" ]
3
[ [ "communication_network", "find_connected_components" ], [ "find_connected_components", "euclidean_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c6d57011548054b53615069323d28f57d3076e5e
34a0bb739ccb65843331fef413059b45067bf535
v1.0
instruct
Taco
Taco_6488_I
In a country called Algorithmia, there are n towns connected by m bidirectional roads. Some of these roads are highways, while others are regular roads. Highways are faster and thus more preferable to use. You are given the information about Algorithmia in two arrays, `R` and `H`, both of size m. `R[i]` represents the...
import heapq def dijkstra(n, roads, highways, start, dest): graph = {i: [] for i in range(1, n+1)} for u, v, w in roads: graph[u].append((w, v)) graph[v].append((w, u)) for x, y, z in highways: graph[x].append((z, y)) graph[y].append((z, x)) distances = {i: float(...
from solution import minimum_travel_distance def test_simple_path_with_both_roads_and_highways(): roads = [ (1, 2, 4), (1, 3, 2), (2, 3, 1), (3, 4, 7), (2, 4, 3), (4, 5, 1) ] highways = [ (3, 5, 2), (1, 5, 8) ] assert minimum_travel_di...
[ { "docstring": null, "function_declaration": "def dijkstra(n, roads, highways, start, dest):", "function_name": "dijkstra", "parameter_list": "(n, roads, highways, start, dest)" }, { "docstring": null, "function_declaration": "def minimum_travel_distance(n, roads, highways, s, d):", ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start, end):\n \"\"\"\n Use Dijkstra's algorithm to find the shortest path from start to end.\n \"\"\"\n n = len(gr...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006488", "row_id": 6488, "seed_ids": "[10314]" }
0.828217
Taco_6488
I
[ "dijkstra", "minimum_travel_distance" ]
2
[ [ "minimum_travel_distance", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
107e84bd43653b02b628986d5c824a3b8ccaa412
cf6563d2907ed8ca8a9f41ab5eb4efd6f89c053e
v1.0
instruct
Taco
Taco_6505_I
In a certain country, there are n cities and m direct, bidirectional flights connecting these cities. The cost of each flight between two cities is known. Your task is to select a subset of these flights such that every city is reachable from any other city (directly or indirectly) and the total cost of the used flight...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot]...
def test_minimum_spanning_tree_example1(): n = 5 m = 6 edges = [(1, 2, 4), (1, 3, 2), (2, 3, 3), (3, 4, 5), (4, 5, 1), (3, 5, 6)] assert solve(n, m, edges) == 11 def test_minimum_spanning_tree_example2(): n = 4 m = 3 edges = [(1, 2, 3), (2, 3, 4), (3, 4, 5)] assert solve(n, m, edges) ==...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, ran...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006505", "row_id": 6505, "seed_ids": "[6599]" }
0.677994
Taco_6505
I
[ "find", "union", "minimum_spanning_tree", "solve" ]
4
[ [ "minimum_spanning_tree", "find" ], [ "minimum_spanning_tree", "union" ], [ "solve", "minimum_spanning_tree" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
f2fdc7cfa6b76cb7ba08dbe688a546271bb9fc44
a450ada400cc188752602819bc1d99d012457caf
v1.0
instruct
Taco
Taco_6510_I
You are given a list of coordinates, each representing a point on a 2D plane. Your task is to determine whether these points form a convex polygon. A polygon is convex if all its interior angles are less than 180 degrees, meaning no points within the polygon are 'inward' or causing a 'dent'. Create a function `isConve...
def cross_product(o, a, b): """ Calculate the cross product of vector OA and OB. A positive cross product indicates a counter-clockwise turn, a negative cross product indicates a clockwise turn, and zero indicates the points are collinear. """ return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o...
from solution import isConvex def test_convex_polygon(): assert isConvex([(0,0), (4,0), (4,3), (0,4)]) == True def test_non_convex_polygon(): assert isConvex([(0,0), (4,0), (4,3), (2,1), (0,4)]) == False def test_triangle_convex(): assert isConvex([(0,0), (1,1), (0,1)]) == True def test_square_convex():...
[ { "docstring": "Calculate the cross product of vector OA and OB.\nA positive cross product indicates a counter-clockwise turn,\na negative cross product indicates a clockwise turn,\nand zero indicates the points are collinear.", "function_declaration": "def cross_product(o, a, b):", "function_name": "cr...
[ 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 cross_product(o, a, b):\n \"\"\"\n Calculate the cross product of vector OA and OB.\n A positive cross product indicates a counter-clockwise turn,\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00006510", "row_id": 6510, "seed_ids": "[8155]" }
0.481332
Taco_6510
I
[ "cross_product", "isConvex" ]
2
[ [ "isConvex", "cross_product" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3f2e3af578cb1bc2b4c490ff7f0b7f24a33c3722
30a2527671a4c29c45c23483b8993a930c8d5c33
v1.0
instruct
Taco
Taco_6512_I
John loves playing with numbers. Recently, he got fascinated with numbers that are divisible by 3 but not by 9. But John is also interested in a specific property: the sum of the digits of such numbers should also be divisible by 3 but not by 9. Given an integer x, John wants to find the smallest number y (y > x) that...
def sum_of_digits(n): """ Helper function to calculate the sum of the digits of a number. """ return sum(int(digit) for digit in str(n)) def find_special_number(x): """ Given an integer x, find the smallest number y (y > x) such that: - y is divisible by 3 but not by 9 - the sum of digi...
from solution import find_special_number def test_find_special_number_case_1(): assert find_special_number(10) == 12 def test_find_special_number_case_2(): assert find_special_number(50) == 51 def test_find_special_number_case_boundary(): assert find_special_number(1) == 3 def test_find_special_number_l...
[ { "docstring": "Helper function to calculate the sum of the digits of a number.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Given an integer x, find the smallest number y (y > x) such that:\n- y is divisible ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_divisible_by_3_not_9(n):\n \"\"\"\n Function to check if a number is divisible by 3 but not by 9.\n \"\"\"\n return n % 3 == 0 and n % 9 != 0\n\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006512", "row_id": 6512, "seed_ids": "[25119]" }
0.682428
Taco_6512
I
[ "sum_of_digits", "find_special_number" ]
2
[ [ "find_special_number", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6e1dd18b1767fa68d6489d802cc201dcf9a3e513
15202c66bea1214745fb5199a9a88a611468476a
v1.0
instruct
Taco
Taco_6549_I
Write a function that takes a list of strings and returns a new list of only those strings that are valid IPv4 addresses. An IPv4 address consists of four decimal numbers, each ranging from 0 to 255, separated by dots (`.`). Leading zeros in any of the four decimal numbers are not allowed unless the number is zero. If ...
def is_valid_ipv4_address(address): """ Check if the given string is a valid IPv4 address. """ parts = address.split(".") if len(parts) != 4: return False for part in parts: if not part.isdigit(): return False if len(part) > 1 and part[0] == "0": # Check...
from solution import is_valid_ipv4_address, filter_valid_ipv4_addresses def test_is_valid_ipv4_address(): assert is_valid_ipv4_address("192.168.1.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.256.256...
[ { "docstring": "Check if the given string is a valid IPv4 address.", "function_declaration": "def is_valid_ipv4_address(address):", "function_name": "is_valid_ipv4_address", "parameter_list": "(address)" }, { "docstring": "Returns a list of valid IPv4 addresses from the input list.", "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_ipv4_address(address):\n \"\"\"\n Checks if a given string is a valid IPv4 address.\n \"\"\"\n parts = address.split('.')\n if len(part...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006549", "row_id": 6549, "seed_ids": "[14540]" }
0.670267
Taco_6549
I
[ "is_valid_ipv4_address", "filter_valid_ipv4_addresses" ]
2
[ [ "filter_valid_ipv4_addresses", "is_valid_ipv4_address" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e6563e6d5dda8664e7795b3999a7c7eec5286113
f9387350d530087094f6f51d61a7d79f146e531b
v1.0
instruct
Taco
Taco_6554_I
You are an expert in designing efficient delivery routes for a logistics company. Recently, your task is to optimize the delivery route in a large warehouse with hundreds of aisles and shelves. Each aisle is connected to multiple other aisles with corridors, and each corridor has a certain time cost associated with wal...
import heapq def dijkstra(V, E, edges, S, T): # Create adjacency list graph = {i: [] for i in range(1, V+1)} for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) # Priority queue to process vertices pq = [(0, S)] # (distance, node) distances = {i: float('inf')...
def test_sample_input_1(): V = 5 E = 6 edges = [ (1, 2, 4), (1, 3, 2), (3, 2, 1), (2, 4, 7), (3, 5, 8), (4, 5, 3) ] S = 1 T = 5 assert shortest_travel_time(V, E, edges, S, T) == 10 def test_sample_input_2(): V = 3 E = 2 edges = [ ...
[ { "docstring": null, "function_declaration": "def dijkstra(V, E, edges, S, T):", "function_name": "dijkstra", "parameter_list": "(V, E, edges, S, T)" }, { "docstring": null, "function_declaration": "def shortest_travel_time(V, E, edges, S, T):", "function_name": "shortest_travel_time...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_delivery_time(V, E, edges, S, T):\n \"\"\"\n Finds the shortest travel time from S to T in a graph with V nodes and E edges.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006554", "row_id": 6554, "seed_ids": "[4150]" }
0.714568
Taco_6554
I
[ "dijkstra", "shortest_travel_time" ]
2
[ [ "shortest_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0e199529a9b655596dd9534d0d17e198423d0254
68eea3287058e2e282007ea3cb62ed1f6f04604c
v1.0
instruct
Taco
Taco_6569_I
Given an integer array A containing N distinct integers, determine if there exists a pair of elements in the array such that the sum of the pair is a prime number. If such a pair exists, return 1 (True), otherwise return 0 (False). Example 1: Input: N = 4, A = [1, 4, 6, 7] Output: 1 Explanation: The pair (1, 6) sums u...
import math def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def hasPrimeSumPair(arr, N): ...
from solution import hasPrimeSumPair def test_example_1(): assert hasPrimeSumPair([1, 4, 6, 7], 4) == 1 def test_example_2(): assert hasPrimeSumPair([1, 3, 5], 3) == 0 def test_prime_sum_pair_exists(): assert hasPrimeSumPair([2, 5, 8, 11], 4) == 1 def test_no_prime_sum_pair(): assert hasPrimeSumPair...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def hasPrimeSumPair(arr, N):", "function_name": "hasPrimeSumPair", "parameter_list": "(arr, N)" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime_number(num):\n \"\"\"\n Checks if a given number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006569", "row_id": 6569, "seed_ids": "[24826]" }
0.711669
Taco_6569
I
[ "is_prime", "hasPrimeSumPair" ]
2
[ [ "hasPrimeSumPair", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ee50a9594663179f723e939d934868a9e4319bed
68204c8dff98c37267241c509d4c541bb1ed3cd2
v1.0
instruct
Taco
Taco_6576_I
Alex is a librarian and needs to help a student, Charlie, retrieve books from a series of shelves. Each shelf has a number of books, and Charlie wants to inquire about a specific range of books across multiple shelves. You need to write a function that efficiently handles multiple queries about the number of books in ...
def prepare_prefix_sums(shelves): """ Prepare the prefix sums for the books on the shelves. """ prefix_sums = [0] * len(shelves) prefix_sums[0] = shelves[0] for i in range(1, len(shelves)): prefix_sums[i] = prefix_sums[i - 1] + shelves[i] return prefix_sums def total_books...
def test_prepare_prefix_sums(): assert prepare_prefix_sums([4, 5, 3, 2, 6]) == [4, 9, 12, 14, 20] def test_total_books_in_range(): prefix_sums = [4, 9, 12, 14, 20] assert total_books_in_range(prefix_sums, 1, 3) == 12 assert total_books_in_range(prefix_sums, 2, 5) == 16 assert total_books_in_range(p...
[ { "docstring": "Prepare the prefix sums for the books on the shelves.", "function_declaration": "def prepare_prefix_sums(shelves):", "function_name": "prepare_prefix_sums", "parameter_list": "(shelves)" }, { "docstring": "Calculate the total number of books in the range l to r (1-based index...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def books_in_range(N, Q, books, queries):\n \"\"\"\n Returns the total number of books in the given range of shelves for each query.\n \n Parameters:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006576", "row_id": 6576, "seed_ids": "[6275]" }
0.663302
Taco_6576
I
[ "prepare_prefix_sums", "total_books_in_range", "books_query" ]
3
[ [ "books_query", "prepare_prefix_sums" ], [ "books_query", "total_books_in_range" ] ]
2
[]
false
[]
false
pytest
false
[]
true
4a9d32bc4f6942d679b1d2e95b74bb6dcbbcd56a
d5da4c86f72eed3c7af7048f190feb9e284d8bcf
v1.0
instruct
Taco
Taco_6617_I
You are a software engineer working on a project that requires scheduling tasks with dependencies. Each task can only start after all its dependencies have been completed. You are given a list of tasks and a list of dependency pairs. Your goal is to determine one possible valid order to complete all tasks. A valid ord...
from collections import defaultdict, deque def find_task_order(n, m, dependencies): graph = defaultdict(list) indegree = [0] * (n + 1) for dep in dependencies: u, v = dep graph[u].append(v) indegree[v] += 1 zero_indegree = deque([node for node in range(1, n + 1) if ind...
from solution import schedule_tasks_with_dependencies, find_task_order, process_input def test_find_task_order(): # Test case 1: Simple case with a clear order n, m = 5, 4 dependencies = [(2, 1), (3, 2), (4, 3), (5, 4)] assert find_task_order(n, m, dependencies) == [5, 4, 3, 2, 1] # Test case 2: N...
[ { "docstring": null, "function_declaration": "def find_task_order(n, m, dependencies):", "function_name": "find_task_order", "parameter_list": "(n, m, dependencies)" }, { "docstring": null, "function_declaration": "def process_input(t, all_cases):", "function_name": "process_input", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef find_task_order(t, test_cases):\n def kahns_algorithm(n, adj_list):\n in_degree = [0] * (n + 1)\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006617", "row_id": 6617, "seed_ids": "[11686]" }
0.580755
Taco_6617
I
[ "find_task_order", "process_input", "schedule_tasks_with_dependencies" ]
3
[ [ "process_input", "find_task_order" ], [ "schedule_tasks_with_dependencies", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
7f018f5341c5d8e5b578c6862d9f0f17731c187e
072a72079b5470b37814be2da231f4e187d0cc76
v1.0
instruct
Taco
Taco_6646_I
Ayesha is a computer science student and she's learning about the concept of prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. She is working on a problem where she needs to find the nth prime number and while she can understand the theoretical part,...
def sieve(limit): is_prime = [True] * (limit + 1) p = 2 while (p * p <= limit): if (is_prime[p] == True): for i in range(p * p, limit + 1, p): is_prime[i] = False p += 1 is_prime[0], is_prime[1] = False, False primes = [p for p in range(limit + 1) if is_pr...
import pytest from solution import nth_prime, get_nth_prime_numbers def test_sieve_function(): '''Test if the sieve function generates correct primes up to a limit.''' primes = sieve(30) assert primes == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] def test_nth_prime_small_values(): '''Test nth prime for smal...
[ { "docstring": null, "function_declaration": "def sieve(limit):", "function_name": "sieve", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def nth_prime(n):", "function_name": "nth_prime", "parameter_list": "(n)" }, { "docstring": null, "...
[ 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 sieve_of_eratosthenes(limit):\n \"\"\"\n Generates a list of prime numbers up to the given limit using the Sieve of Eratosthenes algorithm.\n \"\"\"\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006646", "row_id": 6646, "seed_ids": "[13050]" }
0.616698
Taco_6646
I
[ "sieve", "nth_prime", "get_nth_prime_numbers" ]
3
[ [ "get_nth_prime_numbers", "nth_prime" ], [ "nth_prime", "sieve" ] ]
2
[]
false
[]
false
pytest
true
[]
true
108210252753d24ed4822dfdc3a7d6eea846183c
addf52b8745603e42f6ec3bc4526fbee69f81760
v1.0
instruct
Taco
Taco_6691_I
Sara is playing a game involving a grid of squares. Each square of the grid is either empty or contains an obstacle. Sara wants to move from the top-left corner of the grid to the bottom-right corner. However, she can only move right or down, and cannot move onto squares containing obstacles. Given the grid representa...
def count_paths(grid): m = len(grid) n = len(grid[0]) if grid[0][0] == '#' or grid[m-1][n-1] == '#': return 0 dp = [[0] * n for _ in range(m)] dp[0][0] = 1 for i in range(m): for j in range(n): if grid[i][j] == '#': dp[i][j] = 0 else...
from solution import number_of_ways_to_reach_bottom_right def test_no_obstacles(): grid = ["...", "...", "..."] assert number_of_ways_to_reach_bottom_right(3, 3, grid) == 6 def test_one_obstacle(): grid = ["..#", ".#.", "..."] assert number_of_ways_to_re...
[ { "docstring": null, "function_declaration": "def count_paths(grid):", "function_name": "count_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def number_of_ways_to_reach_bottom_right(m, n, grid):", "function_name": "number_of_ways_to_reach_bottom_...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_paths(grid):\n m = len(grid)\n n = len(grid[0])\n\n if grid[0][0] == '#' or grid[m-1][n-1] == '#':\n return 0\n\n dp = [[0] * n for _ ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00006691", "row_id": 6691, "seed_ids": "[15686]" }
0.758807
Taco_6691
I
[ "count_paths", "number_of_ways_to_reach_bottom_right" ]
2
[ [ "number_of_ways_to_reach_bottom_right", "count_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fcf7941d28bc112cd201e0ba6ed035d4b5475ae0
05c150682985d2a453679966cb5a175bbe1a454f
v1.0
instruct
Taco
Taco_6837_I
Julia is learning about prime numbers and she wants to test her knowledge by creating a series of challenges for her friends. Each challenge involves determining how many prime numbers exist in a given range [L, R]. ------ Input ------ The first line of the input contains an integer T denoting the number of test cas...
def sieve_of_eratosthenes(max_num): """ Generates a list indicating prime status for each number up to max_num. True indicates the number is prime, False indicates it is not. :param max_num: The upper limit for the prime number generation :return: A list of boolean values representing prime status ...
import pytest from solution import prime_count_queries, sieve_of_eratosthenes, count_primes_in_range, process_input def test_sieve_of_eratosthenes(): primes_up_to_10 = sieve_of_eratosthenes(10) expected = [False, False, True, True, False, True, False, True, False, False, False] assert primes_up_to_10 == ex...
[ { "docstring": "Generates a list indicating prime status for each number up to max_num.\nTrue indicates the number is prime, False indicates it is not.\n\n:param max_num: The upper limit for the prime number generation\n:return: A list of boolean values representing prime status for each number", "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 sieve_of_eratosthenes(max_num):\n \"\"\"\n Returns a list of boolean values representing prime status for numbers from 0 to max_num.\n \"\"\"\n is_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00006837", "row_id": 6837, "seed_ids": "[2089]" }
0.657348
Taco_6837
I
[ "sieve_of_eratosthenes", "count_primes_in_range", "prime_count_queries", "process_input" ]
4
[ [ "prime_count_queries", "count_primes_in_range" ], [ "prime_count_queries", "sieve_of_eratosthenes" ], [ "process_input", "prime_count_queries" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
1e462490ab59e7912bdbcaba9a35282be0a5d758
c546599f8481506bd852a1978dbc7130d928091d
v1.0
instruct
Taco
Taco_6846_I
A city’s transportation department is designing a new public bus route. They have a set of bus stops and a set of direct roads between some pairs of bus stops. The goal is to find the shortest possible route that visits each bus stop exactly once and returns to the starting bus stop. This is a well-known problem in com...
from itertools import permutations def tsp(matrix): n = len(matrix) # List all permutations of bus stops except the starting point (0) permutations_of_stops = permutations(range(1, n)) min_distance = float('inf') for perm in permutations_of_stops: # Start with the first stop (0) ...
def test_tsp_example1(): matrix = [ [0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0] ] assert tsp(matrix) == 80 def test_tsp_example2(): matrix = [ [0, 29, 20], [29, 0, 15], [20, 15, 0] ] assert tsp(matrix) == 64 def tes...
[ { "docstring": null, "function_declaration": "def tsp(matrix):", "function_name": "tsp", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def read_input_and_compute_tsp():", "function_name": "read_input_and_compute_tsp", "parameter_list": "()" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef traveling_salesperson(n, distance_matrix):\n \"\"\"\n Solves the Traveling Salesperson Problem (TSP) for a small nu...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006846", "row_id": 6846, "seed_ids": "[6503]" }
0.747068
Taco_6846
I
[ "tsp", "read_input_and_compute_tsp" ]
2
[ [ "read_input_and_compute_tsp", "tsp" ] ]
1
[]
false
[]
false
pytest
false
[]
true
298d7cfbdc680eab99e575691b3209a1623bb44a
7cc73b3e28f35982a352aee601ac4b708984e5d6
v1.0
instruct
Taco
Taco_6878_I
You are given an array of integers $a = [a_1, a_2, \dots, a_n]$. You need to process $q$ queries on this array. Each query is described by two numbers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le n$). The final result for each query is the product of the elements from index $l_i$ to $r_i$, inclusive, in the original array. ...
def product_queries(array, queries): max_product = 10**9 results = [] for l, r in queries: product = 1 for i in range(l - 1, r): product *= array[i] if product > max_product: product = max_product break results.append(produ...
from solution import execute_queries def test_single_query(): assert execute_queries(5, [2, 3, 5, 7, 11], 1, [(1, 3)]) == [30] def test_multiple_queries(): assert execute_queries(5, [2, 3, 5, 7, 11], 3, [(1, 3), (2, 4), (1, 5)]) == [30, 105, 2310] def test_large_product(): assert execute_queries(5, [2, 3...
[ { "docstring": null, "function_declaration": "def product_queries(array, queries):", "function_name": "product_queries", "parameter_list": "(array, queries)" }, { "docstring": null, "function_declaration": "def execute_queries(n, array, q, queries):", "function_name": "execute_querie...
[ 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 query_product(n, a, queries):\n results = []\n for l, r in queries:\n product = 1\n for i in range(l-1, r):\n product *= a[i]\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006878", "row_id": 6878, "seed_ids": "[23343]" }
0.703128
Taco_6878
I
[ "product_queries", "execute_queries" ]
2
[ [ "execute_queries", "product_queries" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4568781ba6014a30440804da33317dc12bd1b525
e8ce0ecee2e44fb634ffbcd2d2fc9c77b33c60c0
v1.0
instruct
Taco
Taco_6890_I
In an enchanted forest, there are groups of magical creatures called Fluffkins who live in enchanted trees. Each Fluffkin family tree has a special number. The magical number is created by adding together the digital root of each member's age. The digital root of a number is calculated by an iterative process of summi...
def digital_root(n): """ Calculate the digital root of a number. """ while n >= 10: n = sum(int(digit) for digit in str(n)) return n def magical_number(ages): """ Calculate the magical number for the given ages of Fluffkin family members. """ total_digital_root_sum = sum(dig...
from solution import digital_root, magical_number def test_digital_root_single_digit(): assert digital_root(5) == 5 def test_digital_root_multiple_iterations(): assert digital_root(942) == 6 assert digital_root(123) == 6 assert digital_root(456) == 6 assert digital_root(789) == 6 def test_digital...
[ { "docstring": "Calculate the digital root of a number.", "function_declaration": "def digital_root(n):", "function_name": "digital_root", "parameter_list": "(n)" }, { "docstring": "Calculate the magical number for the given ages of Fluffkin family members.", "function_declaration": "def...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digital_root(n):\n \"\"\"\n Computes the digital root of a given number n.\n \"\"\"\n while n >= 10:\n n = sum(int(digit) for digit in str(n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00006890", "row_id": 6890, "seed_ids": "[3370]" }
0.483085
Taco_6890
I
[ "digital_root", "magical_number" ]
2
[ [ "magical_number", "digital_root" ] ]
1
[]
false
[]
false
pytest
true
[]
true
16a7e426b02b7354faf4b012fa9e06be615e56b8
8b48f31467ff6a1316cd24db178d8662cf7a41c9
v1.0
instruct
Taco
Taco_6938_I
A network of roads forms a tree structure with n nodes, where each node represents a city and each edge represents a road connecting two cities. The length of each road is 1. You are given q queries, each containing two integers a and b, which represent two cities in the network. Your task is to determine the distance ...
from collections import deque, defaultdict def build_tree(n, edges): tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) return tree def bfs_distance(tree, n): dist = [-1] * (n + 1) dist[1] = 0 queue = deque([1]) while queue: node = queue...
def test_find_distances(): n = 5 edges = [ (1, 2), (1, 3), (2, 4), (2, 5) ] queries = [ (4, 5), (1, 4), (3, 5) ] preprocess(build_tree(n, edges), n) result = find_distances(n, edges, queries) assert result == [2, 2, 3] def test_fi...
[ { "docstring": null, "function_declaration": "def build_tree(n, edges):", "function_name": "build_tree", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def bfs_distance(tree, n):", "function_name": "bfs_distance", "parameter_list": "(tree, n)" }...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nsys.setrecursionlimit(200000)\n\ndef preprocess_lca(n, edges):\n from collections import defaultdict, deque\n \n graph = defaultdict(list)\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00006938", "row_id": 6938, "seed_ids": "[13726]" }
0.754139
Taco_6938
I
[ "build_tree", "bfs_distance", "find_distances", "lca", "parent", "preprocess" ]
6
[ [ "find_distances", "bfs_distance" ], [ "find_distances", "build_tree" ], [ "find_distances", "lca" ], [ "lca", "parent" ] ]
4
[]
false
[]
false
pytest
false
[]
true
3180b7b0f6c1efdf9da8110fdc501f675766708f
7f8728a364d2910767eed6797eb866516522bed8
v1.0
instruct
Taco
Taco_7048_I
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Write a function that finds the largest prime number less than or equal to a given integer `n`. ```if-not:haskell Return "Not valid" if the input is not a positive integer. ``` ```if:haskell Return `Nothing` if the...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True d...
from solution import largest_prime def test_largest_prime_within_range(): assert largest_prime(10) == 7 assert largest_prime(29) == 29 assert largest_prime(15) == 13 def test_largest_prime_edge_cases(): assert largest_prime(2) == 2 assert largest_prime(3) == 3 def test_largest_prime_invalid_input...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the largest prime number less than or equal to the given integer n.\nReturns \"Not valid\" if n i...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Helper function to check if a given number is prime.\"\"\"\n if num <= 1:\n return False\n if num == 2:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007048", "row_id": 7048, "seed_ids": "[526]" }
0.741114
Taco_7048
I
[ "is_prime", "largest_prime" ]
2
[ [ "largest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c70abb54c194d5b235ffb628dc048a1f7657a9ca
c34c96942f8b5be4fd6be6d90a688b9b9b2d0333
v1.0
instruct
Taco
Taco_7084_I
Given a string S of length N consisting of lowercase letters, you can perform a left cyclic shift operation where the first character of the string moves to the end of the string. Define `rotateLeft(S, x)` as the string resulting from performing the left cyclic shift operation x times on S. You are given an integer ...
def rotateLeft(S, x): """ Returns the string S rotated to the left x times. """ N = len(S) x = x % N # Only rotating x % N times is needed return S[x:] + S[:x] def character_frequencies(S): """ Returns a list of frequencies of lowercase letters in the string S. """ freq = [0] *...
def test_rotateLeft(): assert rotateLeft("abcde", 1) == "bcdea" assert rotateLeft("abcde", 2) == "cdeab" assert rotateLeft("abcde", 5) == "abcde" assert rotateLeft("abcde", 7) == "cdeab" # 7 % 5 == 2 def test_character_frequencies(): assert character_frequencies("abcde") == [1, 1, 1, 1, 1, 0, 0, 0...
[ { "docstring": "Returns the string S rotated to the left x times.", "function_declaration": "def rotateLeft(S, x):", "function_name": "rotateLeft", "parameter_list": "(S, x)" }, { "docstring": "Returns a list of frequencies of lowercase letters in the string S.", "function_declaration": ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef rotateLeft(S, x):\n x = x % len(S) # To avoid extra unnecessary rotations\n return S[x:] + S[:x]\n\ndef character_fre...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00007084", "row_id": 7084, "seed_ids": "[19105]" }
0.691965
Taco_7084
I
[ "rotateLeft", "character_frequencies", "process_queries" ]
3
[ [ "process_queries", "character_frequencies" ], [ "process_queries", "rotateLeft" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
b893ec72d301d33364bb53310ff4b480d6f1c7fa
96f1444c5b455111d5eb7eb4976afd49cc266f03
v1.0
instruct
Taco
Taco_7123_I
A software development company wants to keep track of the integrity of its codebase by ensuring every code merge into the main branch is conducted correctly. The merge data is recorded as follows: Given the Merge Activity Data, calculate the maximum number of continuous merges that did not have any conflicts. Note: If...
def max_continuous_merges(test_cases): results = [] for case in test_cases: N = case[0] merges = case[1] max_non_conflict = 0 current_non_conflict = 0 for merge in merges: description, conflict = merge if conflict == 0: cur...
def test_max_continuous_merges(): input_data = """2 5 "Merge PR #1" 0 "Merge PR #2" 1 "Merge PR #3" 0 "Merge PR #4" 0 "Merge PR #5" 0 4 "Merge Feature X" 0 "Merge Bugfix Y" 1 "Merge Enhancement Z" 0 "Merge Hotfix Q" 0""" expected_output = [3, 2] assert solve(input_data) == expected_output def test_sin...
[ { "docstring": null, "function_declaration": "def max_continuous_merges(test_cases):", "function_name": "max_continuous_merges", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_data):", "function_name": "parse_input", "param...
[ 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 maximum_non_conflict_merges(T, test_cases):\n results = []\n for i in range(T):\n N, merges = test_cases[i]\n max_count = 0\n curren...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007123", "row_id": 7123, "seed_ids": "[3717]" }
0.546979
Taco_7123
I
[ "max_continuous_merges", "parse_input", "solve" ]
3
[ [ "solve", "max_continuous_merges" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
1ec59919af4c2f7d10d70eec5b05c8f949c52f7f
e8f7e53c23de3d265f2320657c7fb01cbe423dc8
v1.0
instruct
Taco
Taco_7152_I
In a remote town, the residents have an unusual habit of forming groups for any activity they plan, always ensuring that all participants in each group share a common interest. The number of interests and individuals in the town is vast and varied. Given an integer $n$ representing the number of residents and an integ...
def find(parent, x): if parent[x] != x: parent[x] = find(parent, parent[x]) return parent[x] def union(parent, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: parent[rootX] = rootY def count_groups(n, m, pairs): parent = [i for i in range(n + 1)] ...
from solution import count_groups def test_example_1(): assert count_groups(5, 4, [(1, 2), (2, 3), (4, 5), (3, 4)]) == 1 def test_example_2(): assert count_groups(5, 3, [(1, 2), (2, 3), (4, 5)]) == 2 def test_no_pairs(): assert count_groups(5, 0, []) == 5 def test_single_pair(): assert count_groups(...
[ { "docstring": null, "function_declaration": "def find(parent, x):", "function_name": "find", "parameter_list": "(parent, x)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }, { "doc...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_groups(n, m, connections):\n \"\"\"\n Find the number of distinct groups formed based on shared interests.\n \n :param n: Number of residents\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007152", "row_id": 7152, "seed_ids": "[18593]" }
0.646502
Taco_7152
I
[ "find", "union", "count_groups" ]
3
[ [ "count_groups", "find" ], [ "count_groups", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
b592cd165896d6d577f8cf9106f6e52dbd9c8e4e
57e8b48b230cdc1cc7e3802b7df65b1544065800
v1.0
instruct
Taco
Taco_7179_I
A cyclist is planning a route through a city represented by a grid of $M$ rows and $N$ columns, where each cell contains information about the terrain's difficulty. The cyclist starts at the top-left corner of the grid (position $(1,1)$) and aims to reach the bottom-right corner of the grid (position $(M,N)$). The cycl...
import heapq def min_difficulty_route(M, N, grid): """ Function to calculate the minimum difficulty path from top-left to bottom-right. M: number of rows N: number of columns grid: MxN matrix of terrain difficulty levels """ # Directions you can move: right (0, 1) and down (1, 0) direct...
def test_min_difficulty_small_grid(): input_data = "3 3\n1\n3\n2\n7\n4\n9\n2\n1\n5" assert min_difficulty_from_input(input_data) == 14 def test_min_difficulty_single_cell(): input_data = "1 1\n5" assert min_difficulty_from_input(input_data) == 5 def test_min_difficulty_two_by_two(): input_data = "...
[ { "docstring": "Function to calculate the minimum difficulty path from top-left to bottom-right.\nM: number of rows\nN: number of columns\ngrid: MxN matrix of terrain difficulty levels", "function_declaration": "def min_difficulty_route(M, N, grid):", "function_name": "min_difficulty_route", "parame...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_difficulty_path(M, N, grid):\n \"\"\"\n Calculate the minimum difficulty path from the top-left corner to the bottom-right corner of the grid\n us...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007179", "row_id": 7179, "seed_ids": "[13079]" }
0.713301
Taco_7179
I
[ "min_difficulty_route", "min_difficulty_from_input" ]
2
[ [ "min_difficulty_from_input", "min_difficulty_route" ] ]
1
[]
false
[]
false
pytest
false
[]
true
05979b409704b2974c611b1036eaddc6384023dd
26b8feb2f064037ad03c94af60126c45fc4de7ad
v1.0
instruct
Taco
Taco_7190_I
John loves playing with numbers and recently found the concept of palindromic numbers fascinating. A palindromic number is a number that remains the same when its digits are reversed. John came up with a challenging game. Given a range [L, R], he wants to find out how many numbers in that range are palindromic and how...
def is_palindrome(n): """ Check if a given number is a palindrome. """ return str(n) == str(n)[::-1] def count_palindromic_numbers_in_range(L, R): """ Count the number of palindromic and non-palindromic numbers in the range [L, R]. """ palindromic_count = 0 non_palindromic_count = 0...
from solution import is_palindrome, count_palindromic_numbers_in_range, process_test_cases def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1221) == True assert is_palindrome(12321) == True assert is_palindrome(10) == False def tes...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Count the number of palindromic and non-palindromic numbers in the range [L, R].", "function_declaratio...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindromic(n):\n \"\"\"\n Checks if a number n is palindromic.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef count_palindromic_numbers(L, R):...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00007190", "row_id": 7190, "seed_ids": "[8224]" }
0.72002
Taco_7190
I
[ "is_palindrome", "count_palindromic_numbers_in_range", "process_test_cases" ]
3
[ [ "count_palindromic_numbers_in_range", "is_palindrome" ], [ "process_test_cases", "count_palindromic_numbers_in_range" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
a7d0b7255407f6bae86b1a5aac50156b0848467c
980d9923d37edc3058d652eb7f90881e76132760
v1.0
instruct
Taco
Taco_7228_I
You have a list of integers. You are required to modify the list such that every prime number in the list is replaced with the sum of the prime numbers that are smaller than it and those that appear before it in the list. Your task is to return this modified list. For example, given the list: [10, 3, 7, 8, 19, 5], the...
def is_prime(num): """ Helper function to check if a number is a prime number. """ if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def solve(lst): """ Function to replace each prime number in the list w...
from solution import solve def test_no_primes(): assert solve([4, 6, 8]) == [4, 6, 8] def test_all_primes(): assert solve([2, 3, 5, 7]) == [0, 2, 5, 10] def test_mixed_numbers(): assert solve([10, 3, 7, 8, 19, 5]) == [10, 0, 3, 8, 10, 3] def test_with_single_prime(): assert solve([4, 9, 11, 13, 5]) ...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to replace each prime number in the list with the sum of all prime numbers smaller than i...
[ 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 is_prime(n):\n \"\"\"Check if the number n is a prime number.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00007228", "row_id": 7228, "seed_ids": "[2047]" }
0.580033
Taco_7228
I
[ "is_prime", "solve" ]
2
[ [ "solve", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9c4d7771b21b55591197f8bc5f57bd7825b5ae47
05c658748724f32e9cc9d4d37b5335b372aad71b
v1.0
instruct
Taco
Taco_7328_I
A group of friends wants to go on a road trip and rent a car. Each friend has preferences regarding the car's features, like manual or automatic transmission, air conditioning, number of seats, etc. Your task is to help them choose the optimal car that fulfills the majority of their requirements. Each friend has a set ...
def find_optimal_car(n, friends_preferences, m, cars_features): all_required_features = set() optional_features_by_friend = [] for R, O, required, optional in friends_preferences: all_required_features.update(required) optional_features_by_friend.append(set(optional)) best_car_inde...
def test_sample_case(): input_str = """3 2 1 air_conditioning automatic sunroof 1 2 manual sunroof heated_seats 2 0 air_conditioning automatic 4 5 automatic air_conditioning sunroof manual heated_seats 4 air_conditioning automatic sunroof heated_seats 3 sunroof manual heated_seats 2 automatic heated_seats""" as...
[ { "docstring": null, "function_declaration": "def find_optimal_car(n, friends_preferences, m, cars_features):", "function_name": "find_optimal_car", "parameter_list": "(n, friends_preferences, m, cars_features)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):...
[ 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_optimal_car(n, friends_preferences, m, cars_features):\n all_required_features = set()\n optional_features_by_friend = []\n\n for R, O, required,...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00007328", "row_id": 7328, "seed_ids": "[18576]" }
0.641659
Taco_7328
I
[ "find_optimal_car", "parse_input", "optimal_car_selection" ]
3
[ [ "optimal_car_selection", "find_optimal_car" ], [ "optimal_car_selection", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
82e0f3913bf932c6f24c52c7087e3a1ac9ef7788
46bf1f85dedd7e722bf7a7602dc94c2bc485d486
v1.0
instruct
Taco
Taco_7366_I
Jack enjoys organizing puzzles and games for his friends. Recently, he came up with a fun word game. The game consists of finding the longest word that can be formed by deleting some characters of a given string without reordering the remaining characters. For instance, if the given string is "codingchallenge" and the...
def is_subsequence(s, word): """ Helper function to check if 'word' can be formed as a subsequence of 's'. """ iter_s = iter(s) return all(char in iter_s for char in word) def longest_word(s, words): """ Given a string s and a list of words, returns the longest word that can be formed b...
from solution import longest_word def test_longest_word_example(): s = "codingchallenge" words = ["code", "challenge", "cool"] assert longest_word(s, words) == "challenge" def test_longest_word_multiple_same_length(): s = "abcdefghij" words = ["abc", "def", "ghi"] assert longest_word(s, words)...
[ { "docstring": "Helper function to check if 'word' can be formed as a subsequence of 's'.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Given a string s and a list of words,\nreturns the longest w...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_longest_word(s, dictionary):\n def is_subsequence(word, s):\n it = iter(s)\n return all(c in it for c in word)\n \n longest_word = ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00007366", "row_id": 7366, "seed_ids": "[16505]" }
0.714788
Taco_7366
I
[ "is_subsequence", "longest_word" ]
2
[ [ "longest_word", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7d73db864b4ea08c12be75f73a33809fb98840e
03ea15973129a16ba036353ce1a7c961d1946671
v1.0
instruct
Taco
Taco_7369_I
#### Coding Assessment Question Chef loves to play with numbers, and he recently came across an interesting sequence problem. The problem involves generating a sequence from a given set of integers and determining specific sequence properties. The sequence in question is created as follows: 1. Given a list of integer...
def smallest_missing_integer(lst): i = 1 while True: if i not in lst: return i i += 1 def generate_sequence(initial_list, M): while len(initial_list) < M: missing = smallest_missing_integer(initial_list) initial_list.append(missing) return initial_list def s...
def test_smallest_missing_integer(): assert smallest_missing_integer([3, 1, 6]) == 2 assert smallest_missing_integer([1, 2, 3, 4, 5, 6, 7]) == 8 assert smallest_missing_integer([1, 3, 4, 5]) == 2 def test_generate_sequence(): assert generate_sequence([3, 1, 6], 8) == [3, 1, 6, 2, 4, 5, 7, 8] assert...
[ { "docstring": null, "function_declaration": "def smallest_missing_integer(lst):", "function_name": "smallest_missing_integer", "parameter_list": "(lst)" }, { "docstring": null, "function_declaration": "def generate_sequence(initial_list, M):", "function_name": "generate_sequence", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_missing_integer(seq):\n num_set = set(seq)\n smallest_int = 1\n while smallest_int in num_set:\n smallest_int += 1\n return smallest_in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007369", "row_id": 7369, "seed_ids": "[1583]" }
0.697495
Taco_7369
I
[ "smallest_missing_integer", "generate_sequence", "sum_of_first_n_integers", "solve_chef_problem" ]
4
[ [ "generate_sequence", "smallest_missing_integer" ], [ "solve_chef_problem", "generate_sequence" ], [ "solve_chef_problem", "sum_of_first_n_integers" ] ]
3
[]
false
[]
false
pytest
false
[]
true
beac272ec09d64db0b31777e9bb61d43ecabaa7a
fbcb24fd3a1a2a62a7e65affbeca3ad760ffa467
v1.0
instruct
Taco
Taco_7435_I
You are given an array of integers. Your task is to find the k-th smallest element in the array using the QuickSelect algorithm. The QuickSelect algorithm is a selection algorithm to find the k-th smallest element in an unordered list. It is related to the QuickSort sorting algorithm. -----Input----- The first line ...
def partition(arr, low, high): pivot = arr[high] i = low - 1 for j in range(low, high): if arr[j] <= pivot: i += 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high], arr[i + 1] return i + 1 def quickselect(arr, low, high, k): if low < hi...
def test_quickselect(): assert find_kth_smallest_element([3, 1, 2, 5, 4], 2) == 2 assert find_kth_smallest_element([7, 10, 4, 3, 20, 15, 12], 5) == 12 assert find_kth_smallest_element([7, 10, 4, 3, 20, 15], 6) == 20 assert find_kth_smallest_element([1], 1) == 1 assert find_kth_smallest_element([1, 2...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quickselect(arr, low, high, k):", "function_name": "quickselect", "parameter_list...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quickselect(arr, low, high, k):\n \"\"\"\n Helper function to perform the Quickselect algorithm.\n :param arr: List of integers.\n :param low: Lowe...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00007435", "row_id": 7435, "seed_ids": "[19989]" }
0.618703
Taco_7435
I
[ "partition", "quickselect", "find_kth_smallest_element" ]
3
[ [ "find_kth_smallest_element", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
e8e045e0037f1bef7432ea4585852f0f9803df4c
8cfb11e7c095002e8202ce34dc0ff21ba91c8679
v1.0
instruct
Taco
Taco_7603_I
Implement a function that, given a list of integers, finds the smallest subset of integers such that the sum of the subset is greater than or equal to a given number. If no such subset exists, return an empty list. Input The first line contains two integers n and k (0 ≤ n ≤ 100, 0 ≤ k ≤ 1000) – the number of elements...
def smallest_subset(nums, target): """ Finds the smallest subset of integers such that the sum of the subset is greater than or equal to the given target. """ nums.sort(reverse=True) current_sum, subset = 0, [] for num in nums: subset.append(num) current_sum += num if cu...
from solution import find_smallest_subset def test_find_smallest_subset_example1(): assert find_smallest_subset(5, 11, [1, 2, 3, 4, 5]) in [[5, 4, 2], [5, 4, 3], [5, 4, 1]] def test_find_smallest_subset_example2(): assert find_smallest_subset(3, 10, [4, 8, 3]) in [[8, 4]] def test_find_smallest_subset_exampl...
[ { "docstring": "Finds the smallest subset of integers such that the sum of the subset is greater than or equal to the given target.", "function_declaration": "def smallest_subset(nums, target):", "function_name": "smallest_subset", "parameter_list": "(nums, target)" }, { "docstring": null, ...
[ 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 smallest_subset(nums, target):\n \"\"\"\n Finds the smallest subset of integers such that the sum of the subset is greater than or equal to the given tar...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00007603", "row_id": 7603, "seed_ids": "[4840]" }
0.680616
Taco_7603
I
[ "smallest_subset", "find_smallest_subset" ]
2
[ [ "find_smallest_subset", "smallest_subset" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f6b48e77f028f43088915aa06be2978a2ee83da
8c53fab63cbec49e1060040cfa0b8f1aa892e4c9
v1.0
instruct
Taco
Taco_7657_I
A novel scientific research facility is being developed which includes a set of interconnected laboratories. Each lab is uniquely identified by an integer from 1 to n. In the beginning, the laboratories are not connected. As research requirements grow, m bi-directional corridors will be constructed between them, one a...
MOD = 1000000007 def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: ...
from solution import count_loops def test_count_loops_example_case(): n = 4 m = 4 corridors = [(1, 2), (2, 3), (3, 4), (4, 1)] assert count_loops(n, m, corridors) == [0, 0, 0, 1] def test_count_loops_single_lab(): n = 2 m = 1 corridors = [(1, 2)] assert count_loops(n, m, corridors) == ...
[ { "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, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 1000000007\n\ndef find(parent, i):\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, parent[i])\n return parent[i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00007657", "row_id": 7657, "seed_ids": "[17113]" }
0.644466
Taco_7657
I
[ "find", "union", "count_loops" ]
3
[ [ "count_loops", "find" ], [ "count_loops", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
86a24ece1e5d82c8083088f6fcf7194ef2464923
90b5f1f63e58361a3eaa7ebbeb1e92f76b966e9b
v1.0
instruct
Taco
Taco_7676_I
The town of Widgetville is planning to build a new network of roads to connect all the important locations such as homes, shops, and offices. The city planner wants to make sure that the roads are constructed in a manner that minimizes the total length of the roads, ensuring that every location is reachable from any ot...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] = xroot e...
def test_sample_input(): n = 5 m = 7 edge_list = [(1, 2, 1), (1, 3, 3), (3, 4, 4), (2, 4, 2), (2, 5, 5), (4, 5, 1), (3, 5, 6)] assert read_input_and_compute_mst(n, m, edge_list) == 7 def test_single_node(): n = 1 m = 0 edge_list = [] assert read_input_and_compute_mst(n, m, edge_list) ==...
[ { "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
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def find_parent(parent, i):\n if parent[i] == i:\n return i\n return find_parent(parent, parent[i])\n\ndef union(parent, rank...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007676", "row_id": 7676, "seed_ids": "[13465]" }
0.752648
Taco_7676
I
[ "find", "union", "kruskal_mst", "read_input_and_compute_mst" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "read_input_and_compute_mst", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
41766c462f95f632a966f90a0fdff5c21d4ad6cb
3531c6334705fab61c5b39ff66b7d8777f420d49
v1.0
instruct
Taco
Taco_7705_I
Write a function that takes a list of integers and returns a list containing only the prime numbers from the original list. Each element in the input list is an integer in the range from 2 to 1000 inclusive. Your function should implement an efficient algorithm to identify prime numbers. Example 1: Input: [2, 3, 4, 5...
import math def is_prime(n): """ Helper function to check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: re...
from solution import filter_primes def test_filter_primes_example1(): assert filter_primes([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] def test_filter_primes_example2(): assert filter_primes([11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == [11, 13, 17, 19, 23, 29, 31, 37, 41, 43] def test_filter_primes_example...
[ { "docstring": "Helper function to check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the original list.", "function_declaration":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00007705", "row_id": 7705, "seed_ids": "[4977]" }
0.687721
Taco_7705
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8ace3633c92f3b0daf34458ba788e10435f34c0
7108386d54d6b1fa1a20962a00ecb3247c1e9b2e
v1.0
instruct
Taco
Taco_7737_I
A company uses a binary tree to represent its organizational structure. Each node in the tree represents an employee, and each edge represents a direct reporting line. The root node represents the CEO. Given a binary tree with N nodes, where each node contains a unique integer employee ID, you are required to process ...
class TreeNode: def __init__(self, employee_id): self.id = employee_id self.left = None self.right = None def build_tree(edges): from collections import defaultdict nodes = {} children = set() for parent, child in edges: if parent not in nodes: ...
def test_lca(): edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6)] queries = [(1, 4, 5)] root, nodes = build_tree(edges) results = process_queries(root, nodes, queries) assert results == [2] def test_max_depth(): edges = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6)] queries = [(2, 1)] root, no...
[]
[ 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, id):\n self.id = id\n self.left = None\n self.right = None\n self.parent = None\n\ndef build_tr...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00007737", "row_id": 7737, "seed_ids": "[20850]" }
0.661134
Taco_7737
I
[ "build_tree", "find_lca", "max_depth", "count_nodes", "process_queries", "main" ]
6
[ [ "process_queries", "count_nodes" ], [ "process_queries", "find_lca" ], [ "process_queries", "max_depth" ] ]
3
[ "process_queries" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
29db62f2faa14b50185735068bbdbce59d70e425
0b2d16b4b8cfe3e592a3472a1291e6709dd3fa4b
v1.0
instruct
Taco
Taco_7758_I
In a distant galaxy, there are special droids that communicate using a unique string language. Each string consists of digits from 0 to 9. The droids have discovered that some strings are "equal-weighted" if the sum of the first half of the string equals the sum of the second half. You have been given several strings ...
def is_equal_weighted(s): n = len(s) first_half = s[:n//2] second_half = s[n//2:] return sum(map(int, first_half)) == sum(map(int, second_half)) def check_strings(t, strings): results = [] for s in strings: if is_equal_weighted(s): results.append("YES") else: ...
from solution import is_equal_weighted, check_strings def test_is_equal_weighted(): assert is_equal_weighted("123321") == True assert is_equal_weighted("456654") == True assert is_equal_weighted("112233") == False assert is_equal_weighted("111111") == True assert is_equal_weighted("123456") == Fals...
[ { "docstring": null, "function_declaration": "def is_equal_weighted(s):", "function_name": "is_equal_weighted", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def check_strings(t, strings):", "function_name": "check_strings", "parameter_list": "(t, strin...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_equal_weighted(s):\n \"\"\"\n Returns 'YES' if the sum of the first half of the string equals the sum of the second half,\n otherwise returns 'NO'....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007758", "row_id": 7758, "seed_ids": "[14313]" }
0.697805
Taco_7758
I
[ "is_equal_weighted", "check_strings" ]
2
[ [ "check_strings", "is_equal_weighted" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8dcaf9943cecd741bdc03bd7fb79d65e613df473
b57f491e81f52c68c076a2c94942e2930063a431
v1.0
instruct
Taco
Taco_7763_I
Consider an island with x villages (numbered 1 through x) and y roads connecting these villages. Each road connects exactly two different villages and may have different travel times. The rulers of the island want to pave additional roads to ensure that it is possible to travel between any two villages by road, either ...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[...
from solution import process_multiple_datasets def test_single_dataset(): datasets = [ (4, 2, [(1, 2, 8), (2, 3, 5)]), ] assert process_multiple_datasets(datasets) == [1] def test_single_dataset_no_additional_roads_needed(): datasets = [ (3, 3, [(1, 2, 7), (1, 3, 10), (2, 3, 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, 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_minimum_roads(x, y, roads):\n parent = list(range(x + 1))\n \n def find(v):\n if parent[v] != v:\n parent[v] = find(parent[v])\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007763", "row_id": 7763, "seed_ids": "[7557]" }
0.719289
Taco_7763
I
[ "find", "union", "min_additional_roads", "process_multiple_datasets" ]
4
[ [ "min_additional_roads", "find" ], [ "min_additional_roads", "union" ], [ "process_multiple_datasets", "min_additional_roads" ], [ "union", "find" ] ]
4
[ "process_multiple_datasets" ]
false
[]
false
pytest
true
[]
true
40bd3e53b7912a2d78ed3ef51ba5f3722610a3d4
9b415d2e87a70061edc0753c55de350aa988f5e4
v1.0
instruct
Taco
Taco_7769_I
A palindrome is a string that reads the same forward and backward. You are given a string \( s \) consisting of lowercase English letters. Find the number of pairs of indices \( (l, r) \) (1 ≤ l ≤ r ≤ |s|) such that the substring \( s[l, r] \) is a palindrome and \( r \) is the smallest index for this substring, among ...
def is_palindrome(s, l, r): """ Checks if the substring s[l:r+1] is a palindrome. """ while l < r: if s[l] != s[r]: return False l += 1 r -= 1 return True def count_palindromic_substrings(n, s): """ Returns the number of palindromic substrings where r is ...
from solution import is_palindrome, count_palindromic_substrings, process_test_cases def test_is_palindrome(): assert is_palindrome("ababa", 0, 4) == True assert is_palindrome("ababa", 1, 3) == True assert is_palindrome("ababa", 0, 1) == False def test_count_palindromic_substrings(): assert count_pali...
[ { "docstring": "Checks if the substring s[l:r+1] is a palindrome.", "function_declaration": "def is_palindrome(s, l, r):", "function_name": "is_palindrome", "parameter_list": "(s, l, r)" }, { "docstring": "Returns the number of palindromic substrings where r is the smallest index\nfor the gi...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_palindromic_substrings(t, test_cases):\n results = []\n \n def is_palindrome(s):\n return s == s[::-1]\n \n for i in range(t):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00007769", "row_id": 7769, "seed_ids": "[20261]" }
0.833996
Taco_7769
I
[ "is_palindrome", "count_palindromic_substrings", "process_test_cases" ]
3
[ [ "count_palindromic_substrings", "is_palindrome" ], [ "process_test_cases", "count_palindromic_substrings" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
db65b4958ed83eae154a6d09aae2d834755829b7
c03b8fc8844200345ec345ea267b18228535c82d
v1.0
instruct
Taco
Taco_7790_I
Imagine you are managing the inventory of a warehouse. The warehouse has a variety of items, each with a different stock count. You regularly receive restock requests, which specify the quantities to be restocked for certain items. The goal is to successfully process each restock request. If an item's stock count surpa...
def update_inventory(current_stocks, max_capacities, restock_requests): """ Updates the inventory based on the restock requests. Parameters: current_stocks (list): List of current stock amounts. max_capacities (list): List of maximum capacities for each item. restock_requests (list): List o...
from solution import update_inventory, process_restock_requests def test_update_inventory_basic(): assert update_inventory([10, 20, 15], [50, 25, 30], [(1, 10), (2, 5), (3, 20), (1, 40), (2, 7)]) == [50, 25, 30] def test_update_inventory_no_restock(): assert update_inventory([10, 20, 15], [50, 25, 30], []) ==...
[ { "docstring": "Updates the inventory based on the restock requests.\n\nParameters:\ncurrent_stocks (list): List of current stock amounts.\nmax_capacities (list): List of maximum capacities for each item.\nrestock_requests (list): List of restock requests, each being a tuple (index, quantity).\n\nReturns:\nlist...
[ 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 update_inventory(n, stock_counts, max_capacities, m, restock_requests):\n \"\"\"\n Updates the stock counts based on the restock requests without exceedi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007790", "row_id": 7790, "seed_ids": "[20544]" }
0.591976
Taco_7790
I
[ "update_inventory", "process_restock_requests" ]
2
[ [ "process_restock_requests", "update_inventory" ] ]
1
[]
false
[]
false
pytest
true
[]
true
51099c6bdf1911fc03b8fdecaee3759fcc9ecda7
0f60bca4a22a07ef1c0fcd50183b1ee2ecfdf15f
v1.0
instruct
Taco
Taco_7836_I
In a certain kingdom, cities are connected by bidirectional roads, such that there is exactly one path between any two cities. Each road has a certain travel-time associated with it, which varies greatly. The king, to improve trade efficiency, wants to open a maximum of k checkpoints in k different cities. These check...
import heapq from collections import defaultdict import numpy as np def dijkstra(graph, n, start): dist = [float('inf')] * n dist[start] = 0 pq = [(0, start)] while pq: curr_dist, u = heapq.heappop(pq) if curr_dist > dist[u]: continue for v, length in graph[u]: ...
from solution import min_max_travel_time def test_example_1(): n, k = 5, 2 roads = [ (1, 2, 4), (2, 3, 6), (3, 4, 8), (4, 5, 3), ] assert min_max_travel_time(n, k, roads) == 6 def test_single_city(): n, k = 1, 1 roads = [] assert min_max_travel_time(n, k, ro...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, n, start):", "function_name": "dijkstra", "parameter_list": "(graph, n, start)" }, { "docstring": null, "function_declaration": "def min_max_travel_time(n, k, roads):", "function_name": "min_max_travel_time", "para...
[ 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\nfrom collections import defaultdict\n\ndef min_max_travel_time(n, k, roads):\n if k >= n:\n return 0\n \n def bfs(start, distance):\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00007836", "row_id": 7836, "seed_ids": "[18035]" }
0.747207
Taco_7836
I
[ "dijkstra", "min_max_travel_time" ]
2
[ [ "min_max_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
fce8b4166eabe6621dfedd3295e3ede0c1800edd
ad7cd7c7a9ab69b38deab15ad162f3d141946b15
v1.0
instruct
Taco
Taco_7922_I
Write a program that prints the Fibonacci sequence up to the Nth term. The Fibonacci sequence is a series of numbers where the next term is the sum of the previous two terms. It starts with 0 and 1. Input A single integer N, where 1 <= N <= 50. Output The first N terms of the Fibonacci sequence, separated by spaces...
def fibonacci(n): """ Returns the first n terms of the Fibonacci sequence. """ if n == 1: return [0] elif n == 2: return [0, 1] sequence = [0, 1] for i in range(2, n): sequence.append(sequence[-1] + sequence[-2]) return sequence # For direct output def print...
from solution import fibonacci, print_fibonacci import pytest def test_fibonacci_single_term(): assert fibonacci(1) == [0] def test_fibonacci_two_terms(): assert fibonacci(2) == [0, 1] def test_fibonacci_ten_terms(): assert fibonacci(10) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] def test_fibonacci_max_terms(...
[ { "docstring": "Returns the first n terms of the Fibonacci sequence.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def print_fibonacci(n):", "function_name": "print_fibonacci", ...
[ 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 fibonacci_sequence(n):\n \"\"\"\n Returns the first N terms of the Fibonacci sequence.\n \n Args:\n n (int): Number of terms in the Fibonacci se...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007922", "row_id": 7922, "seed_ids": "[10362]" }
0.757631
Taco_7922
I
[ "fibonacci", "print_fibonacci" ]
2
[ [ "print_fibonacci", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ba1ee3afa21a90d9aef76fb23a079af12a0c991
00e74572e79c517cfc2d83319f233d031702fc87
v1.0
instruct
Taco
Taco_7969_I
In a city, there are N intersections, conveniently numbered 1 through N. Each intersection is connected by roads, and there are M roads in total. Each road connects two intersections and has a certain length. The roads are bidirectional. Your task is to find the shortest path from the first intersection (numbered 1) t...
import heapq from collections import defaultdict import sys def shortest_path(N, M, roads): graph = defaultdict(list) for u, v, l in roads: graph[u].append((v, l)) graph[v].append((u, l)) # Dijkstra's algorithm queue = [(0, 1)] # (distance, node) distances = {i: float('inf') f...
import pytest from solution import find_shortest_path_from_input def test_find_shortest_path_sample(): input_data = '''5 6 1 2 2 1 3 4 2 3 1 2 4 7 3 5 3 4 5 1''' assert find_shortest_path_from_input(input_data) == 6 def test_no_path(): input_data = '''5 3 1 2 2 2 3 1 4 5 3''' assert find_shortest_path...
[ { "docstring": null, "function_declaration": "def shortest_path(N, M, roads):", "function_name": "shortest_path", "parameter_list": "(N, M, roads)" }, { "docstring": null, "function_declaration": "def find_shortest_path_from_input(input_data):", "function_name": "find_shortest_path_f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_path(N, M, roads):\n # Create to store graph as adjacency list\n graph = [[] for _ in range(N + 1)]\n for u, v, l in roads:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00007969", "row_id": 7969, "seed_ids": "[17391]" }
0.791189
Taco_7969
I
[ "shortest_path", "find_shortest_path_from_input" ]
2
[ [ "find_shortest_path_from_input", "shortest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
72eeab79705cb05b1756c1c650f74d52c5b9a679
3bfd1b10245a601a80746e6f79806a178f176038
v1.0
instruct
Taco
Taco_8028_I
In a certain city, there are n intersections and m bidirectional roads connecting them. Each road has a specific travel time associated with it. A traveler wishes to visit k specific intersections and must find the shortest travel time required to visit all these intersections starting from a given starting intersectio...
import heapq from collections import defaultdict import sys def dijkstra(edges, start, n): dist = [float('inf')] * (n + 1) dist[start] = 0 pq = [(0, start)] while pq: current_dist, u = heapq.heappop(pq) if current_dist > dist[u]: continue for v, weight in edges[u]...
from solution import minimum_travel_time def test_example(): n = 5 m = 6 k = 3 s = 1 required_intersections = [2, 3, 5] roads = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 2) ] assert minimum_travel_time(n, m, k, s, req...
[ { "docstring": null, "function_declaration": "def dijkstra(edges, start, n):", "function_name": "dijkstra", "parameter_list": "(edges, start, n)" }, { "docstring": null, "function_declaration": "def minimum_travel_time(n, m, k, s, required_intersections, roads):", "function_name": "m...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n \"\"\"\n Dijkstra's algorithm to find the shortest path from start node to all other nodes\n \"\"\"\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00008028", "row_id": 8028, "seed_ids": "[4209]" }
0.742773
Taco_8028
I
[ "dijkstra", "minimum_travel_time" ]
2
[ [ "minimum_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a2a5007c433fe1dc200b8b2f6f28e3fb561c39d6
cc7c1485acd4f12e1ec84c5a674e53bc8541318b
v1.0
instruct
Taco
Taco_8061_I
You are given two numbers, X and Y. Your task is to determine if the number of divisors of X is greater than the number of divisors of Y. -----Input----- The input contains two integers X and Y. -----Output----- Print "X" if X has more divisors than Y. Print "Y" if Y has more divisors than X. If both numbers have t...
def count_divisors(n): """ Returns the number of divisors of n. """ count = 0 for i in range(1, n + 1): if n % i == 0: count += 1 return count def compare_divisors(X, Y): """ Compares the number of divisors of X and Y. Returns "X" if X has more divisors, "Y" if Y...
from solution import compare_divisors def test_compare_divisors_case1(): assert compare_divisors(8, 12) == "Y" def test_compare_divisors_case2(): assert compare_divisors(12, 8) == "X" def test_compare_divisors_case3(): assert compare_divisors(6, 28) == "Y" def test_compare_divisors_case4(): assert c...
[ { "docstring": "Returns the number of divisors of n.", "function_declaration": "def count_divisors(n):", "function_name": "count_divisors", "parameter_list": "(n)" }, { "docstring": "Compares the number of divisors of X and Y.\nReturns \"X\" if X has more divisors, \"Y\" if Y has more diviso...
[ 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 count_divisors(n):\n \"\"\"\n Returns the number of divisors of n.\n \"\"\"\n count = 0\n for i in range(1, n + 1):\n if n % i == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00008061", "row_id": 8061, "seed_ids": "[3543]" }
0.709736
Taco_8061
I
[ "count_divisors", "compare_divisors" ]
2
[ [ "compare_divisors", "count_divisors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0b8a41e1ffd953cda9e62d94d2c0deab63942cf
9c3a8f3efaff64bda01899e1651876aa1b0d2eba
v1.0
instruct
Taco
Taco_8067_I
Given a sequence of positive integers, construct a binary search tree (BST) by inserting the integers in the given order. Then, compute and output the height of the BST. The height of a BST is the length of the path from the root to the deepest node in the tree. Input A single line containing a comma-separated sequen...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.value = key def insert(root, key): if root is None: return TreeNode(key) else: if root.value < key: root.right = insert(root.right, key) else: root.left =...
from solution import construct_bst_and_compute_height def test_construct_bst_and_compute_height_example(): assert construct_bst_and_compute_height("10,5,15,3,7,13,17,2,4,6,8") == 3 def test_construct_bst_and_compute_height_single_element(): assert construct_bst_and_compute_height("10") == 0 def test_construc...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef insert_into_bst(root, value...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008067", "row_id": 8067, "seed_ids": "[19528]" }
0.546067
Taco_8067
I
[ "insert", "height", "construct_bst_and_compute_height" ]
3
[ [ "construct_bst_and_compute_height", "height" ], [ "construct_bst_and_compute_height", "insert" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
e4be989da3809ccea7ef14107e898cd593aba0c2
06f498f748ccd5c7dd6c54608e19f88adfb32224
v1.0
instruct
Taco
Taco_8228_I
Imagine you are designing a basic router that routes data packets in a network. You need to simulate the routing of packets through a series of routers. Each router forwards the packet to the next router in the path based on a set of forwarding rules. The network is represented as a graph where routers are nodes and c...
def find_path(N, M, connections, forwarding_tables, S, D): from collections import deque # Build the network graph graph = {i: [] for i in range(N)} for u, v in connections: graph[u].append(v) graph[v].append(u) # Assume bidirectional links # Perform BFS to find the path queue...
def test_example_case(): N = 5 M = 6 connections = [(0, 1), (0, 2), (1, 3), (2, 3), (3, 4), (2, 4)] forwarding_data = [ (3, 0, 1, 1, 2, 2, 1), (3, 0, 1, 4, 4, 1, 2), (2, 2, 3, 4, 4), (2, 4, 4, 3, 3), (2, 4, 4, 3, 3), ] S, D = 0, 4 assert simulate_routi...
[ { "docstring": null, "function_declaration": "def find_path(N, M, connections, forwarding_tables, S, D):", "function_name": "find_path", "parameter_list": "(N, M, connections, forwarding_tables, S, D)" }, { "docstring": null, "function_declaration": "def simulate_routing(N, M, connection...
[ 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 router_path(N, M, connections, forwarding_tables, S, D):\n \"\"\"\n Determines the path a packet takes in the network from source router S to destination...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00008228", "row_id": 8228, "seed_ids": "[3913]" }
0.607495
Taco_8228
I
[ "find_path", "simulate_routing" ]
2
[ [ "simulate_routing", "find_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c880088a321f5d463b4252e3621296921cfe123d
574e780fcf298e431e826699439e0e6882ea05e5
v1.0
instruct
Taco
Taco_8256_I
A professional treasure hunter has discovered a room full of artifacts. Each artifact has a weight and a value associated with it. However, the room has a maximum weight capacity that cannot be exceeded. The treasure hunter wants to collect artifacts in a way that maximizes the total value, while not exceeding the weig...
def max_artifact_value(n, W, items): """ Given the number of artifacts n, the max weight capacity W, and a list of artifacts (each represented as a tuple (weight, value)), this function calculates the maximum value that can be collected without exceeding the weight capacity using dynamic programming. ...
from solution import max_artifact_value, read_input_and_solve def test_example1(): input_data = "4 7\n1 1\n3 4\n4 5\n5 7" assert read_input_and_solve(input_data) == 9 def test_example2(): input_data = "3 50\n10 60\n20 100\n30 120" assert read_input_and_solve(input_data) == 220 def test_single_item():...
[ { "docstring": "Given the number of artifacts n, the max weight capacity W, and a list of artifacts \n(each represented as a tuple (weight, value)), this function calculates the maximum\nvalue that can be collected without exceeding the weight capacity using dynamic programming.", "function_declaration": "d...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_artifact_value(n, W, artifacts):\n # Initialize the DP array with 0\n dp = [0] * (W + 1)\n\n # Process each artifact\n for weight, value in art...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00008256", "row_id": 8256, "seed_ids": "[1217]" }
0.692189
Taco_8256
I
[ "max_artifact_value", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "max_artifact_value" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d9c109ace7ea1679328bb7553617f022ff32885c
cb7e292c999e8d25256b2f7dbb091e212f9c0085
v1.0
instruct
Taco
Taco_8283_I
Develop a program to help a delivery company calculate the most optimal delivery path for their trucks based on a given graph of cities where the nodes represent cities and the edges represent the direct routes between the cities with their respective travel times. The goal is to minimize the total travel time for the ...
def tsp(graph): from itertools import permutations N = len(graph) min_path_cost = float('inf') # Check all permutations of cities excluding the starting city cities = list(range(1, N)) for perm in permutations(cities): current_cost = 0 k = 0 possible = True...
import pytest from solution import tsp, read_input, solve def test_tsp_example_1(): graph = [ [0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0] ] assert tsp(graph) == 80 def test_tsp_example_2(): graph = [ [0, -1, 3], [-1, 0, 1], ...
[ { "docstring": null, "function_declaration": "def tsp(graph):", "function_name": "tsp", "parameter_list": "(graph)" }, { "docstring": null, "function_declaration": "def read_input(input_data):", "function_name": "read_input", "parameter_list": "(input_data)" }, { "docstri...
[ 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": "from itertools import permutations\n\ndef tsp(graph):\n N = len(graph)\n min_path_cost = float('inf')\n\n # Generate all permutations of cities except the...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00008283", "row_id": 8283, "seed_ids": "[4878]" }
0.780362
Taco_8283
I
[ "tsp", "read_input", "solve" ]
3
[ [ "read_input", "tsp" ], [ "solve", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
true
[]
true
8e9fb21c1becbbc7dbc56672c3a03d865853c3b7
2e719b2e7e3b3832ce8ff9f30176f4dc1b75e7f5
v1.0
instruct
Taco
Taco_8286_I
You are given an array of N integers. Your task is to find the length of the longest subsequence such that the difference between consecutive elements is a constant value. Write a function to find this length. ### Input: - The first line contains an integer T denoting the number of test cases. - For each test case: ...
def find_longest_subsequence(arr): """ Function to find the length of the longest subsequence such that the difference between consecutive elements is a constant value. """ if not arr: return 0 n = len(arr) if n == 1: return 1 dp = [{} for _ in range(n)] max...
import pytest from solution import find_longest_subsequence def test_longest_subsequence_case_1(): assert find_longest_subsequence([3, 6, 9, 12, 15, 18, 21]) == 7 def test_longest_subsequence_case_2(): assert find_longest_subsequence([5, 1, 5, 9, 13, 17]) == 5 def test_no_sequence(): assert find_longest...
[ { "docstring": "Function to find the length of the longest subsequence such that the\ndifference between consecutive elements is a constant value.", "function_declaration": "def find_longest_subsequence(arr):", "function_name": "find_longest_subsequence", "parameter_list": "(arr)" }, { "docs...
[ 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 longest_arith_seq_len(nums):\n if len(nums) == 0:\n return 0\n \n dp = [{} for _ in range(len(nums))]\n max_len = 1\n \n for i in rang...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008286", "row_id": 8286, "seed_ids": "[8229]" }
0.901674
Taco_8286
I
[ "find_longest_subsequence", "longest_subsequence_length", "parse_input_output", "main" ]
4
[ [ "longest_subsequence_length", "find_longest_subsequence" ] ]
1
[ "parse_input_output" ]
false
[]
false
pytest
true
[]
true
dc50025a3e43c6d293fd60525a9f4f359f972ae0
8040cba74c0cda2d78ea5bad6e5be898d48c802d
v1.0
instruct
Taco
Taco_8317_I
Alice loves to create unique patterns using strings of characters. She is working on a new pattern that involves a string consisting of uppercase letters. The pattern is created by rotating the string several times. Each rotation involves taking the first character of the string and moving it to the end. For example, i...
def is_palindrome(s): return s == s[::-1] def rotation_is_palindrome(s): for i in range(len(s)): if is_palindrome(s): return "YES" s = s[1:] + s[0] return "NO"
from solution import rotation_is_palindrome def test_rotation_is_palindrome_no_potential(): assert rotation_is_palindrome("AABC") == "NO" def test_rotation_is_palindrome_direct_palindrome(): assert rotation_is_palindrome("ABCCBA") == "YES" def test_rotation_is_palindrome_single_char(): assert rotation_is...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def rotation_is_palindrome(s):", "function_name": "rotation_is_palindrome", "parameter_list": "(s)" }...
[ 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_palindrome(s):\n return s == s[::-1]\n\ndef rotate_string(s):\n return s[1:] + s[0]\n\ndef has_palindromic_rotation(s):\n for _ in range(len(s)):\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00008317", "row_id": 8317, "seed_ids": "[9806]" }
0.744508
Taco_8317
I
[ "is_palindrome", "rotation_is_palindrome" ]
2
[ [ "rotation_is_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
497cc336e56f0a7bc3ca301d8a439f91fbd6ace1
70a2eed779d42867313f020d2d1bf869057a7794
v1.0
instruct
Taco
Taco_8360_I
A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A super prime number is a prime number that occupies a prime-numbered position in the sequence of all prime numbers, as defined by their natural occurrence. For example, the sequence of all prime numbers...
def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def generate_primes_up_to(n): primes = [] candidate = 2 while len(primes) < n: if is_prime(candidate): primes.append(candid...
from solution import super_primes def test_super_primes_single(): assert super_primes(1) == [3] def test_super_primes_two(): assert super_primes(2) == [3, 5] def test_super_primes_five(): assert super_primes(5) == [3, 5, 11, 17, 31] def test_super_primes_ten(): assert super_primes(10) == [3, 5, 11, ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def generate_primes_up_to(n):", "function_name": "generate_primes_up_to", "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": "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_3
{ "original_instruction": "", "prompt_id": "00008360", "row_id": 8360, "seed_ids": "[19069]" }
0.630849
Taco_8360
I
[ "is_prime", "generate_primes_up_to", "super_primes" ]
3
[ [ "generate_primes_up_to", "is_prime" ], [ "super_primes", "generate_primes_up_to" ], [ "super_primes", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
3c9d12d33ce4f29630d013f0d07fd5fe4d344323
546b2d5af3c37cb9047f2e49b8ee2e44c5d498b7
v1.0
instruct
Taco
Taco_8363_I
Given an integer N, print all prime numbers less than or equal to N. A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself. -----Constraints----- - 1 \leq N \leq 10^6 - All values in input are integers. -----Input----- Input is given from the Standard Inpu...
def sieve_of_eratosthenes(N): """ Returns a list of all prime numbers less than or equal to N. """ if N < 2: return [] prime = [True for i in range(N + 1)] p = 2 while p * p <= N: if prime[p]: for i in range(p * p, N + 1, p): prime[i] = False ...
from solution import sieve_of_eratosthenes, print_primes_up_to import io import sys def test_sieve_basic(): assert sieve_of_eratosthenes(1) == [] assert sieve_of_eratosthenes(2) == [2] assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] def test_sieve_larger(): assert sieve_of_eratosthenes(30) == [2, 3, ...
[ { "docstring": "Returns a list of all prime numbers less than or equal to N.", "function_declaration": "def sieve_of_eratosthenes(N):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(N)" }, { "docstring": null, "function_declaration": "def print_primes_up_to(N):", "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 find_primes(N):\n \"\"\"\n Returns a list of all prime numbers less than or equal to N.\n \"\"\"\n if N < 2:\n return []\n sieve = [True]...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00008363", "row_id": 8363, "seed_ids": "[10777]" }
0.689238
Taco_8363
I
[ "sieve_of_eratosthenes", "print_primes_up_to" ]
2
[ [ "print_primes_up_to", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2eb5aa5ea2fa68b76d6ee492245abf30baed8f75
19b535c36dbfd5b2d22ba35433537655f257e52e
v1.0
instruct
Taco
Taco_8419_I
Given an integer array, find the average of all the prime numbers present in the array. If there are no prime numbers in the array, return -1. -----Input----- - The first line of the input contains an integer T denoting the number of test cases. Then T test cases follow. - Each test case is described with two lines: ...
import math def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True def average_of_primes(arr): primes = [x for x in arr if is_pr...
from solution import is_prime, average_of_primes, process_test_cases def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(1000003) == True d...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def average_of_primes(arr):", "function_name": "average_of_primes", "parameter_list": "(arr)" }, { "docst...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return False\n for i in range(3...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00008419", "row_id": 8419, "seed_ids": "[16395]" }
0.660135
Taco_8419
I
[ "is_prime", "average_of_primes", "process_test_cases" ]
3
[ [ "average_of_primes", "is_prime" ], [ "process_test_cases", "average_of_primes" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
26367fa45fa9829d6fa58700f02388ebb12290c3
491f1d9c81099509653bc2423db24e85e28f718b
v1.0
instruct
Taco
Taco_8470_I
Problem In a distant kingdom, there are N fortresses connected by M bidirectional highways. The kingdom's king recently decreed that all fortresses must be directly managed by the kingdom's officials. Each official is assigned to a fortress and has two limits on their duties: they can only manage up to D fortresses an...
from collections import deque def bfs_shortest_paths(graph, start, max_distance): distances = {} queue = deque([(start, 0)]) while queue: current_node, current_distance = queue.popleft() if current_node not in distances: distances[current_node] = current_distance if ...
def test_min_officials_needed_case1(): input_data = '''5 6 3 2 1 2 1 3 2 4 2 5 3 4 3 5 2 1 2 0 0 0 0 ''' expected_output = [2] assert parse_input(input_data) == expected_output def test_min_officials_needed_case2(): input_data = '''7 10 4 3 1 2 1 3 2 4 2 5 3 6 3 7 4 5 5 6 6 7 7 1 3 1 4 7 0 0 0 0 ''' ...
[ { "docstring": null, "function_declaration": "def bfs_shortest_paths(graph, start, max_distance):", "function_name": "bfs_shortest_paths", "parameter_list": "(graph, start, max_distance)" }, { "docstring": null, "function_declaration": "def min_officials_needed(N, M, D, K, highways, init...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs_shortest_paths(graph, start, max_distance):\n distances = {}\n queue = deque([(start, 0)])\n while queue:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00008470", "row_id": 8470, "seed_ids": "[8030]" }
0.681493
Taco_8470
I
[ "bfs_shortest_paths", "min_officials_needed", "parse_input", "main" ]
4
[ [ "min_officials_needed", "bfs_shortest_paths" ], [ "parse_input", "min_officials_needed" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
29572e1b3bfce7b5f451dbe64f1d256c9d84faae
687a28a1afe8c7673300b732e8f162b6678a9b0d
v1.0
instruct
Taco
Taco_8472_I
Given a list of non-negative integers, your task is to find the smallest number that can be formed by concatenating the numbers together. Example 1: Input: nums = [3, 30, 34, 5, 9] Output: "3033459" Explanation: By arranging the numbers in such a way, the smallest concatenated number is formed. Example 2: Input: num...
from functools import cmp_to_key def compare(a, b): if a + b < b + a: return -1 elif a + b > b + a: return 1 else: return 0 def smallestConcatenatedNumber(nums): """ Returns the smallest number that can be formed by concatenating the numbers together. """ # Conver...
from solution import smallestConcatenatedNumber def test_example_1(): assert smallestConcatenatedNumber([3, 30, 34, 5, 9]) == "3033459" def test_example_2(): assert smallestConcatenatedNumber([20, 1, 34, 3, 9]) == "1203349" def test_all_zeros(): assert smallestConcatenatedNumber([0, 0, 0, 0]) == "0" def...
[ { "docstring": null, "function_declaration": "def compare(a, b):", "function_name": "compare", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest number that can be formed by concatenating the numbers together.", "function_declaration": "def smallestConcatenatedNumber(num...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(a, b):\n \"\"\"\n Comparator function to sort numbers in such a way that \n the concatenation of numbers f...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00008472", "row_id": 8472, "seed_ids": "[12569]" }
0.646846
Taco_8472
I
[ "compare", "smallestConcatenatedNumber" ]
2
[ [ "smallestConcatenatedNumber", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62789ce8037384352f28ab0132e98b4c725dc608
45e0cfc1b00c4a5dd0cfa7fe2ad2a3cd77c39cc3
v1.0
instruct
Taco
Taco_8575_I
You are given a matrix representing a maze consisting of $n$ rows and $m$ columns. The maze contains obstacles ('#'), open paths ('.'), a start point ('S'), and an end point ('E'). Your goal is to determine whether there is a path from the start point to the end point. You can only move up, down, left, or right, and ca...
def can_reach_end(matrix, start, end, n, m): from collections import deque # Directions for moving up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # BFS setup queue = deque([start]) visited = set() visited.add(start) while queue: current = que...
import pytest from solution import solve def test_example_cases(): assert solve(3, [((4, 4), ["S...", ".##.", ".#..", "...E"]), ((4, 4), ["S.#.", ".##.", ".#..", "#..E"]), ((3, 3), ["S#E", "###", "###"])]) == ['YES', 'NO', 'NO'] def test_no_path(): assert solve(1, [((...
[ { "docstring": null, "function_declaration": "def can_reach_end(matrix, start, end, n, m):", "function_name": "can_reach_end", "parameter_list": "(matrix, start, end, n, m)" }, { "docstring": null, "function_declaration": "def solve(t, test_cases):", "function_name": "solve", "pa...
[ 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_path_possible(mazes):\n def valid_position(x, y, n, m):\n return 0 <= x < n and 0 <= y < m\n \n def bfs(start, end, maze):\n from col...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008575", "row_id": 8575, "seed_ids": "[3636]" }
0.671915
Taco_8575
I
[ "can_reach_end", "solve" ]
2
[ [ "solve", "can_reach_end" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f334ad34c1d50cdc13edced5929c3b9b56a68b0
e550d8629586d0a2d932f77cb496687740a1e8be
v1.0
instruct
Taco
Taco_8597_I
A string is said to be a valid palindrome if it reads the same backward as forward, after converting all uppercase letters into lowercase letters and ignoring all non-alphanumeric characters. Write a function to determine if a given string is a valid palindrome. ------ Input ------ The input consists of a single line...
def is_valid_palindrome(s): """ Determines if the given string s is a valid palindrome by ignoring non-alphanumeric characters and case differences. """ # Remove non-alphanumeric characters and convert to lowercase filtered_s = ''.join([char.lower() for char in s if char.isalnum()]) # Check ...
from solution import is_valid_palindrome, solve import subprocess def test_is_valid_palindrome(): assert is_valid_palindrome("A man, a plan, a canal: Panama") == True assert is_valid_palindrome("race a car") == False assert is_valid_palindrome("") == True assert is_valid_palindrome(" ") == True ass...
[ { "docstring": "Determines if the given string s is a valid palindrome by ignoring non-alphanumeric characters\nand case differences.", "function_declaration": "def is_valid_palindrome(s):", "function_name": "is_valid_palindrome", "parameter_list": "(s)" }, { "docstring": "Solves the problem...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_palindrome(s):\n \"\"\"\n Returns \"YES\" if the given string is a valid palindrome, otherwise returns \"NO\".\n A string is considered a val...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008597", "row_id": 8597, "seed_ids": "[3359]" }
0.804048
Taco_8597
I
[ "is_valid_palindrome", "solve" ]
2
[ [ "solve", "is_valid_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4065f4537e44bb0768aa41259f4151c72918188
3fb2c28bfdd19ebf14b47d5261ee4f2e30b62634
v1.0
instruct
Taco
Taco_8629_I
Given an array of integers, determine if the array can be rearranged to form an arithmetic sequence. An arithmetic sequence is a sequence of numbers in which the difference between consecutive terms is constant. Constraints: - The number of elements in the array, \( N \), is an integer such that \( 1 \leq N \leq 10^...
def can_form_arithmetic_sequence(arr): """ Check if the given array can be rearranged to form an arithmetic sequence. """ if len(arr) <= 1: return True arr.sort() difference = arr[1] - arr[0] for i in range(2, len(arr)): if arr[i] - arr[i - 1] != difference: ...
def test_single_element(): assert check_arithmetic_sequence(1, [1]) == "YES" def test_two_elements(): assert check_arithmetic_sequence(2, [5, 10]) == "YES" assert check_arithmetic_sequence(2, [10, 5]) == "YES" def test_already_sorted_arithmetic_sequence(): assert check_arithmetic_sequence(5, [1, 3, 5,...
[ { "docstring": "Check if the given array can be rearranged to form an arithmetic sequence.", "function_declaration": "def can_form_arithmetic_sequence(arr):", "function_name": "can_form_arithmetic_sequence", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def c...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_arithmetic_sequence(arr):\n \"\"\"\n Determine if the array can be rearranged to form an arithmetic sequence.\n \"\"\"\n if len(arr) <= 1:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008629", "row_id": 8629, "seed_ids": "[21786]" }
0.709609
Taco_8629
I
[ "can_form_arithmetic_sequence", "check_arithmetic_sequence" ]
2
[ [ "check_arithmetic_sequence", "can_form_arithmetic_sequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5187fc5b07995e74b25f22ac29cf2a939405366c
66a752c95f967f1f3a5b707cb5a71ae3dbfaa9dd
v1.0
instruct
Taco
Taco_8661_I
The Traveling Salesman Problem (TSP) is a classic algorithmic problem in the fields of operations research and computer science. Given a list of cities and the distances between each pair of cities, the task is to find the shortest possible route that visits each city exactly once and returns to the origin city. Consi...
from itertools import permutations def calculate_tsp(N, D): """ Calculate the shortest possible route for the Traveling Salesman Problem with a limited number of cities using permutations. """ cities = range(N) min_route_length = float('inf') # Generate all permutations of city visits...
def test_tsp_example_1(): input_str = '''4 0 10 15 20 10 0 35 25 15 35 0 30 20 25 30 0''' assert read_input_and_solve(input_str) == 80 def test_tsp_example_2(): input_str = '''3 0 29 20 29 0 15 20 15 0''' assert read_input_and_solve(input_str) == 64 def test_tsp_min_2_cities(): input_str = '''2 0 ...
[ { "docstring": "Calculate the shortest possible route for the Traveling Salesman Problem \nwith a limited number of cities using permutations.", "function_declaration": "def calculate_tsp(N, D):", "function_name": "calculate_tsp", "parameter_list": "(N, D)" }, { "docstring": null, "funct...
[ 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 itertools import permutations\n\ndef calculate_tsp(N, D):\n \"\"\"\n Calculate the shortest possible route for the Traveling Salesman Problem \n with...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00008661", "row_id": 8661, "seed_ids": "[14505]" }
0.624019
Taco_8661
I
[ "calculate_tsp", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "calculate_tsp" ] ]
1
[]
false
[]
false
pytest
false
[]
true
57f8e9b2ad7c7f964f2b99b53cc2eea39a27298b
275154950797f441597b7d207187620a924bfd6b
v1.0
instruct
Taco
Taco_8691_I
Bob has just learned about prime numbers and palindrome numbers in his computer science class. He is now tasked with solving a problem that combines both concepts. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A palindrome number is a number that re...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import is_prime, is_palindrome, palindrome_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_is_palindrome(): assert is_palindrome(121) == True assert ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Checks if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindr...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\" Returns True if n is a prime number, else False. \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00008691", "row_id": 8691, "seed_ids": "[8956]" }
0.713919
Taco_8691
I
[ "is_prime", "is_palindrome", "palindrome_prime" ]
3
[ [ "palindrome_prime", "is_palindrome" ], [ "palindrome_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9936f0fe82d65d2d66315737e900fed9605b4a02
99722d96f5f42e39e321971748b1cc8f96172472
v1.0
instruct
Taco
Taco_8796_I
The Kingdom of Magicland is controlled by a powerful wizard who maintains order by using magical seals. One day, he decided to conduct an experiment to test the abilities of his apprentices. He wants to know how many distinct ways they can arrange a series of magical seals represented by a string of lowercase English l...
import math from collections import Counter MOD = 10**9 + 7 def factorial_mod(n, mod=MOD): result = 1 for i in range(2, n + 1): result = result * i % mod return result def distinct_permutations(s): count = Counter(s) denominator = 1 for freq in count.values(): denominator = (d...
def test_distinct_permutations_aab(): assert distinct_permutations("aab") == 3 def test_distinct_permutations_abc(): assert distinct_permutations("abc") == 6 def test_distinct_permutations_single_char(): assert distinct_permutations("a") == 1 def test_distinct_permutations_repeated_chars(): assert di...
[ { "docstring": null, "function_declaration": "def factorial_mod(n, mod=MOD):", "function_name": "factorial_mod", "parameter_list": "(n, mod=MOD)" }, { "docstring": null, "function_declaration": "def distinct_permutations(s):", "function_name": "distinct_permutations", "parameter_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom collections import Counter\n\nMOD = 10**9 + 7\n\ndef factorial(n):\n if n == 0 or n == 1:\n return 1\n return n * factorial(n - 1) %...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008796", "row_id": 8796, "seed_ids": "[2178]" }
0.6727
Taco_8796
I
[ "factorial_mod", "distinct_permutations", "number_of_distinct_permutations" ]
3
[ [ "distinct_permutations", "factorial_mod" ], [ "number_of_distinct_permutations", "distinct_permutations" ] ]
2
[]
false
[]
false
pytest
false
[]
true
9ed6c4e71371ac23ee115dd257d21887d3e2fbca
920eac1bff0fc0cb701fdf7ae1f5a1a5d5477288
v1.0
instruct
Taco
Taco_8846_I
Professor Snape is brewing a magical potion and needs exactly $M$ milliliters of a special ingredient. He has several bottles, each containing a different amount of the special ingredient. However, he noticed that some bottles might be enchanted, reducing the content by a fixed percentage after taking the ingredient fr...
def calculate_effective_capacity(C, P): """ Returns the effective capacity of the bottle after reduction. C: Original capacity of the bottle P: Percentage reduction """ return C * (100 - P) / 100 def is_possible_to_measure(M, capacities): """ Determines if it's possible to measure exact...
from solution import solve def test_example_cases(): # Sample input T = 2 test_cases = [ ((3, 50), [(100, 50), (100, 0), (100, 25)]), ((2, 75), [(100, 50), (100, 50)]) ] # Expected output expected_output = ["Yes", "No"] # Test assert solve(T, test_cases) == exp...
[ { "docstring": "Returns the effective capacity of the bottle after reduction.\nC: Original capacity of the bottle\nP: Percentage reduction", "function_declaration": "def calculate_effective_capacity(C, P):", "function_name": "calculate_effective_capacity", "parameter_list": "(C, P)" }, { "do...
[ 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": "# Function to calculate the effective volume after percentage reduction\ndef effective_volume(C, P):\n return C * (1 - P / 100)\n\n# Function to check if we can...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008846", "row_id": 8846, "seed_ids": "[7030]" }
0.701827
Taco_8846
I
[ "calculate_effective_capacity", "is_possible_to_measure", "can_measure_special_ingredient", "solve" ]
4
[ [ "can_measure_special_ingredient", "calculate_effective_capacity" ], [ "can_measure_special_ingredient", "is_possible_to_measure" ], [ "solve", "can_measure_special_ingredient" ] ]
3
[]
false
[]
false
pytest
true
[]
true
faf98065c0449a1385bd98dbbc408754e7354fc2
d82b084509b97f0c6639b6687e15f23c242156d6
v1.0
instruct
Taco
Taco_8928_I
You are given an integer array `arr` of size `n`. Your task is to divide the array into exactly `k` subarrays such that the largest sum of any subarray is minimized. Write a program to determine the minimized largest sum among these k subarrays. ### Input The input consists of: - The first line contains two integers `...
def can_split(arr, n, k, max_sum): """ Determines if it is possible to split the array into k or fewer subarrays such that the maximum subarray sum does not exceed max_sum. """ current_sum = 0 required_splits = 1 for num in arr: if current_sum + num > max_sum: required_s...
def test_example_case(): assert minimize_largest_sum([7, 2, 5, 10, 8, 1, 3], 7, 3) == 14 def test_single_element(): assert minimize_largest_sum([10], 1, 1) == 10 def test_equal_k_n(): assert minimize_largest_sum([1, 2, 3, 4, 5], 5, 5) == 5 def test_k_equal_to_1(): assert minimize_largest_sum([1, 2, 3...
[ { "docstring": "Determines if it is possible to split the array into k or fewer subarrays\nsuch that the maximum subarray sum does not exceed max_sum.", "function_declaration": "def can_split(arr, n, k, max_sum):", "function_name": "can_split", "parameter_list": "(arr, n, k, max_sum)" }, { "...
[ 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 minimize_largest_sum(arr, n, k):\n def can_partition(arr, n, k, limit):\n count, current_sum = 1, 0\n for i in range(n):\n if curre...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008928", "row_id": 8928, "seed_ids": "[12836]" }
0.852009
Taco_8928
I
[ "can_split", "minimize_largest_sum" ]
2
[ [ "minimize_largest_sum", "can_split" ] ]
1
[]
false
[]
false
pytest
false
[]
true
78568030fad61777e9eafeb3704a948848e28148
01169bc991e6214eb5fded552257cedf2996fafa
v1.0
instruct
Taco
Taco_8935_I
A coding magazine editor wants to design a simple text editor that provides a special feature of `autocorrect`. The autocorrect function is supposed to correct misspelled words based on a given dictionary of correct words. The text editor needs to replace any misspelled words with the nearest correct word from the dict...
def levenshtein_distance(s1, s2): """ Compute the Levenshtein distance between two strings s1 and s2. """ if len(s1) < len(s2): return levenshtein_distance(s2, s1) if len(s2) == 0: return len(s1) previous_row = range(len(s2) + 1) for i, c1 in enumerate(s1): ...
from solution import process_testcases def test_case_1(): testcases = [ (3, ["apple", "banana", "orange"], 2, ["appl", "bannana"]), ] expected_output = ["apple banana"] assert process_testcases(testcases) == expected_output def test_case_2(): testcases = [ (2, ["codeforces", "stac...
[ { "docstring": "Compute the Levenshtein distance between two strings s1 and s2.", "function_declaration": "def levenshtein_distance(s1, s2):", "function_name": "levenshtein_distance", "parameter_list": "(s1, s2)" }, { "docstring": null, "function_declaration": "def autocorrect(dictionary...
[ 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 levenshtein_distance(s1, s2):\n \"\"\"Calculate the Levenshtein distance between two strings.\"\"\"\n if len(s1) < len(s2):\n return levenshtein_d...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00008935", "row_id": 8935, "seed_ids": "[9239]" }
0.593004
Taco_8935
I
[ "levenshtein_distance", "autocorrect", "process_testcases" ]
3
[ [ "autocorrect", "levenshtein_distance" ], [ "process_testcases", "autocorrect" ] ]
2
[ "process_testcases" ]
false
[]
false
pytest
true
[]
true
3ddb197882babfc392987b8ebde6a8c4f2aeb9c1
cbffa0c4017b9c23bb67c6c49ba3a2e21f524297
v1.0
instruct
Taco
Taco_8973_I
Alicia is an avid puzzle enthusiast and loves filling out crosswords. However, she faces a very peculiar problem. She must fill a crossword grid consisting of n rows and m columns with the words she has already chosen. The grid cells are represented as a list of n strings containing '.' for empty cells and '#' for bloc...
def can_place_word_horizontally(grid, word, row, col): if col + len(word) > len(grid[0]): return False for i in range(len(word)): if grid[row][col + i] == '#' or (grid[row][col + i] != '.' and grid[row][col + i] != word[i]): return False return True def can_place_word_vertically...
import pytest from solution import solve_crossword def test_example_1(): n = 4 m = 4 grid = ["....", ".#..", "....", "...."] words = ["this", "math", "cat"] assert solve_crossword(n, m, grid, words) == 3 def test_example_2(): n = 4 m = 4 grid = ["....", ".#..", ".##.", "...."] word...
[ { "docstring": null, "function_declaration": "def can_place_word_horizontally(grid, word, row, col):", "function_name": "can_place_word_horizontally", "parameter_list": "(grid, word, row, col)" }, { "docstring": null, "function_declaration": "def can_place_word_vertically(grid, word, row...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_place_word_horizontally(grid, word, row, col):\n if col + len(word) > len(grid[0]):\n return False\n for i in range(len(word)):\n if gr...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00008973", "row_id": 8973, "seed_ids": "[3388]" }
0.613037
Taco_8973
I
[ "can_place_word_horizontally", "can_place_word_vertically", "place_word_horizontally", "place_word_vertically", "solve_crossword" ]
5
[ [ "solve_crossword", "can_place_word_horizontally" ], [ "solve_crossword", "can_place_word_vertically" ], [ "solve_crossword", "place_word_horizontally" ], [ "solve_crossword", "place_word_vertically" ] ]
4
[]
false
[]
false
pytest
true
[]
true
5b1641b0a383321c64d9184d6ef8266d986f6401
ee00cca86962ab2c127e5160ccd2be9bdae6d4f3
v1.0
instruct
Taco
Taco_8983_I
A popular city has an intricate network of roads, represented as an undirected graph with N intersections and M roads. Each road has a particular energy cost associated with traversing it. There's a particularly important intersection known as the "center", denoted as C. Every day, several events take place, and each e...
import heapq import sys def dijkstra(graph, start): """ Function to implement Dijkstra's algorithm to find the shortest path from the start node to all other nodes in the graph. """ n = len(graph) distances = [sys.maxsize] * n distances[start] = 0 pq = [(0, start)] # Priority queue to ...
def test_minimum_energy_costs(): T = 1 test_cases = [( (6, 8, 3), (2,), [ (1, 2, 3), (1, 3, 1), (2, 3, 1), (2, 4, 2), (3, 4, 1), (3, 5, 4), (4, 6, 2), (5, 6, 3) ], [5, 6, 3] ...
[ { "docstring": "Function to implement Dijkstra's algorithm to find the shortest path\nfrom the start node to all other nodes in the graph.", "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": null, "fun...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\n\ndef dijkstra(graph, start):\n \"\"\"\n Function to implement Dijkstra's algorithm to find the shortest path\n from the start n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00008983", "row_id": 8983, "seed_ids": "[427]" }
0.712818
Taco_8983
I
[ "dijkstra", "minimum_energy_costs" ]
2
[ [ "minimum_energy_costs", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
64372e0b9cc8d7edbe9ac4dfe335345d055f47be
5903b8b16d6411f93d5bfa2480478974bbca1917
v1.0
instruct
Taco
Taco_8998_I
In a 2D coordinate plane, you are given an integer n and n pairs of integers (x, y) representing the coordinates of n points. Your task is to determine if there exists at least one right-angled triangle that can be formed using any three of these points. A right-angled triangle is one that has one angle exactly 90 de...
def is_right_angle(px, py, qx, qy, rx, ry): """Helper function to check if the triangle (p, q, r) is right-angled.""" a2 = (qx - px) ** 2 + (qy - py) ** 2 b2 = (rx - qx) ** 2 + (ry - qy) ** 2 c2 = (px - rx) ** 2 + (py - ry) ** 2 sides = sorted([a2, b2, c2]) return sides[0] + sides[1] == sides[2]...
def test_case_1(): points = [(0, 0), (3, 0), (3, 4), (0, 4)] assert find_right_angled_triangle(points) == "YES" def test_case_2(): points = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)] assert find_right_angled_triangle(points) == "NO" def test_case_3(): points = [(0, 0), (0, 5), (5, 0), (2, 2), (...
[ { "docstring": "Helper function to check if the triangle (p, q, r) is right-angled.", "function_declaration": "def is_right_angle(px, py, qx, qy, rx, ry):", "function_name": "is_right_angle", "parameter_list": "(px, py, qx, qy, rx, ry)" }, { "docstring": null, "function_declaration": "de...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef is_right_angle_triangle(p1, p2, p3):\n \"\"\"\n This function checks if the given three points form a right-angled ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00008998", "row_id": 8998, "seed_ids": "[16292]" }
0.8222
Taco_8998
I
[ "is_right_angle", "find_right_angled_triangle", "main" ]
3
[ [ "find_right_angled_triangle", "is_right_angle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4b19d7a27435eb51faa4be09dcd75d11e77b4d54
1892797c271ca1ba441ce667b400180090ab02f7
v1.0
instruct
Taco
Taco_9081_I
You are managing a fleet of delivery drones that operate within a grid city. Each grid cell can be either an open space or a building that a drone cannot fly through. Your task is to write a program to guide a drone from a starting position to a delivery location while ensuring it does not collide with buildings. The ...
from collections import deque def shortest_path(grid, startX, startY, endX, endY): N = len(grid) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(startX, startY, 0)]) # (x, y, distance) visited = set((startX, startY)) while queue: x, y, dist = queue.popleft() ...
def test_single_case_reachable(): input_str = "1\n5\n0 0 1 0 0\n0 0 1 0 0\n0 0 0 1 1\n1 1 0 0 0\n0 0 0 0 0\n0 0 4 4" expected_output = "8" assert main(input_str) == expected_output def test_single_case_unreachable(): input_str = "1\n4\n0 0 1 1\n1 1 0 0\n0 0 0 0\n1 0 0 0\n3 0 0 1" expected_output = ...
[ { "docstring": null, "function_declaration": "def shortest_path(grid, startX, startY, endX, endY):", "function_name": "shortest_path", "parameter_list": "(grid, startX, startY, endX, endY)" }, { "docstring": null, "function_declaration": "def solve_drone_delivery(test_cases):", "func...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(grid, startX, startY, endX, endY):\n \"\"\"\n Uses BFS to find the shortest path in a grid from (startX, s...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00009081", "row_id": 9081, "seed_ids": "[19159]" }
0.66456
Taco_9081
I
[ "shortest_path", "solve_drone_delivery", "parse_input", "main" ]
4
[ [ "solve_drone_delivery", "shortest_path" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
0323157e2dc83f558ca91a4a37caa41b973e9093
81a23013ecd520cce96b58a815555070b601721b
v1.0
instruct
Taco
Taco_9095_I
John is passionate about numbers, especially prime sequences. He recently learned about a fascinating concept called "prime gap sequences." A prime gap sequence is defined as the difference between successive prime numbers. For instance, the first few prime numbers are 2, 3, 5, 7, 11, so the first few prime gaps are 1,...
def is_prime(num): """ Return True if the number is prime, otherwise False. """ 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: re...
from solution import is_prime, generate_prime_gaps, sum_of_prime_gaps, 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_generate_prime_gaps(): assert generate_prime_gap...
[ { "docstring": "Return True if the number is prime, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generate the first n prime gaps.", "function_declaration": "def generate_prime_gaps(n):", "fu...
[ 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(num):\n \"\"\"\n Return True if the number is prime, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00009095", "row_id": 9095, "seed_ids": "[24930]" }
0.580164
Taco_9095
I
[ "is_prime", "generate_prime_gaps", "sum_of_prime_gaps", "solve" ]
4
[ [ "generate_prime_gaps", "is_prime" ], [ "solve", "sum_of_prime_gaps" ], [ "sum_of_prime_gaps", "generate_prime_gaps" ] ]
3
[]
false
[]
false
pytest
true
[]
true
f3d5e7ca701f32189427a21a3b49cd18cafd6a80
651be12c7fd3b6921cc078af42140f4913bc36d4
v1.0
instruct
Taco
Taco_9099_I
A factory has a network of N machines (numbered 1 to N) connected by M conveyor belts. Each conveyor belt connects two machines and transfers items between them in a specified amount of time. The factory produces items on machine 1 and they need to be delivered to machine N. Write a program to determine the minimum am...
import heapq import sys input = sys.stdin.read def find_min_transfer_time(n, m, edges): adj = [[] for _ in range(n + 1)] for u, v, t in edges: adj[u].append((v, t)) adj[v].append((u, t)) return dijkstra(adj, 1, n, n) def dijkstra(adj, start, end, n): pq = [(0, start)] dist = {...
from solution import find_min_transfer_time def test_sample_1(): N = 5 M = 6 edges = [ (1, 2, 4), (2, 3, 1), (3, 5, 1), (1, 4, 5), (4, 5, 2), (3, 4, 3) ] assert find_min_transfer_time(N, M, edges) == 6 def test_no_path(): N = 4 M = 2 edge...
[ { "docstring": null, "function_declaration": "def find_min_transfer_time(n, m, edges):", "function_name": "find_min_transfer_time", "parameter_list": "(n, m, edges)" }, { "docstring": null, "function_declaration": "def dijkstra(adj, start, end, n):", "function_name": "dijkstra", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\ninput = sys.stdin.read\n\ndef find_min_transfer_time(n, m, edges):\n adj = [[] for _ in range(n + 1)]\n for u, v, t in edges:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00009099", "row_id": 9099, "seed_ids": "[9455]" }
0.774185
Taco_9099
I
[ "find_min_transfer_time", "dijkstra", "main" ]
3
[ [ "find_min_transfer_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7eee1d015139e8528416fc15986ac9f3226fdae6
da2794c8f2e41c257a21f8eb424babbd48da9357
v1.0
instruct
Taco
Taco_9168_I
In a networking system, computers are interconnected such that messages can be sent from one computer to another through various paths. Each computer has a unique identifier, and communication paths have different latencies associated with them. In this system, a message can be sent from one computer to another either ...
import heapq def dijkstra(n, edges, source, destination): """ Function to calculate the minimum latency to send a message from the source to the destination computer. Parameters: n (int): Number of computers edges (list of tuples): List of edges where each edge is represented as (u, v,...
def test_simple_case(): n = 5 m = 5 edges = [(0, 1, 10), (0, 2, 5), (1, 3, 1), (2, 1, 3), (3, 4, 4)] source = 0 destination = 4 assert minimum_latency(n, m, edges, source, destination) == 13 def test_direct_connection(): n = 3 m = 3 edges = [(0, 1, 1), (1, 2, 1), (0, 2, 10)] sou...
[ { "docstring": "Function to calculate the minimum latency to send a message from the source to the destination computer.\n\nParameters:\n n (int): Number of computers\n edges (list of tuples): List of edges where each edge is represented as (u, v, w)\n source (int): Source computer\n destination (in...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, edges, source, destination):\n \"\"\"\n Function to calculate the minimum latency to send a message from the source to the de...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00009168", "row_id": 9168, "seed_ids": "[1078]" }
0.666686
Taco_9168
I
[ "dijkstra", "minimum_latency" ]
2
[ [ "minimum_latency", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
dfa59e477d0f8c565bfaa4fe7f48ffc1f0b07616
53806e44887dd44054b8d2b81457d53e93c0cca5
v1.0
instruct
Taco
Taco_9226_I
Ariella is learning about string manipulation in her programming course and has come across the concept of palindromes. She finds it fascinating but slightly challenging. A palindrome is a string that reads the same forward and backward, ignoring cases, spaces, and non-alphanumeric characters. Ariella’s task is to writ...
def is_alphanumeric(c): return c.isalnum() def is_palindrome(s): filtered_chars = list(filter(is_alphanumeric, s.lower())) return filtered_chars == filtered_chars[::-1] def can_be_palindrome_by_removing_one_char(s): filtered_chars = list(filter(is_alphanumeric, s.lower())) for i in range(len(filte...
from solution import palindrome_status def test_palindrome(): assert palindrome_status("A man a plan a canal Panama") == 1 def test_one_removal_palindrome(): assert palindrome_status("abca") == 0 def test_not_palindrome(): assert palindrome_status("abc") == -1 def test_single_character(): assert...
[ { "docstring": null, "function_declaration": "def is_alphanumeric(c):", "function_name": "is_alphanumeric", "parameter_list": "(c)" }, { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "doc...
[ 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_alphanumeric(c):\n return c.isalnum()\n\ndef is_palindrome(s):\n filtered_chars = list(filter(is_alphanumeric, s.lower()))\n return filtered_chars ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00009226", "row_id": 9226, "seed_ids": "[18071]" }
0.761023
Taco_9226
I
[ "is_alphanumeric", "is_palindrome", "can_be_palindrome_by_removing_one_char", "palindrome_status" ]
4
[ [ "can_be_palindrome_by_removing_one_char", "is_alphanumeric" ], [ "is_palindrome", "is_alphanumeric" ], [ "palindrome_status", "can_be_palindrome_by_removing_one_char" ], [ "palindrome_status", "is_palindrome" ] ]
4
[]
false
[]
false
pytest
true
[]
true
11e9bfaa1493c8c6bb209fa870ff87322b1a6462
f8f20fe0937367dfbd95f4b0966ec0e523f4c945
v1.0
instruct
Taco
Taco_9269_I
King of Westeros wants to expand his territory by building a series of fortresses. Each fortress has a specific strength that is determined by a peculiar function. The strength of a fortress is the sum of the factorials of the number of distinct prime numbers in each of its prime factor decompositions. Given a set of f...
import math def prime_factors(n): """Returns a set of distinct prime factors of n.""" factors = set() while n % 2 == 0: factors.add(2) n = n // 2 for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: factors.add(i) n = n // i if n > 2: ...
from solution import prime_factors, fortress_strength, total_strength_of_fortresses def test_prime_factors(): assert prime_factors(6) == {2, 3} assert prime_factors(10) == {2, 5} assert prime_factors(15) == {3, 5} assert prime_factors(17) == {17} def test_fortress_strength(): assert fortress_stren...
[ { "docstring": "Returns a set of distinct prime factors of n.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Returns the sum of factorials of the distinct prime factors of n.", "function_declaration": "def f...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import factorial\n\ndef prime_factors(n):\n \"\"\" Return the list of distinct prime factors of a given number. \"\"\"\n factors = set()\n d = 2...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00009269", "row_id": 9269, "seed_ids": "[7729]" }
0.584048
Taco_9269
I
[ "prime_factors", "fortress_strength", "total_strength_of_fortresses" ]
3
[ [ "fortress_strength", "prime_factors" ], [ "total_strength_of_fortresses", "fortress_strength" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9fe39321614efd789e7be8c6e3242a713d683526
0e363d838f9fae183cc34a612e2b50c1380badc7
v1.0
instruct
Taco
Taco_9274_I
As a space station engineer, you are tasked with optimizing the energy consumption of robot movements in a grid. Each robot can move up, down, left, or right by one unit per move. The grid consists of `N` x `M` cells, where each cell either contains a clear path (represented by '.') or an obstacle (represented by '#')....
from collections import deque def min_energy_cost(T, test_cases): def bfs(grid, start, target): N = len(grid) M = len(grid[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(start[0], start[1], 0)]) visited = set() visited.add((start[0], start[1])) ...
def test_min_energy_cost(): T = 2 test_cases = [ (4, 4, ["....", ".#..", "..#.", "...."], 0, 0, 3, 3), (4, 4, ["..#.", ".#..", "..#.", "...."], 0, 1, 2, 2), ] expected = [ "Case #1: 6", "Case #2: -1" ] assert min_energy_cost(T, test_cases) == expected def test_mi...
[ { "docstring": null, "function_declaration": "def min_energy_cost(T, test_cases):", "function_name": "min_energy_cost", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def driver():", "function_name": "driver", "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": "from collections import deque\n\ndef min_energy_cost(T, test_cases):\n results = []\n \n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n \n def bf...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00009274", "row_id": 9274, "seed_ids": "[22922]" }
0.7293
Taco_9274
I
[ "min_energy_cost", "driver" ]
2
[ [ "driver", "min_energy_cost" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3b4ae0db60561538659d556fe3731a9a5d00c241
8ab0b77d17f188dbbc30af5a07e67c80e9e11f5c
v1.0
instruct
Taco
Taco_9351_I
Given an undirected graph with `n` vertices and `m` edges, write a program to determine if the graph contains a cycle. Each of the `m` edges connects a pair of vertices. A cycle is formed when a path exists between a node and itself with one or more edges. If the graph contains a cycle, output "YES". Otherwise, outpu...
def find(parent, i): if parent[i] == -1: return i return find(parent, parent[i]) def union(parent, x, y): xset = find(parent, x) yset = find(parent, y) if xset != yset: parent[xset] = yset def has_cycle(n, edges): parent = [-1] * (n + 1) for u, v in edges: x = find(...
from solution import detect_cycles_in_graphs def test_cycle_case_1(): test_cases = [ (3, 3, [(1, 2), (1, 3), (2, 3)]) ] assert detect_cycles_in_graphs(test_cases) == ["YES"] def test_cycle_case_2(): test_cases = [ (4, 2, [(1, 2), (3, 4)]) ] assert detect_cycles_in_graphs(test_c...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }, { "doc...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_parent(parents, node):\n if parents[node] == node:\n return node\n parents[node] = find_parent(parents, parents[node])\n return parents[no...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00009351", "row_id": 9351, "seed_ids": "[8074]" }
0.793926
Taco_9351
I
[ "find", "union", "has_cycle", "detect_cycles_in_graphs" ]
4
[ [ "detect_cycles_in_graphs", "has_cycle" ], [ "has_cycle", "find" ], [ "has_cycle", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
e540528eef2067662a185512c274037cb235bce2
33e2ed05daa5dbb0cf10d070b5ba32ac1a30429e
v1.0
instruct
Taco
Taco_9356_I
You are tasked with developing a software system to manage a parking lot with automated billing. The parking lot consists of different sections: Regular, Compact, Handicapped, and Electric. Each section has a limited number of parking spaces and can accommodate cars up to a specified maximum size. Each car that enters...
def calculate_fee(entry_time, exit_time, rate_per_hour): entry_hours, entry_minutes = map(int, entry_time.split(":")) exit_hours, exit_minutes = map(int, exit_time.split(":")) total_entry_minutes = entry_hours * 60 + entry_minutes total_exit_minutes = exit_hours * 60 + exit_minutes total_minutes = ...
import pytest from solution import process_parking_events def test_example(): events = [ "enter ABC123 2 R 09:00", "enter XYZ789 1 C 09:30", "exit ABC123 11:00", "enter EFG456 3 H 12:00", "enter HIJ101 1 E 13:00", "exit XYZ789 14:00" ] expected_output = [ ...
[ { "docstring": null, "function_declaration": "def calculate_fee(entry_time, exit_time, rate_per_hour):", "function_name": "calculate_fee", "parameter_list": "(entry_time, exit_time, rate_per_hour)" }, { "docstring": null, "function_declaration": "def process_parking_events(events):", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_fee(entry_time, exit_time, rate_per_hour):\n entry_hours, entry_minutes = map(int, entry_time.split(\":\"))\n exit_hours, exit_minutes = map(in...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00009356", "row_id": 9356, "seed_ids": "[22209]" }
0.64003
Taco_9356
I
[ "calculate_fee", "process_parking_events" ]
2
[ [ "process_parking_events", "calculate_fee" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5528d90f1c8c400df73008bd2aaf70d4c996f30d
41a3522ddb88db024e2b285735fe092ddabf3b37