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_9381_I
Albert has a challenge for you: Given an array of integers, for each element in the array compute the product of all the elements in the array except the element at the current position. You are required to solve this without using division. Input Format: The first line contains T, the number of test cases. Each test ...
def product_except_self(arr): """ Given an array arr, returns a new array such that each element at index i is equal to the product of all the elements of arr except arr[i], without using division. """ n = len(arr) if n == 0: return [] # Initialize the left and right product arrays ...
def test_product_except_self(): assert product_except_self([1, 2, 3]) == [6, 3, 2] assert product_except_self([2, 3, 4, 5]) == [60, 40, 30, 24] assert product_except_self([1, 1, 1, 1]) == [1, 1, 1, 1] assert product_except_self([1, 2, 0]) == [0, 0, 2] assert product_except_self([0, 0, 0]) == [0, 0, ...
[ { "docstring": "Given an array arr, returns a new array such that each element at index i is\nequal to the product of all the elements of arr except arr[i], without using division.", "function_declaration": "def product_except_self(arr):", "function_name": "product_except_self", "parameter_list": "(...
[ 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 product_except_self(arr):\n \"\"\"\n Given an array arr, returns a new array such that each element at index i is\n equal to the product of all the el...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00009381", "row_id": 9381, "seed_ids": "[2849]" }
0.687747
Taco_9381
I
[ "product_except_self", "solve", "parse_input", "format_output" ]
4
[ [ "solve", "product_except_self" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
6fa69a058cd69488b4783a0e7eb791b85dd65488
64063225655ca746d9cbe9e6935e6143e0b73dff
v1.0
instruct
Taco
Taco_9431_I
Linda loves playing with numbers, and she has recently come across the concept of digit sum. A digit sum of a number is the sum of all its digits. For example, the digit sum of 1234 is 1 + 2 + 3 + 4 = 10. Linda has a list of positive integers and wants to know the digit sums for each of these numbers. Can you help her...
def digit_sum(n): """ Returns the digit sum of the number n. """ return sum(int(digit) for digit in str(n)) def compute_digit_sums(numbers): """ For each number in the list `numbers`, computes the digit sum and returns a list of these sums. """ return [digit_sum(number) for number i...
from solution import digit_sum, compute_digit_sums def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(456) == 15 assert digit_sum(7890) == 24 assert digit_sum(1) == 1 assert digit_sum(10**9) == 1 # 1000000000 -> digit sum is 1 assert digit_sum(999999999) == 81 # All 9s, 9*9 = 8...
[ { "docstring": "Returns the digit sum of the number n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "For each number in the list `numbers`, computes the digit sum and\nreturns a list of these sums.", "function_decl...
[ 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 digit_sum(n):\n \"\"\"\n Returns the sum of the digits of the number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef digit_sums(num...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00009431", "row_id": 9431, "seed_ids": "[8066]" }
0.817027
Taco_9431
I
[ "digit_sum", "compute_digit_sums" ]
2
[ [ "compute_digit_sums", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ba9a9378df674456ae73590fdf93e481372ff654
17f9061ddbd7d0b5350cecdeeacef52049d346f4
v1.0
instruct
Taco
Taco_9433_I
A massive space mining project is underway in the Andromeda galaxy. One of the main milestones of this project is to deploy mining robots on asteroids. Each asteroid is modeled as a polyhedron in a three-dimensional space. Before deploying the robots, scientists need to calculate the volume of these asteroids to determ...
import sys import math def vector_cross(a, b): return [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]] def dot_product(a, b): return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] def volume_of_tetrahedron(v1, v2, v3, v4): vec1 = [v2[i] - v1[i] for i in range(3)] vec2 = [v3[i] - v1[i] for i i...
from solution import calculate_polyhedron_volume def test_tetrahedron_volume(): vertices = [ [0.00000, 0.00000, 0.00000], [1.00000, 0.00000, 0.00000], [0.00000, 1.00000, 0.00000], [0.00000, 0.00000, 1.00000], ] faces = [ [1, 2, 3], [1, 2, 4], [1, 3, 4...
[ { "docstring": null, "function_declaration": "def vector_cross(a, b):", "function_name": "vector_cross", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def dot_product(a, b):", "function_name": "dot_product", "parameter_list": "(a, b)" }, { "d...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def volume_of_polyhedron(vertices, faces):\n def vector_cross_product(a, b):\n return (\n a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00009433", "row_id": 9433, "seed_ids": "[212]" }
0.648463
Taco_9433
I
[ "vector_cross", "dot_product", "volume_of_tetrahedron", "calculate_polyhedron_volume", "parse_input", "main" ]
6
[ [ "calculate_polyhedron_volume", "volume_of_tetrahedron" ], [ "volume_of_tetrahedron", "dot_product" ], [ "volume_of_tetrahedron", "vector_cross" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
671bf90eb1fa2fb94e7851c3a3b1827f1bca20b1
7179d3b4b62b20ccb382ae466b3e53648a0cb0f4
v1.0
instruct
Taco
Taco_9439_I
Mina is practicing her data structure skills with linked lists. She decides to create a problem where she has to reorder a linked list according to specific rules. Given a singly linked list, you need to reorder the list so that it is arranged in the order: first node -> last node -> second node -> second last node -> ...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reorderList(head): if not head or not head.next: return head # Find the middle of the linked list slow, fast = head, head while fast and fast.next: slow = slow.next ...
import pytest from solution import reorder_list def test_reorder_list_case1(): assert reorder_list([1, 2, 3, 4]) == [1, 4, 2, 3] def test_reorder_list_case2(): assert reorder_list([1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3] def test_reorder_list_single_element(): assert reorder_list([1]) == [1] def test_reorder...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef list_to_string(head: ListNode) -> str:\n res...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00009439", "row_id": 9439, "seed_ids": "[18274]" }
0.584376
Taco_9439
I
[ "reorderList", "toList", "toLinkedList", "reorder_list" ]
4
[ [ "reorder_list", "reorderList" ], [ "reorder_list", "toLinkedList" ], [ "reorder_list", "toList" ] ]
3
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
dd873df56bee8941dc2073f56c2fdceb23c16ea5
2f55017fe4219918a033e4c898e4ca98a6e5a46f
v1.0
instruct
Taco
Taco_9467_I
Arjun and Beena are participating in a coding competition where they need to find out if a specific number is a "Special Fibonacci Number". Arjun loves Fibonacci numbers, and Beena admires prime numbers. So, they combined their interests and came up with the following definition: A number is considered a "Special Fibo...
def is_prime(n): if n <= 1: return False if n == 2 or n == 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def is_fibonacci(n): if n < 0: ...
from solution import is_prime, is_fibonacci, is_special_fibonacci_number, special_fibonacci_numbers def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(1) == False assert is_prime(0) == False asse...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_fibonacci(n):", "function_name": "is_fibonacci", "parameter_list": "(n)" }, { "docstring": null, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00009467", "row_id": 9467, "seed_ids": "[13618]" }
0.684665
Taco_9467
I
[ "is_prime", "is_fibonacci", "is_special_fibonacci_number", "special_fibonacci_numbers" ]
4
[ [ "is_special_fibonacci_number", "is_fibonacci" ], [ "is_special_fibonacci_number", "is_prime" ], [ "special_fibonacci_numbers", "is_special_fibonacci_number" ] ]
3
[]
false
[]
false
pytest
true
[]
true
b805b3aee978d9a91a057ee49428251b578433aa
b2ff9f741156739a1852bd80df0dcb5313941310
v1.0
instruct
Taco
Taco_9482_I
### Prime Number Array Alice has an array of integers and wants to know how many prime numbers are in the array. Write a program that takes an integer array as input and outputs the count of prime numbers in the array. A prime number is an integer greater than 1 that has no positive divisors other than 1 and itself. ...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def count_primes(arr): return sum(1 for x ...
from solution import is_prime, count_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(25) == False assert is_prime(29) == True def test_count_primes_example1(): assert count_primes([2, 3...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_primes(arr):", "function_name": "count_primes", "parameter_list": "(arr)" } ]
[ 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 Return True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00009482", "row_id": 9482, "seed_ids": "[4939]" }
0.728291
Taco_9482
I
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f3fa83f35bb092798a03fc4caf94a0baa491bdcd
9951e02549030ae1b6f34e71b3aedf3e3dec1337
v1.0
instruct
Taco
Taco_9523_I
A company wants to generate unique employee IDs for each of its employees. Every employee ID must be a palindromic number, meaning it reads the same backward as forward. Given an integer N, the company wants to know the N-th palindromic number. The first few palindromic numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 3...
def is_palindrome(num): """ Helper function to check if a number is a palindrome. """ return str(num) == str(num)[::-1] def nth_palindromic_number(N): """ Function to get the N-th palindromic number. """ count = 0 num = 0 # Iterate until we find the N-th palindromic number w...
from solution import nth_palindromic_number def test_first_ten_palindromic_numbers(): assert nth_palindromic_number(1) == 1 assert nth_palindromic_number(2) == 2 assert nth_palindromic_number(3) == 3 assert nth_palindromic_number(4) == 4 assert nth_palindromic_number(5) == 5 assert nth_palindro...
[ { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Function to get the N-th palindromic number.", "function_declaration": "def nth_palind...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def nth_palindromic_number(N):\n \"\"\"\n Returns the N-th palindromic number.\n \"\"\"\n def is_palindromic(num):\n return str(num) == str(num)...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00009523", "row_id": 9523, "seed_ids": "[17271]" }
0.724096
Taco_9523
I
[ "is_palindrome", "nth_palindromic_number" ]
2
[ [ "nth_palindromic_number", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2c69fb4442c92e1f778ebea90f4f1bd8f6c69413
36e44dc692e0fd3e38260e69684adc7917438b58
v1.0
instruct
Taco
Taco_9562_I
In a 2D grid of size N x M, you are to find the shortest path from the top-left corner (0,0) to the bottom-right corner (N-1,M-1). However, certain cells are blocked and cannot be traversed. You are allowed to move up, down, left, or right, but cannot move diagonally. Your task is to calculate the length of the shorte...
from collections import deque def get_shortest_path_length(n, m, grid): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Up, Down, Left, Right queue = deque([(0, 0, 0)]) # (x, y, distance) visited = set((0, 0)) while queue: x, y, dist = queue.popleft() if x == n-1 and y...
def test_get_shortest_path_length_1(): grid = [ ['0', '1', '0'], ['0', '0', '0'], ['1', '1', '0'] ] assert get_shortest_path_length(3, 3, grid) == 4 def test_get_shortest_path_length_2(): grid = [ ['0', '0', '1', '0'], ['1', '0', '1', '0'], ['0', '0', '0'...
[ { "docstring": null, "function_declaration": "def get_shortest_path_length(n, m, grid):", "function_name": "get_shortest_path_length", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def input_and_calculate_shortest_path():", "function_name": "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\n\ndef shortest_path(N, M, grid):\n \"\"\"\n Returns the length of the shortest path in a grid from the top-left corner to the ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00009562", "row_id": 9562, "seed_ids": "[5909]" }
0.713099
Taco_9562
I
[ "get_shortest_path_length", "input_and_calculate_shortest_path" ]
2
[ [ "input_and_calculate_shortest_path", "get_shortest_path_length" ] ]
1
[]
false
[]
false
pytest
false
[]
true
14c752b2a0c4144737a6941c431312f2f5657533
9d7c4b93ee5b7118e5d8951f553fa45e16012997
v1.0
instruct
Taco
Taco_9577_I
A progressive number is a positive integer that, when its digits are raised to consecutive powers starting from 1, the sum of those powers equals to the number itself. For instance, 89 is a progressive number because 8^1 + 9^2 = 89. Write a program that takes two positive integers p and q (where p < q) and prints out ...
def is_progressive_number(n): """ Checks if the number n is a progressive number. """ digits = [int(d) for d in str(n)] total = sum(d ** (i + 1) for i, d in enumerate(digits)) return total == n def find_progressive_numbers(p, q): """ Find all progressive numbers in the range [p, q]. ...
from solution import is_progressive_number, find_progressive_numbers # Unit tests for is_progressive_number function def test_is_progressive_number_true(): assert is_progressive_number(89) == True assert is_progressive_number(135) == True def test_is_progressive_number_false(): assert is_progressive_numbe...
[ { "docstring": "Checks if the number n is a progressive number.", "function_declaration": "def is_progressive_number(n):", "function_name": "is_progressive_number", "parameter_list": "(n)" }, { "docstring": "Find all progressive numbers in the range [p, q].", "function_declaration": "def...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_progressive_number(n):\n \"\"\"\n Checks if a number n is a progressive number.\n \"\"\"\n digits = list(map(int, str(n)))\n progressive_sum ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00009577", "row_id": 9577, "seed_ids": "[2836]" }
0.542506
Taco_9577
I
[ "is_progressive_number", "find_progressive_numbers" ]
2
[ [ "find_progressive_numbers", "is_progressive_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d21d70047c38b02a858fb749aa7e03f0ee187859
7c42967437a52e9132e06b9cc9eb9b4def44afe4
v1.0
instruct
Taco
Taco_9645_I
Given a binary tree, write a program to find the sum of all left leaves in the tree. A leaf is a node with no children, and a left leaf is a leaf that is the left child of its parent. ------ Input details ------ The input consists of the binary tree in level order traversal, with 'null' representing absence of a no...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sumOfLeftLeaves(root): if not root: return 0 def is_leaf(node): return node and not node.left and not node.right left_sum = 0 if ro...
from solution import sum_of_left_leaves_from_input def test_sum_of_left_leaves_case_1(): tree_input = "3 9 20 null null 15 7" assert sum_of_left_leaves_from_input(tree_input) == 24 def test_sum_of_left_leaves_with_no_left_leaves(): tree_input = "1 null 2 null 3 null 4 null 5" assert sum_of_left_leaves...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef sumOfLe...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00009645", "row_id": 9645, "seed_ids": "[9990]" }
0.623393
Taco_9645
I
[ "sumOfLeftLeaves", "build_tree_from_level_order", "sum_of_left_leaves_from_input" ]
3
[ [ "sum_of_left_leaves_from_input", "build_tree_from_level_order" ], [ "sum_of_left_leaves_from_input", "sumOfLeftLeaves" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
6243f7b87e0b959337b6ed30368a557a2b1f5ef5
9bd7b7458b81b13eadafc6fa96267f34f6bb472a
v1.0
instruct
Taco
Taco_9672_I
Fibonacci Array Transformation You are given an array of integers. Your goal is to transform this array into another array where each element is equal to the sum of itself and the corresponding Fibonacci number. The first Fibonacci number in this context is considered to be `F0 = 0`, the second `F1 = 1`, the third `F2...
def fibonacci(n): """ Returns a list of the first n Fibonacci numbers with zero-based indexing. """ if n == 0: return [] if n == 1: return [0] fib = [0, 1] for i in range(2, n): fib.append(fib[i-1] + fib[i-2]) return fib def transform_array(arr): """...
from solution import fibonacci, transform_array def test_fibonacci(): assert fibonacci(0) == [] assert fibonacci(1) == [0] assert fibonacci(2) == [0, 1] assert fibonacci(3) == [0, 1, 1] assert fibonacci(5) == [0, 1, 1, 2, 3] def test_transform_array(): assert transform_array([4, 3, 2, 1, 0]) =...
[ { "docstring": "Returns a list of the first n Fibonacci numbers with zero-based indexing.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Transforms the array by adding the corresponding Fibonacci number to each element....
[ 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(n):\n \"\"\"\n Generate a list of first n Fibonacci numbers.\n \"\"\"\n if n == 0:\n return []\n elif n == 1:\n return [...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00009672", "row_id": 9672, "seed_ids": "[10457]" }
0.588117
Taco_9672
I
[ "fibonacci", "transform_array" ]
2
[ [ "transform_array", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8742df95e8941f7736f0ecc04e07e6cf3c510a3
f7bb03737042861b87b4b0758a6a562378c4414c
v1.0
instruct
Taco
Taco_9679_I
You are helping your friend Mike organize a bike rental service. He has a set of bikes that can be rented for varying periods of time, and each rental has a different profit associated with it. From past data, you know the rental slots come in various lengths - some spanning just a few hours, others going up to several...
def max_profit(t, rental_options): """ Returns the maximum profit Mike can achieve without overlapping rental periods. :param t: Number of test cases :param rental_options: List of rental options for each test case. Each rental option consists of a tuple (start, end, profit). :return: List...
from solution import max_profit def test_sample_input(): # sample input t = 1 rental_options = [ [(1, 3, 50), (2, 5, 20), (4, 6, 70)] ] assert max_profit(t, rental_options) == [120] def test_no_overlapping(): # test no overlapping rentals t = 1 rental_options = [ [...
[ { "docstring": "Returns the maximum profit Mike can achieve without overlapping rental periods.\n\n:param t: Number of test cases\n:param rental_options: List of rental options for each test case. Each rental option consists of a tuple (start, end, profit).\n\n:return: List of maximum profit for each test case"...
[ 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 bisect import bisect_right\n\ndef max_profit_for_rentals(rentals):\n # Sort the rentals by end time\n rentals.sort(key=lambda x: x[1])\n \n # Init...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00009679", "row_id": 9679, "seed_ids": "[17267]" }
0.703529
Taco_9679
I
[ "max_profit", "binary_search" ]
2
[ [ "max_profit", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5a4283bfd429380064adfc410f1600b6d997496d
0754584e632bc5d50f93461cbcba6423e9bd9a2e
v1.0
instruct
Taco
Taco_9751_I
A kingdom is divided into several cities connected by bidirectional roads. Each road has a travel time. You are asked to write a program to determine the shortest time required to travel between pairs of cities. If a direct connection between the cities is not possible, the program should return -1. The cities are lab...
import heapq def dijkstra(graph, start, n): """ Performs Dijkstra's algorithm to find the shortest path from start to all other nodes. """ distances = {node: float('infinity') for node in range(1, n+1)} distances[start] = 0 pq = [(0, start)] while pq: current_distance, current_...
def test_example_1(): input_lines = [ "4 4", "1 2 1", "2 3 3", "3 4 1", "4 1 6", "2", "1 3", "1 4", "5 3", "1 2 10", "2 3 10", "4 5 5", "1", "1 5", "0 0" ] expected_output = [4, 5, -1] ...
[ { "docstring": "Performs Dijkstra's algorithm to find the shortest path from start to all other nodes.", "function_declaration": "def dijkstra(graph, start, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, n)" }, { "docstring": "For each query, find the shortest travel ti...
[ 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 sys\nimport heapq\n\ndef dijkstra(n, graph, start, end):\n distance = [float('inf')] * (n + 1)\n distance[start] = 0\n priority_queue = [(0, start)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00009751", "row_id": 9751, "seed_ids": "[943]" }
0.808155
Taco_9751
I
[ "dijkstra", "find_shortest_paths", "process_input_blocks" ]
3
[ [ "find_shortest_paths", "dijkstra" ], [ "process_input_blocks", "find_shortest_paths" ] ]
2
[]
false
[]
false
pytest
false
[]
true
c10b6487bf3b39d80cab0857cdc7aba3d37c9a62
503335919f42d5414062b971fae0adda831c7357
v1.0
instruct
Taco
Taco_9833_I
You are given a list of tasks. Each task is represented by a start time and an end time. Two tasks are compatible if they do not overlap. Your goal is to find the maximum number of compatible tasks from the given list. A task `(s1, e1)` is considered compatible with another task `(s2, e2)` if and only if `e1 <= s2` or...
def max_compatible_tasks(test_cases): results = [] for tasks in test_cases: # Sort tasks by their end times for the greedy algorithm tasks.sort(key=lambda x: x[1]) max_tasks = 0 last_end_time = -1 for start, end in tasks: if start >= last_en...
import pytest from solution import parse_input, max_compatible_tasks, solve def test_parse_input(): input_str = "3\n1 3\n2 5\n4 6\n4\n1 2\n3 4\n0 5\n8 9\n0\n" expected = [ [(1, 3), (2, 5), (4, 6)], [(1, 2), (3, 4), (0, 5), (8, 9)], ] assert parse_input(input_str) == expected def test_...
[ { "docstring": null, "function_declaration": "def max_compatible_tasks(test_cases):", "function_name": "max_compatible_tasks", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "paramete...
[ 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_compatible_tasks(test_cases):\n results = []\n for tasks in test_cases:\n tasks.sort(key=lambda x: x[1]) # Sort tasks based on end time\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00009833", "row_id": 9833, "seed_ids": "[24973]" }
0.644134
Taco_9833
I
[ "max_compatible_tasks", "parse_input", "solve" ]
3
[ [ "solve", "max_compatible_tasks" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
34cce6a5eb293a7f7e52147a7af499f1bc437924
1e0a0c2a7c6d2649e0b23821273b72c5efc4245c
v1.0
instruct
Taco
Taco_9882_I
A company wants to monitor its employees' activity to ensure they are not idle during their working hours. Each employee has a unique ID and a list of timestamps representing their login and logout times (in pairs) throughout the day. The company defines "idle time" as the total amount of time an employee is logged out...
from datetime import datetime def calculate_idle_time(log_pairs): idle_time = 0 for i in range(1, len(log_pairs), 2): logout_time = datetime.strptime(log_pairs[i], "%H:%M") if i+1 < len(log_pairs): next_login_time = datetime.strptime(log_pairs[i+1], "%H:%M") idle_ti...
from solution import find_idle_employees def test_no_idle_time_violations(): employee_data = ["1", "60", "E001 09:00,12:00"] result = find_idle_employees(employee_data, 60) assert result == ["NO IDLE TIME VIOLATIONS"] def test_single_idle_violation(): employee_data = ["1", "30", "E001 09:00,09:30,10:0...
[ { "docstring": null, "function_declaration": "def calculate_idle_time(log_pairs):", "function_name": "calculate_idle_time", "parameter_list": "(log_pairs)" }, { "docstring": null, "function_declaration": "def find_idle_employees(employee_data, threshold):", "function_name": "find_idl...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef parse_time(time_str):\n return datetime.strptime(time_str, \"%H:%M\")\n\ndef calculate_total_idle_time(logins_logouts):\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00009882", "row_id": 9882, "seed_ids": "[8372]" }
0.584733
Taco_9882
I
[ "calculate_idle_time", "find_idle_employees" ]
2
[ [ "find_idle_employees", "calculate_idle_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eecfb44bce0c69fa16c4decc0d3f54bc1d6d1619
5080e3478537922e9c0275882a779bec28a18ea6
v1.0
instruct
Taco
Taco_9924_I
Nyx, a computer science student, loves solving number theory problems. One day, she comes across a fascinating problem related to prime numbers. She decided to solve it using her coding skills but quickly realized that it requires a highly optimized approach due to the large constraints. Given her passion for coding, s...
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, calculate_sum_of_primes_in_list, solve_prime_sum_problem 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(17) == True assert is_prime(20) == False assert is_prime(...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Calculates the sum of prime numbers in the provided list.", "function_declaration": "def calculate_sum_of_primes_in_list(...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if an integer is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00009924", "row_id": 9924, "seed_ids": "[10059]" }
0.670531
Taco_9924
I
[ "is_prime", "calculate_sum_of_primes_in_list", "solve_prime_sum_problem" ]
3
[ [ "calculate_sum_of_primes_in_list", "is_prime" ], [ "solve_prime_sum_problem", "calculate_sum_of_primes_in_list" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c98f4edf4a4ae09101c97c42f1706a379266790d
a6e378b1731c336ceba49b81ff0d1a2505961d5c
v1.0
instruct
Taco
Taco_10005_I
Emma loves programming contests. When she practices, she likes to simulate competitions by solving several problems in a row. She wants to track her performance by recording the time taken to solve each problem. After a session, she realizes that she wants a summary of her performance: the shortest time, the longest ti...
def performance_metrics(times): """ This function takes a list of times taken to solve problems and returns a tuple containing: - the shortest time - the longest time - the average time - the median time """ n = len(times) if n == 0: return 0.00, 0.00, 0.00, 0.00 tim...
from solution import performance_metrics, metrics_from_input def test_performance_metrics_single_entry(): assert performance_metrics([100]) == (100.00, 100.00, 100.00, 100.00) def test_performance_metrics_odd_entries(): assert performance_metrics([120, 150, 300, 50, 90]) == (50.00, 300.00, 142.00, 120.00) de...
[ { "docstring": "This function takes a list of times taken to solve problems and returns a tuple containing:\n- the shortest time\n- the longest time\n- the average time\n- the median time", "function_declaration": "def performance_metrics(times):", "function_name": "performance_metrics", "parameter_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def performance_summary(n, times):\n \"\"\"\n Computes and returns the shortest, longest, average, and median time from the given list of times.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010005", "row_id": 10005, "seed_ids": "[2808]" }
0.605177
Taco_10005
I
[ "performance_metrics", "metrics_from_input" ]
2
[ [ "metrics_from_input", "performance_metrics" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a7cdcf2cc41875c2a5183f6eb2122c9c3194308f
80268d5c74aa72c79a5d9f70d8dbbb2d6dae6d47
v1.0
instruct
Taco
Taco_10132_I
Problem A city has an ancient drainage system that consists of a network of pipes and junctions. Each junction is connected to one or more pipes, and each pipe has a defined flow capacity. Recently, the city experienced heavy rainfall, and part of the drainage system became blocked. The city engineers need your help t...
from collections import deque, defaultdict def bfs(C, F, source, sink, parent): visited = set() queue = deque([source]) visited.add(source) while queue: u = queue.popleft() for v in C[u]: if v not in visited and C[u][v] - F[u][v] > 0: # Residual capacity is po...
def test_case_1(): graph_data = [ (1, 2, 100), (2, 3, 50), (1, 3, 50), (3, 4, 100), (2, 4, 100) ] source = 1 sink = 4 assert solve_flow_problem(graph_data, source, sink) == 150 def test_case_2(): graph_data = [ (1, 2, 10), (2, 3, 5), ...
[ { "docstring": null, "function_declaration": "def bfs(C, F, source, sink, parent):", "function_name": "bfs", "parameter_list": "(C, F, source, sink, parent)" }, { "docstring": null, "function_declaration": "def max_flow(graph, source, sink):", "function_name": "max_flow", "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": "from collections import deque\n\nclass MaxFlow:\n def __init__(self, n):\n self.n = n\n self.graph = [[0] * n for _ in range(n)]\n self.sou...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010132", "row_id": 10132, "seed_ids": "[16851]" }
0.687431
Taco_10132
I
[ "bfs", "max_flow", "solve_flow_problem", "main" ]
4
[ [ "max_flow", "bfs" ], [ "solve_flow_problem", "max_flow" ] ]
2
[]
false
[]
false
pytest
false
[]
true
230cc764844d84d99d133eb22f81f8f306f3788f
e2c8ff83a1f26531673c1da49e1ea548e74344e5
v1.0
instruct
Taco
Taco_10179_I
In a certain kingdom, there's a peculiar type of tree called a MaxiTree. The uniqueness of this tree lies in its nodes' arrangement. You are given a binary tree, where each node has a value. Your task is to determine whether this binary tree is a MaxiTree. A tree is considered a MaxiTree if each node's value is the m...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes_info): nodes = {} for index, value, left, right in nodes_info: if index not in nodes: nodes[index] = TreeNode(value) else: no...
from solution import check_maxitree def test_example(): n = 5 nodes_info = [ (0, 10, 1, 2), (1, 5, -1, -1), (2, 10, 3, 4), (3, 5, -1, -1), (4, 2, -1, -1) ] assert check_maxitree(n, nodes_info) == "Yes" def test_single_node(): n = 1 nodes_info = [ ...
[]
[ 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 Node:\n def __init__(self, index, value):\n self.index = index\n self.value = value\n self.left = None\n self.right = None\n\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010179", "row_id": 10179, "seed_ids": "[11500]" }
0.617496
Taco_10179
I
[ "build_tree", "is_maxitree", "check_maxitree" ]
3
[ [ "check_maxitree", "build_tree" ], [ "check_maxitree", "is_maxitree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
d03b8f120eba4b14a73e6e45aff6dc9e0b7683d8
9ec436d572122de99b8962a8436219a6468ef87f
v1.0
instruct
Taco
Taco_10186_I
In the futuristic city of Technovia, the residents have developed an advanced system to manage their energy consumption. The city grid is represented as a tree with `n` nodes, where each node represents a different district, and each edge represents an energy conduit between two districts. The grid's central hub is at ...
from collections import deque def min_energy_loss(n, edges): # Initialize the adjacency list adjacency_list = [[] for _ in range(n + 1)] for u, v in edges: adjacency_list[u].append(v) adjacency_list[v].append(u) # Distance array to store distance from node 1 distance = [-1] * (...
from solution import min_energy_loss def test_sample_input(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] expected_output = [0, 1, 1, 2, 2] assert min_energy_loss(n, edges) == expected_output def test_single_node(): n = 1 edges = [] expected_output = [0] assert min_energy_loss(n, ed...
[ { "docstring": null, "function_declaration": "def min_energy_loss(n, edges):", "function_name": "min_energy_loss", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def energy_loss(n, edges):", "function_name": "energy_loss", "parameter_list": "(n, e...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef bfs_minimum_energy_loss(n, edges):\n # Initialize adjacency list\n adj_list = defaultdict(list)\n for u,...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010186", "row_id": 10186, "seed_ids": "[23613]" }
0.649449
Taco_10186
I
[ "min_energy_loss", "energy_loss" ]
2
[ [ "energy_loss", "min_energy_loss" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cb53dd1dc7984191414f3f7f7669b5037cddad7c
e82d0c9ec4a33d26ec0000c6e9b85806391756ce
v1.0
instruct
Taco
Taco_10190_I
In a video game, players find themselves in a grid-based maze consisting of walls and empty spaces. The player can only move up, down, left, or right and aims to reach the exit located at the bottom-right corner of the grid starting from the top-left corner. However, the maze contains traps that result in an instantane...
from collections import deque # Directions for movement: Up, Down, Left, Right DIRECTIONS = [(-1, 0), (1, 0), (0, -1), (0, 1)] def is_valid_move(r, c, R, C, maze, visited): return 0 <= r < R and 0 <= c < C and maze[r][c] != '#' and maze[r][c] != 'T' and (r, c) not in visited def can_escape_maze(maze, R, C): ...
import pytest from solution import solve_mazes def test_example_cases(): test_cases = [ (3, 3, ['...', '.#.', '..D']), (4, 4, ['.D.T', '.T..', '....', '...#']) ] expected = ['YES', 'NO'] assert solve_mazes(test_cases) == expected def test_single_cell_no_trap(): test_cases = [ ...
[ { "docstring": null, "function_declaration": "def is_valid_move(r, c, R, C, maze, visited):", "function_name": "is_valid_move", "parameter_list": "(r, c, R, C, maze, visited)" }, { "docstring": null, "function_declaration": "def can_escape_maze(maze, R, C):", "function_name": "can_es...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\n# Directions for movement: Up, Down, Left, Right\nDIRECTIONS = [(-1, 0), (1, 0), (0, -1), (0, 1)]\n\ndef is_valid_move(r, c, R, C,...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00010190", "row_id": 10190, "seed_ids": "[23165]" }
0.696399
Taco_10190
I
[ "is_valid_move", "can_escape_maze", "solve_mazes" ]
3
[ [ "can_escape_maze", "is_valid_move" ], [ "solve_mazes", "can_escape_maze" ] ]
2
[]
false
[]
false
pytest
true
[]
true
234aec384162a3b84c9ad01026157c71e89b887f
a7bd59a26251a436e255fe80ebcacb448f95ae63
v1.0
instruct
Taco
Taco_10214_I
Кate is organizing a charity event and needs to set up different activity stations. She needs to arrange n different stations linearly in such a way that certain pairs of stations must not be directly next to each other due to space constraints and safety guidelines. The pairs that must avoid adjacency are given as a l...
import itertools def is_valid(arrangement, constraints): """ Check if a given arrangement satisfies all the adjacency constraints. """ for (x, y) in constraints: for a, b in zip(arrangement, arrangement[1:]): if (a == x and b == y) or (a == y and b == x): return Fals...
from solution import arrange_stations def test_simple_case_possible(): n = 4 m = 2 constraints = [(1, 2), (3, 4)] result = arrange_stations(n, m, constraints) assert result != "No arrangement possible" assert isinstance(result, tuple) and len(result) == 4 def test_simple_case_not_possible(...
[ { "docstring": "Check if a given arrangement satisfies all the adjacency constraints.", "function_declaration": "def is_valid(arrangement, constraints):", "function_name": "is_valid", "parameter_list": "(arrangement, constraints)" }, { "docstring": "Determines if it is possible to arrange al...
[ 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 itertools\n\ndef is_valid(arrangement, constraints):\n \"\"\"\n Check if a given arrangement satisfies all the adjacency constraints.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00010214", "row_id": 10214, "seed_ids": "[770]" }
0.672682
Taco_10214
I
[ "is_valid", "arrange_stations" ]
2
[ [ "arrange_stations", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f3886341e2f50ef431d3d6c4cc3d93dcd485a73e
4fc90c7787558d7c0572d1a5b768a6b3d2651953
v1.0
instruct
Taco
Taco_10235_I
Filbert has founded a new city with a grid of houses arranged in an `n x m` matrix. Each cell in the grid has a certain number of apples. Filbert wants to host an event and collect apples from a rectangular sub-grid. Given the matrix and multiple queries where each query specifies the top-left and bottom-right corners ...
def preprocess_apples(matrix, n, m): """Preprocess the matrix to create a prefix sum matrix.""" prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): prefix_sum[i][j] = (matrix[i-1][j-1] + prefix_sum[i-1][j...
def test_preprocess_apples(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] assert preprocess_apples(matrix, 3, 3) == expected_prefix_sum def test_total_apple...
[ { "docstring": "Preprocess the matrix to create a prefix sum matrix.", "function_declaration": "def preprocess_apples(matrix, n, m):", "function_name": "preprocess_apples", "parameter_list": "(matrix, n, m)" }, { "docstring": "Calculate total apples in the subgrid using the prefix sum matrix...
[ 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 preprocess_matrix(matrix):\n \"\"\"\n Preprocesses the matrix to create a prefix sum matrix.\n \"\"\"\n n = len(matrix)\n m = len(matrix[0])\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010235", "row_id": 10235, "seed_ids": "[13438]" }
0.645838
Taco_10235
I
[ "preprocess_apples", "total_apples_in_subgrid", "collect_apples_from_queries" ]
3
[ [ "collect_apples_from_queries", "preprocess_apples" ], [ "collect_apples_from_queries", "total_apples_in_subgrid" ] ]
2
[]
false
[]
false
pytest
false
[]
true
86a726bdd690ea6f16d9044ce1fdefd5668b268a
f15895122c573677f0cc0f22ac9621e4ad4dc8b4
v1.0
instruct
Taco
Taco_10255_I
For a given string \( s \), print all unique subsets of the string in lexicographic order. Each subset should appear on a new line. Subsets can be empty or contain all characters of the string in any order, but no subset should appear more than once. Constraints * \( 1 \leq |s| \leq 12 \) * \( s \) contains only lowe...
def generate_subsets(s): """ This function generates all unique subsets of the string `s` in lexicographic order. """ subsets = set() def backtrack(start, path): # Add current subset to the set subsets.add("".join(path)) for i in range(start, len(s)): # Include t...
from solution import generate_subsets def test_generate_subsets_example1(): assert generate_subsets("abc") == ['', 'a', 'ab', 'abc', 'ac', 'b', 'bc', 'c'] def test_generate_subsets_example2(): assert generate_subsets("aab") == ['', 'a', 'aa', 'aab', 'ab', 'b'] def test_generate_subsets_single_char(): ass...
[ { "docstring": "This function generates all unique subsets of the string `s` in lexicographic order.", "function_declaration": "def generate_subsets(s):", "function_name": "generate_subsets", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def print_subsets(s):",...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef unique_subsets(s):\n \"\"\"\n Generate all unique subsets of the string in lexicographic order.\n \"\"\"\n # ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00010255", "row_id": 10255, "seed_ids": "[6064]" }
0.605499
Taco_10255
I
[ "generate_subsets", "print_subsets" ]
2
[ [ "print_subsets", "generate_subsets" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9402d604ebf19e0d7b270f7657af7c970a28c4c6
b5bdcbf3c5a4a3fe1f53703ebfe8df6c7942672d
v1.0
instruct
Taco
Taco_10258_I
You are tasked with helping Arya navigate the haunted forests of Weirwood. This forest is represented as a grid of N x M cells. Arya starts at the top-left corner of the grid and needs to reach the bottom-right corner. Each cell in the grid contains a number that represents the amount of energy required to pass through...
def min_energy_to_reach_end(grid): """ Calculate the minimum energy required to reach the bottom-right corner of the grid from the top-left corner. """ N = len(grid) M = len(grid[0]) # Initialization of a dp array to store the minimum energy required to reach each cell dp = [[0]*M f...
from solution import min_energy_to_reach_end, solve_arya_navigation, parse_input def test_min_energy_to_reach_end_single_case(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_energy_to_reach_end(grid) == 7 def test_solve_arya_navigation_single_case(): test_cases = [ ...
[ { "docstring": "Calculate the minimum energy required to reach the bottom-right corner\nof the grid from the top-left corner.", "function_declaration": "def min_energy_to_reach_end(grid):", "function_name": "min_energy_to_reach_end", "parameter_list": "(grid)" }, { "docstring": null, "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 min_energy(T, test_cases):\n results = []\n \n for test_case in test_cases:\n N, M, grid = test_case\n dp = [[0] * M for _ in range(N)]\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010258", "row_id": 10258, "seed_ids": "[7146]" }
0.656617
Taco_10258
I
[ "min_energy_to_reach_end", "solve_arya_navigation", "parse_input" ]
3
[ [ "solve_arya_navigation", "min_energy_to_reach_end" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
9d98ad063abe6bcd55d29edfe9684b116877c713
1ca3f381ea280637e3a5037be17b24cb7c6dc07f
v1.0
instruct
Taco
Taco_10337_I
Given a binary tree, determine whether the tree satisfies the property of a "spiral order". A binary tree has a spiral order if the levels of the tree are traversed alternately from left to right and right to left, starting from the root level which is traversed from left to right. Input The first line contains an int...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): if not nodes: return None n = len(nodes) if n == 0 or nodes[0] == -1: return None root = TreeNode(nodes[0]) queue = [root] index = ...
def test_check_spiral_order_trees(): from solution import check_spiral_order_trees T = 2 test_cases = [ (7, [1, 2, 3, 7, 6, 5, 4]), (7, [1, 2, 3, -1, -1, 5, 4]) ] results = check_spiral_order_trees(T, test_cases) assert results[0] == "YES" assert results[1] == "NO" def...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00010337", "row_id": 10337, "seed_ids": "[15835]" }
0.588886
Taco_10337
I
[ "build_tree", "is_spiral_order", "check_spiral_order_trees" ]
3
[ [ "check_spiral_order_trees", "build_tree" ], [ "check_spiral_order_trees", "is_spiral_order" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ab1ab24f5045575a4c56e2b2045087554faf9467
9a6426d216590215f4a626f57c98f5ec81756549
v1.0
instruct
Taco
Taco_10385_I
You are given a 2D grid of size M x N filled with non-negative integers, representing heights. Suppose you are going on a hike, and you start at the top-left corner of the grid (1, 1), and move to the bottom-right corner (M, N). You can only move up, down, left, or right each step, and you want to minimize the maximum ...
from collections import deque def is_path_possible(grid, M, N, max_diff): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] visited = [[False] * N for _ in range(M)] queue = deque([(0, 0)]) visited[0][0] = True while queue: x, y = queue.popleft() if x == M - 1 and y == N - 1: ...
from solution import is_path_possible, min_max_difference def test_sample_input(): grid = [ [1, 2, 2], [3, 8, 2], [5, 3, 5] ] assert min_max_difference(grid) == 2 def test_smaller_grid(): grid = [ [0, 1], [1, 0] ] assert min_max_difference(grid) == 1 de...
[ { "docstring": null, "function_declaration": "def is_path_possible(grid, M, N, max_diff):", "function_name": "is_path_possible", "parameter_list": "(grid, M, N, max_diff)" }, { "docstring": null, "function_declaration": "def min_max_difference(grid):", "function_name": "min_max_diffe...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from heapq import heappop, heappush\n\ndef min_max_diff(M, N, heights):\n def is_valid(x, y):\n return 0 <= x < M and 0 <= y < N\n \n directions = ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00010385", "row_id": 10385, "seed_ids": "[15612]" }
0.715969
Taco_10385
I
[ "is_path_possible", "min_max_difference", "main" ]
3
[ [ "min_max_difference", "is_path_possible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8eac0b5ee37567a69229bafde0000b8193b67874
0a430492c96c3ed105dc3c4057c17fc980bc0327
v1.0
instruct
Taco
Taco_10404_I
Consider an image represented as an n x m grid of pixels. Each pixel can be either `0` (white) or `1` (black). Suppose you want to find the largest rectangle (contiguous sub-grid) consisting entirely of black pixels. Write a function `largest_black_rectangle` that takes a binary matrix (a list of lists of integers whe...
from typing import List def largest_black_rectangle(matrix: List[List[int]]) -> int: if not matrix or not matrix[0]: return 0 n = len(matrix) m = len(matrix[0]) max_area = 0 histogram = [0] * m for row in matrix: # Update the histogram for i in range(m): ...
from solution import largest_black_rectangle def test_largest_black_rectangle_example_case(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert largest_black_rectangle(matrix) == 6 def test_largest_black_rectangle_all_zeros(): matrix...
[ { "docstring": null, "function_declaration": "def largest_black_rectangle(matrix):", "function_name": "largest_black_rectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largest_rectangle_in_histogram(heights):", "function_name": "largest_rect...
[ 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 largest_black_rectangle(matrix: List[List[int]]) -> int:\n if not matrix:\n return 0\n\n n = len(matrix)\n m = len(m...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010404", "row_id": 10404, "seed_ids": "[14390]" }
0.687079
Taco_10404
I
[ "largest_black_rectangle", "largest_rectangle_in_histogram" ]
2
[ [ "largest_black_rectangle", "largest_rectangle_in_histogram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
690b6faea82f1e51ef876e6cbcdfedff42162089
389c86f310bf5ecb634b4c2b1abe4bb446e7f7ab
v1.0
instruct
Taco
Taco_10449_I
Anant is working on a system where he needs to manage tasks with dependencies. Each task is represented with a unique identifier from 1 to N. Some tasks have dependencies, meaning that a task can only be started after specific tasks have been completed. The input consists of multiple lines; the first line contains a ...
from collections import defaultdict, deque def find_task_order(N, dependencies): # Create an adjacency list and compute in-degrees of each task adj_list = defaultdict(list) in_degree = {i: 0 for i in range(1, N+1)} for task, deps in dependencies.items(): for dep in deps: adj_list[d...
from solution import task_management def test_sample_input_1(): input_lines = [ "4", "1 2 -1", "2 3 -1", "3 4 -1", "4 -1" ] assert task_management(input_lines) == "4 3 2 1" def test_sample_input_2(): input_lines = [ "3", "1 2 -1", "2 3 -1...
[ { "docstring": null, "function_declaration": "def find_task_order(N, dependencies):", "function_name": "find_task_order", "parameter_list": "(N, dependencies)" }, { "docstring": null, "function_declaration": "def parse_input(input_lines):", "function_name": "parse_input", "parame...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef find_task_order(N, task_dependencies):\n graph = defaultdict(list)\n indegree = defaultdict(int)\n \n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00010449", "row_id": 10449, "seed_ids": "[14861]" }
0.663134
Taco_10449
I
[ "find_task_order", "parse_input", "task_management" ]
3
[ [ "task_management", "find_task_order" ], [ "task_management", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
101f42ed191d95ef8b5e6820b05e554b5054004e
3da27bec201fb0fa6c29828fbe384fa5cb94a25b
v1.0
instruct
Taco
Taco_10457_I
Aradhana loves prime numbers, and she has challenged the boys in her class to a game. She will select a number `k`, and the nth boy who wants to impress her must find the `k`th prime number. Since some of the boys are not well-versed in programming, they have asked for your help to determine the `k`th prime number effi...
def sieve_of_eratosthenes(n): """ Generates all prime numbers up to n using the sieve of Eratosthenes. """ is_prime = [True] * (n + 1) p = 2 while p * p <= n: if is_prime[p]: for i in range(p * p, n + 1, p): is_prime[i] = False p += 1 primes = [p f...
from solution import kth_prime, process_primes def test_sieve_of_eratosthenes(): from solution import sieve_of_eratosthenes assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_kth_prime(): assert kth_prime(1) == 2 assert kth_pr...
[ { "docstring": "Generates all prime numbers up to n using the sieve of Eratosthenes.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns the k-th prime number.", "function_declaration": "d...
[ 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(n):\n \"\"\"\n Returns all prime numbers up to n (inclusive) using the Sieve of Eratosthenes.\n \"\"\"\n is_prime = [True] * ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010457", "row_id": 10457, "seed_ids": "[12228]" }
0.612004
Taco_10457
I
[ "sieve_of_eratosthenes", "kth_prime", "process_primes" ]
3
[ [ "kth_prime", "sieve_of_eratosthenes" ], [ "process_primes", "kth_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0e6ab5d1e6ce7058f69969227f348ddf12868f1e
5c1ed76e5635f02e780ff5891e23d5b41171c54b
v1.0
instruct
Taco
Taco_10489_I
You are organizing a fleet of drones to monitor a series of events happening in a city. There are $n$ monitoring stations positioned in different parts of the city, each managing certain sections of the area. Each monitoring station has a set radius within which it can effectively monitor events. You are given the coo...
import math from itertools import combinations def distance(x1, y1, x2, y2): """ Calculate the Euclidean distance between two points (x1, y1) and (x2, y2) """ return math.sqrt((x1 - x2)**2 + (y1 - y2)**2) def min_stations_to_cover_events(n, m, stations, events): def can_cover_all_events(selected_s...
from solution import min_stations_to_cover_events def test_example_case(): n = 5 m = 3 stations = [(1, 1, 5), (4, 4, 2), (7, 7, 3), (10, 10, 1), (13, 13, 2)] events = [(2, 2), (6, 6), (9, 9)] assert min_stations_to_cover_events(n, m, stations, events) == 2 def test_no_stations(): n = 0 m =...
[ { "docstring": "Calculate the Euclidean distance between two points (x1, y1) and (x2, y2)", "function_declaration": "def distance(x1, y1, x2, y2):", "function_name": "distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def min_stations_to_cove...
[ 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 math\nfrom itertools import combinations\n\ndef distance(x1, y1, x2, y2):\n \"\"\"\n Calculate the Euclidean distance between two points (x1, y1) and ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00010489", "row_id": 10489, "seed_ids": "[79]" }
0.694951
Taco_10489
I
[ "distance", "min_stations_to_cover_events" ]
2
[ [ "min_stations_to_cover_events", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
15237af1aee61d38c6a8209b5b38d1ceb71d9315
c9c66bdd8b6ca4d6eabfe84e7e7f7836cfe3d26c
v1.0
instruct
Taco
Taco_10491_I
A warehouse has a grid layout of shelves with rows numbered from 1 to m and columns numbered from 1 to n. Each cell in the grid can either be empty or contain a box with certain dimensions. You need to implement a system to store the boxes in such a way that no box overlaps with any other, and each box fits within the ...
def can_place_boxes(m, n, boxes): """ Returns "YES" if all boxes can be placed on the grid without overlapping and within grid boundaries, else "NO". Parameters: m (int): Number of rows in the grid. n (int): Number of columns in the grid. boxes (list of tuples): List of boxes where each box...
from solution import can_place_boxes, solve def test_case_1(): input_data = "5 5\n3\n1 1 2 2\n3 3 1 1\n4 4 2 2\n" assert solve(input_data) == "YES" def test_case_2(): input_data = "4 4\n2\n1 1 3 3\n2 2 2 2\n" assert solve(input_data) == "NO" def test_case_3(): input_data = "10 10\n5\n1 1 1 1\n2 2...
[ { "docstring": "Returns \"YES\" if all boxes can be placed on the grid without overlapping and within grid boundaries, else \"NO\".\n\nParameters:\nm (int): Number of rows in the grid.\nn (int): Number of columns in the grid.\nboxes (list of tuples): List of boxes where each box is described by tuple (r, c, h, ...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_place_boxes(m, n, b, boxes):\n grid = [[0]*n for _ in range(m)] # Create a grid initialized with 0\n \n for box in boxes:\n r, c, h, w = bo...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00010491", "row_id": 10491, "seed_ids": "[16568]" }
0.750338
Taco_10491
I
[ "can_place_boxes", "solve" ]
2
[ [ "solve", "can_place_boxes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
307cac28ad5f2e804a773a39009c301f2366cb67
1d5d8addc1cf6a704cf6aabf618753bcda852e3c
v1.0
instruct
Taco
Taco_10527_I
Tommy the Turtle likes to play with binary trees. He has a tree with n nodes, where each node is labeled with a unique integer from 1 to n. Tommy wants to find out the number of nodes in the subtree of a specific node. Can you help Tommy? Given a binary tree with n nodes, you have to process m queries. Each query give...
class TreeNode: def __init__(self, node_id): self.node_id = node_id self.children = [] def build_tree(n, edges): nodes = [TreeNode(i) for i in range(n + 1)] for u, v in edges: nodes[u].children.append(nodes[v]) nodes[v].children.append(nodes[u]) return nodes def calcula...
from solution import subtree_sizes def test_case_1(): n = 5 edges = [(1, 2), (1, 3), (3, 4), (3, 5)] m = 3 queries = [1, 3, 4] assert subtree_sizes(n, edges, m, queries) == [5, 3, 1] def test_single_node(): n = 1 edges = [] m = 1 queries = [1] assert subtree_sizes(n, edges, m, ...
[]
[ 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 defaultdict\n\ndef subtree_sizes(n, edges, queries):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010527", "row_id": 10527, "seed_ids": "[3042]" }
0.614743
Taco_10527
I
[ "build_tree", "calculate_subtree_sizes", "subtree_sizes" ]
3
[ [ "subtree_sizes", "build_tree" ], [ "subtree_sizes", "calculate_subtree_sizes" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
b465739feb425e83130deb3beb4b824edd70765f
2b38267db285a92b06b3de03313adb679c86b71b
v1.0
instruct
Taco
Taco_10547_I
Write a function that takes an integer array as input and returns an array with all the prime numbers replaced by their squares. For example: Input: [2, 3, 4, 5, 6, 7, 8, 9, 10] Output: [4, 9, 4, 25, 6, 49, 8, 9, 10] Note: The function should identify prime numbers and replace them with their squares only. Non-prim...
import math def is_prime(n): """ Checks if a number is a 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 def replace_pr...
from solution import replace_primes_with_squares def test_replace_primes_with_squares(): # Test case 1: Example given in the prompt assert replace_primes_with_squares([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [4, 9, 4, 25, 6, 49, 8, 9, 10] # Test case 2: Array with no prime numbers assert replace_primes_wi...
[ { "docstring": "Checks if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Replaces all prime numbers in the array with their squares.", "function_declaration": "def replace_primes_with_squares(arr)...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010547", "row_id": 10547, "seed_ids": "[8811]" }
0.520731
Taco_10547
I
[ "is_prime", "replace_primes_with_squares" ]
2
[ [ "replace_primes_with_squares", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
46bfcd13ce06321d42d10aab9c93f717c7e56a36
84dc34f589057795fe23f8776b502881b59d7b8c
v1.0
instruct
Taco
Taco_10549_I
Write a function that takes a list of integers and returns a list of booleans indicating whether each integer is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Example 1: Input: arr = [2, 3, 4, 5, 6] Output: [True, True, False, True, False] Expl...
import math def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return Fals...
from solution import isPrimeList def test_is_prime_list_example_1(): assert isPrimeList([2, 3, 4, 5, 6]) == [True, True, False, True, False] def test_is_prime_list_example_2(): assert isPrimeList([10, 13, 17, 19, 20]) == [False, True, True, True, False] def test_is_prime_list_single_prime(): assert isPri...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of booleans indicating whether each integer in the input list is a prime 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 is_prime(n):\n \"\"\"\n Helper function to determine if a number is a prime number.\n :param n: Integer\n :return: Boolean - True if n is a prime n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010549", "row_id": 10549, "seed_ids": "[25361]" }
0.736885
Taco_10549
I
[ "is_prime", "isPrimeList" ]
2
[ [ "isPrimeList", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
65da02cf714e3e675a01649101478223db7911c7
fe91d1fd30ff7654be87be5d89799f0d8cc3d55b
v1.0
instruct
Taco
Taco_10624_I
Given an array of strings `words` and a string `pattern`, return a list of words from the array that match the given pattern. A word matches the pattern if there exists a bijection from the letters in the pattern to the letters in the word such that transforming all occurrences of the same letter in the pattern to the ...
def match_pattern(word, pattern): if len(word) != len(pattern): return False map_word_to_pattern = {} map_pattern_to_word = {} for w, p in zip(word, pattern): if w not in map_word_to_pattern: map_word_to_pattern[w] = p if p not in map_pattern_to_word: ma...
from solution import find_and_replace_pattern, match_pattern def test_simple_patterns(): words = ["abc", "deq", "mee", "aqq", "dkd", "ccc"] pattern = "abb" assert find_and_replace_pattern(words, pattern) == ["mee", "aqq"] def test_single_letter_pattern(): words = ["a", "b", "c"] pattern = "a" ...
[ { "docstring": null, "function_declaration": "def match_pattern(word, pattern):", "function_name": "match_pattern", "parameter_list": "(word, pattern)" }, { "docstring": null, "function_declaration": "def find_and_replace_pattern(words, pattern):", "function_name": "find_and_replace_...
[ 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 match_pattern(word, pattern):\n if len(word) != len(pattern):\n return False\n\n map_word_to_pattern = {}\n map_pattern_to_word = {}\n\n for...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00010624", "row_id": 10624, "seed_ids": "[16393]" }
0.718634
Taco_10624
I
[ "match_pattern", "find_and_replace_pattern" ]
2
[ [ "find_and_replace_pattern", "match_pattern" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa5057b39362b913f5b12e2e9bc14525a2ce22c2
ed6636359041ece7942d48a69007582b29c50ebc
v1.0
instruct
Taco
Taco_10716_I
Nina loves solving puzzles, especially those that involve prime numbers. She recently stumbled upon an interesting puzzle and wants you to help her solve it. The puzzle works with a grid that contains various numbers. Nina's task is to find the largest prime number within the grid. A prime number is a natural number g...
def is_prime(num): if num <= 1: return False if num == 2 or num == 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def largest_prime_...
from solution import is_prime, largest_prime_in_grid, solve 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(100) == False def test_largest_prime_in_grid(): assert largest_prime_in_grid([[8, 23, 1...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def largest_prime_in_grid(grid):", "function_name": "largest_prime_in_grid", "parameter_list": "(grid)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010716", "row_id": 10716, "seed_ids": "[16727]" }
0.619408
Taco_10716
I
[ "is_prime", "largest_prime_in_grid", "solve" ]
3
[ [ "largest_prime_in_grid", "is_prime" ], [ "solve", "largest_prime_in_grid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fb008ef20936df9099995b3de8ca9c486a6e17d2
6f938696496ce0fe451e0080df0c8d3b21d35d4f
v1.0
instruct
Taco
Taco_10733_I
A company requires a system that validates employee identification codes. Each ID code has specific rules that need to be checked. Your task is to write a function that validates these codes and determines if they meet the company's standards. -----Input:----- - First line will contain $N$, the number of employee ID ...
import re def validate_id_code(id_code): """ Checks if the given ID code is valid based on the specified criteria. """ if len(id_code) != 8: return "Invalid" has_upper = re.search(r'[A-Z]', id_code) is not None has_lower = re.search(r'[a-z]', id_code) is not None has_digit = re...
from solution import validate_id_code, validate_id_codes def test_validate_id_code_all_criteria_met(): assert validate_id_code("A1!bCdef") == "Valid" def test_validate_id_code_missing_uppercase(): assert validate_id_code("a1!bcdef") == "Invalid" def test_validate_id_code_missing_lowercase(): assert v...
[ { "docstring": "Checks if the given ID code is valid based on the specified criteria.", "function_declaration": "def validate_id_code(id_code):", "function_name": "validate_id_code", "parameter_list": "(id_code)" }, { "docstring": "Given a list of ID codes, returns a list indicating which co...
[ 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 validate_id_codes(n, id_codes):\n \"\"\"\n This function validates employee ID codes based on specified criteria:\n - Must be exactly 8 characters lon...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010733", "row_id": 10733, "seed_ids": "[20095]" }
0.668451
Taco_10733
I
[ "validate_id_code", "validate_id_codes" ]
2
[ [ "validate_id_codes", "validate_id_code" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f72c573e6cf962c62d9c0c543702dca791df754d
8fa5323a22602bb5dac7c4cefa7b5b345a5b84c2
v1.0
instruct
Taco
Taco_10757_I
You are given a list of strings. Each string in the list represents a mathematical arithmetic expression containing integers and the operators `+`, `-`, `*`, and `/` (without brackets). You need to evaluate the expression for each string and return their results as a list of integers. Assume all operations are integer ...
def evaluate_expression(expression): """ Evaluate a single mathematical expression string containing integers and the operators +, -, *, /. Drop decimal part in division results and return 0 for division by zero. """ try: # Remove spaces expression = expression.replace(' ', '') ...
import pytest from solution import evaluate_expressions def test_evaluate_expressions_basic(): expressions = ["3 + 5", "10 - 2 * 2", "18 / 3 + 4", "15 / 0"] assert evaluate_expressions(expressions) == [8, 6, 10, 0] def test_evaluate_expressions_with_spaces(): expressions = [" 3 + 5 ", " 10 - 2 * 2 ", " 1...
[ { "docstring": "Evaluate a single mathematical expression string containing integers and the operators +, -, *, /.\nDrop decimal part in division results and return 0 for division by zero.", "function_declaration": "def evaluate_expression(expression):", "function_name": "evaluate_expression", "para...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def evaluate_expression(expression):\n \"\"\"\n Evaluates a mathematical expression containing integers and +, -, *, /\n operators. Assumes all operations...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010757", "row_id": 10757, "seed_ids": "[6232]" }
0.673706
Taco_10757
I
[ "evaluate_expression", "evaluate_expressions" ]
2
[ [ "evaluate_expressions", "evaluate_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a6fb8f1b5b5fbb04777069b4678594ebf04f8b46
e2ed017b1763b74c4081f447fb7653f3495e8299
v1.0
instruct
Taco
Taco_10800_I
Heidi has discovered a maze in her quest to track down the Zombie King. The maze is represented as a grid of cells, where each cell is either open (represented by '.') or blocked (represented by '#'). Heidi starts at the top-left corner of the maze and wants to reach the bottom-right corner. She can move up, down, left...
from collections import deque def shortest_path(maze, M, N): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] queue = deque([(0, 0, 0)]) # (row, col, distance) visited = set((0, 0)) while queue: x, y, dist = queue.popleft() if (x, y) == (M - 1, N - 1): return d...
def test_read_input(): input_data = '6 5\n.....\n.#.#.\n.#...\n.####\n.....\n.#...\n3 3\n.#.\n.#.\n.#.\n0 0\n' expected_mazes = [ {'M': 6, 'N': 5, 'grid': [['.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '#', '.', '.', '.'], ['.', '#', '#', ...
[ { "docstring": null, "function_declaration": "def shortest_path(maze, M, N):", "function_name": "shortest_path", "parameter_list": "(maze, M, N)" }, { "docstring": null, "function_declaration": "def solve_mazes(mazes):", "function_name": "solve_mazes", "parameter_list": "(mazes)"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_maze(M, N, maze):\n def is_valid(x, y):\n return 0 <= x < M and 0 <= y < N and maze[x][y] == '.'\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010800", "row_id": 10800, "seed_ids": "[3222]" }
0.704272
Taco_10800
I
[ "shortest_path", "solve_mazes", "read_input", "main" ]
4
[ [ "solve_mazes", "shortest_path" ] ]
1
[ "read_input" ]
false
[]
false
pytest
false
[]
true
795c11e4b6307bdaa8a1ed66907a5442799c0ff1
cab760f188744f3f2b4db53828f98429e6912263
v1.0
instruct
Taco
Taco_10825_I
In this problem, you need to determine if a string can be split into exactly **three** non-empty palindromic substrings. A **palindrome** is a word that reads the same backward as forward, for example, `madam`, `racecar`, `a`, etc. Given a string `s`, check if it is possible to partition `s` into three non-empty subs...
def is_palindrome(sub): """ Checks if a given string is a palindrome. """ return sub == sub[::-1] def canSplitIntoThreePalindromicSubstrings(s): """ Determines if the string s can be split into exactly three non-empty palindromic substrings. """ n = len(s) # Loop through p...
from solution import canSplitIntoThreePalindromicSubstrings def test_example_case_1(): assert canSplitIntoThreePalindromicSubstrings("abacaba") == True def test_example_case_2(): assert canSplitIntoThreePalindromicSubstrings("abcd") == False def test_single_character(): assert canSplitIntoThreePalindromi...
[ { "docstring": "Checks if a given string is a palindrome.", "function_declaration": "def is_palindrome(sub):", "function_name": "is_palindrome", "parameter_list": "(sub)" }, { "docstring": "Determines if the string s can be split into exactly three non-empty \npalindromic substrings.", "...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(sub):\n return sub == sub[::-1]\n\ndef canSplitIntoThreePalindromicSubstrings(s):\n n = len(s)\n for i in range(1, n):\n for j in...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00010825", "row_id": 10825, "seed_ids": "[21841]" }
0.738494
Taco_10825
I
[ "is_palindrome", "canSplitIntoThreePalindromicSubstrings" ]
2
[ [ "canSplitIntoThreePalindromicSubstrings", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfabcfa65382d1ee5629843d801fd7c7fc504d74
fda4ee1b46bede497e1db4669af8196e4505d89e
v1.0
instruct
Taco
Taco_10838_I
You are tasked to write a program that converts times from a 24-hour format (also known as military time) to a 12-hour format with "AM" and "PM" annotations. The 24-hour formatted time is in the format HH:MM, where HH is an integer between 00 and 23 inclusive, and MM is an integer between 00 and 59 inclusive. In the...
def convert_24_to_12(hour_minute): """ Converts a given time from 24-hour format to 12-hour format with AM/PM. Args: hour_minute (str): A string representing time in 24-hour format "HH:MM" Returns: str: A string representing time in 12-hour format with AM/PM """ hh, mm = map(in...
from solution import convert_24_to_12, convert_multiple_times def test_convert_24_to_12(): assert convert_24_to_12("00:15") == "12:15 AM" assert convert_24_to_12("11:30") == "11:30 AM" assert convert_24_to_12("12:00") == "12:00 PM" assert convert_24_to_12("13:45") == "1:45 PM" assert convert_24_to_...
[ { "docstring": "Converts a given time from 24-hour format to 12-hour format with AM/PM.\n\nArgs:\nhour_minute (str): A string representing time in 24-hour format \"HH:MM\"\n\nReturns:\nstr: A string representing time in 12-hour format with AM/PM", "function_declaration": "def convert_24_to_12(hour_minute):"...
[ 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 convert_time_to_12_hour_format(times):\n converted_times = []\n for time in times:\n hh, mm = map(int, time.split(\":\"))\n period = \"AM\"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010838", "row_id": 10838, "seed_ids": "[16804]" }
0.665977
Taco_10838
I
[ "convert_24_to_12", "convert_multiple_times" ]
2
[ [ "convert_multiple_times", "convert_24_to_12" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa7b5981c4922e0ca80e444b2f1e9fb0f2a4e906
da23fd4ef61b1609e96dfcf2a05b1b223e7edb82
v1.0
instruct
Taco
Taco_10881_I
A palindrome is a sequence that reads the same backwards as forwards. A numeric palindrome is simply a number that is a palindrome. For example, 121 is a palindrome, but 123 is not. ## Task Write a function `nextPalindrome` that finds the smallest numeric palindrome that is greater than a given number. The input wil...
def is_palindrome(n): """ Helper function to check if a number is a palindrome. """ return str(n) == str(n)[::-1] def nextPalindrome(n): """ Returns the smallest numeric palindrome greater than the given number `n`. """ m = n + 1 while not is_palindrome(m): m += 1 return...
from solution import nextPalindrome def test_nextPalindrome_basic(): assert nextPalindrome(123) == 131 assert nextPalindrome(9) == 11 def test_nextPalindrome_edge(): assert nextPalindrome(0) == 1 assert nextPalindrome(10) == 11 def test_nextPalindrome_large_number(): assert nextPalindrome(999...
[ { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Returns the smallest numeric palindrome greater than the given number `n`.", "function_dec...
[ 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(n):\n str_n = str(n)\n return str_n == str_n[::-1]\n\ndef nextPalindrome(n):\n while True:\n n += 1\n if is_palindrome(n):...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010881", "row_id": 10881, "seed_ids": "[7234]" }
0.808035
Taco_10881
I
[ "is_palindrome", "nextPalindrome" ]
2
[ [ "nextPalindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20447ab58525a5e73a6c710fed1868002a69cbff
b0684cc73f60813a85a3f9659b4ef1de6a7c1c69
v1.0
instruct
Taco
Taco_10925_I
A programmer working on a project requires a balanced binary tree (AVL tree) for efficient insertion, deletion, and lookup operations. However, after handling a number of updates, the tree can become imbalanced. Your task is to write a function that checks if a given binary tree is an AVL tree, which means it has to sa...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): if not nodes: return None node_dict = {} for node in nodes: value, left, right = node if value not in node_dict: ...
import pytest from solution import is_avl_tree def test_is_avl_tree_1(): n = 5 nodes = [ (10, 5, 15), (5, -1, 7), (15, 12, 20), (7, -1, -1), (20, -1, -1), (12, -1, -1) ] assert is_avl_tree(n, nodes) == "YES" def test_is_avl_tree_2(): n = 3 nodes...
[]
[ 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_avl_tree(tree):\n n = tree[0][0] # Number of nodes in the tree\n if n == 0:\n return \"YES\"\n \n from collections import defaultdict, d...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010925", "row_id": 10925, "seed_ids": "[8365]" }
0.772171
Taco_10925
I
[ "build_tree", "is_balanced", "is_avl_tree" ]
3
[ [ "is_avl_tree", "build_tree" ], [ "is_avl_tree", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3d2a5667433aa62f91d920d0cbb0fe382a63f79f
2e5460fdba946d1adec4bf3a7da1572449c1c0f3
v1.0
instruct
Taco
Taco_10930_I
In a company, employees are organized hierarchically, meaning there is a single root employee (the CEO) and every other employee has exactly one direct manager. Each employee is represented by an integer ID from 1 to N, where 1 is always the CEO. You are given a list of pairs representing the direct report relationship...
import sys from collections import defaultdict, deque def dfs(node, parent, depth, adjList, depths, parents): """ Depth First Search to populate depth and parent information for each node. """ depths[node] = depth parents[node] = parent for neighbor in adjList[node]: if neighbor != pare...
from solution import build_lca, lca def test_example1(): adjList = { 1: [2, 3], 2: [1, 4, 5], 3: [1, 6, 7], 4: [2], 5: [2], 6: [3], 7: [3] } N = 7 depths, dp = build_lca(N, adjList) assert lca(4, 5, depths, dp) == 2 assert lca(6, 7, depths...
[ { "docstring": "Depth First Search to populate depth and parent information for each node.", "function_declaration": "def dfs(node, parent, depth, adjList, depths, parents):", "function_name": "dfs", "parameter_list": "(node, parent, depth, adjList, depths, parents)" }, { "docstring": "Prepr...
[ 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 collections import defaultdict\nimport sys\nsys.setrecursionlimit(100000)\n\ndef preprocess_lca(employees, N):\n log = 16 # because 2^16 > 10^5\n paren...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00010930", "row_id": 10930, "seed_ids": "[18181]" }
0.596494
Taco_10930
I
[ "dfs", "build_lca", "lca", "process_input" ]
4
[ [ "build_lca", "dfs" ], [ "process_input", "build_lca" ], [ "process_input", "lca" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
e4e6a6b1e8cd45d288771b17ba678165fd5150e0
8c3c3b859ded7faafb86753eb41fd8e0c672eebf
v1.0
instruct
Taco
Taco_10935_I
After a hurricane hit the coastal town, rescue teams are trying to reach several villages that are connected by a series of roads. Villages are represented as nodes in a graph, and roads are directed edges connecting these nodes. Each road has a time associated with it, indicating how long it takes to travel between tw...
import heapq def dijkstra(n, adj_list): """ Dijkstra's algorithm to find the shortest path from the source node to all other nodes in the given graph represented by adjacency list. """ dist = [float('inf')] * (n + 1) dist[1] = 0 pq = [(0, 1)] while pq: current_dist, u = heapq.he...
from solution import shortest_times def test_example_case(): n = 6 m = 7 roads = [ (1, 2, 4), (1, 3, 2), (2, 3, 5), (2, 4, 10), (3, 5, 3), (4, 5, 4), (5, 6, 11) ] queries = [4, 5, 6] assert shortest_times(n, m, roads, queries) == [14, 5, 1...
[ { "docstring": "Dijkstra's algorithm to find the shortest path from the source node to all other nodes\nin the given graph represented by adjacency list.", "function_declaration": "def dijkstra(n, adj_list):", "function_name": "dijkstra", "parameter_list": "(n, adj_list)" }, { "docstring": n...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n distances = [float('inf')] * (n+1)\n distances[start] = 0\n pq = [(0, start)]\n \n while pq:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00010935", "row_id": 10935, "seed_ids": "[18537]" }
0.737747
Taco_10935
I
[ "dijkstra", "shortest_times" ]
2
[ [ "shortest_times", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd4d8f97c8afdbfe6ac4859bdfe69bb6fc2440b6
509c66617e9c41908fdd6d1e9337ba4d97e0fc65
v1.0
instruct
Taco
Taco_10963_I
Determine Sudoku Validity A Sudoku board is a 9x9 grid where each row, column, and 3x3 sub-grid must contain the digits 1 through 9 exactly once. You need to write a program that verifies if a given completed Sudoku board is valid. Input The input consists of multiple lines, each line representing a Sudoku board in...
def is_valid_sudoku(board): def is_valid_block(block): return sorted(block) == list('123456789') for row in range(9): if not is_valid_block([board[row * 9 + col] for col in range(9)]): return False for col in range(9): if not is_valid_block([board[row * 9 + col] for ...
def test_is_valid_sudoku(): valid_sudoku = "295743861431865927876192543387459216612387495549216738763524189928671354154938672" invalid_sudoku = "195743862431865927876192543387459216612387495549216738763524189928671354254938671" assert is_valid_sudoku(valid_sudoku) == True assert is_valid_sudoku(inv...
[ { "docstring": null, "function_declaration": "def is_valid_sudoku(board):", "function_name": "is_valid_sudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def validate_sudoku_boards():", "function_name": "validate_sudoku_boards", "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": "def is_valid_sudoku(board):\n \"\"\"\n Verifies if the given Sudoku board is valid.\n \"\"\"\n def is_valid_group(group):\n return set(group) ==...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00010963", "row_id": 10963, "seed_ids": "[12604]" }
0.654957
Taco_10963
I
[ "is_valid_sudoku", "validate_sudoku_boards" ]
2
[ [ "validate_sudoku_boards", "is_valid_sudoku" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2b2a8da4b3f03570365e134d95d8ed5a764039c5
1f2adb4d14fa9d3b5b491fa8d6f71b8719a158c0
v1.0
instruct
Taco
Taco_10972_I
In the kingdom of Algorithmia, there are N cities connected by M bidirectional roads. Each road connects two distinct cities and has a certain travel time associated with it. The king wants to ensure that all his cities are well connected, and he has selected certain pairs of cities to be directly connected by new road...
import heapq def dijkstra(start, graph, N): """ Implements Dijkstra's algorithm to find the shortest paths from the start node to all other nodes :param start: Starting node :param graph: Adjacency list of the graph :param N: Number of nodes :return: List of shortest distances from start to all...
def test_will_new_road_reduce_travel_time(): N = 5 M = 6 existing_roads = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 2), ] K = 3 new_roads = [ (1, 5, 4), (2, 5, 6), (1, 4, 5), ] expected = ["YES"...
[ { "docstring": "Implements Dijkstra's algorithm to find the shortest paths from the start node to all other nodes\n:param start: Starting node\n:param graph: Adjacency list of the graph\n:param N: Number of nodes\n:return: List of shortest distances from start to all other nodes", "function_declaration": "d...
[ 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": "import heapq\n\ndef dijkstra(graph, start, N):\n \"\"\"\n Performs the Dijkstra's algorithm to find the shortest paths from the start node to all other nodes...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00010972", "row_id": 10972, "seed_ids": "[12147]" }
0.8099
Taco_10972
I
[ "dijkstra", "will_new_road_reduce_travel_time" ]
2
[ [ "will_new_road_reduce_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0ad26764a44915136ddc5083980eacae93fcf1bb
3b7bbec854b6c17fb3331d6ee64d97cbe4f341e8
v1.0
instruct
Taco
Taco_10987_I
Read problems statements in Mandarin Chinese and Russian. Chef is working with strings and needs your help with a problem involving cyclic shifts. A cyclic shift of a string is obtained by moving some (possibly zero) characters from the beginning of the string to the end, in the same order. For example, the cyclic s...
def is_palindrome(s): return s == s[::-1] def longest_palindromic_substring(S): N = len(S) max_len = 0 # Generate all cyclic shifts for i in range(N): shifted = S[i:] + S[:i] # Check all possible substrings for start in range(N): for end in range(start + 1, ...
from solution import longest_palindromic_substring def test_example_case(): assert longest_palindromic_substring("ababa") == 5 def test_single_character(): assert longest_palindromic_substring("a") == 1 def test_no_palindrome_longer_than_one(): assert longest_palindromic_substring("abcdefg") == 1 def te...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def longest_palindromic_substring(S):", "function_name": "longest_palindromic_substring", "parameter_li...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n return s == s[::-1]\n\ndef longest_palindromic_substring_length(s):\n n = len(s)\n max_len = 0\n for i in range(n):\n cy...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00010987", "row_id": 10987, "seed_ids": "[10473]" }
0.65459
Taco_10987
I
[ "is_palindrome", "longest_palindromic_substring" ]
2
[ [ "longest_palindromic_substring", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef0b219a0c70e410647381c52748d5d31b551b26
943dcc0b2f6cac367746d366257d8f6d06cb5659
v1.0
instruct
Taco
Taco_10995_I
In a certain land called Byteland, there are many cities, each connected by roads. The king of Byteland wants to improve the transportation system between cities by connecting each city with high-speed railways. However, due to budget constraints, the king wants to minimize the total cost of constructing the railways. ...
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] ...
from solution import connect_cities_from_input def test_example_1(): input_str = "4 5\n1 2 1\n1 3 4\n2 3 2\n2 4 7\n3 4 3\n" assert connect_cities_from_input(input_str) == 6 def test_example_2(): input_str = "4 1\n1 2 10\n" assert connect_cities_from_input(input_str) == -1 def test_no_edges(): inp...
[ { "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": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00010995", "row_id": 10995, "seed_ids": "[9719]" }
0.774816
Taco_10995
I
[ "find", "union", "minimum_cost_to_connect_cities", "connect_cities_from_input" ]
4
[ [ "connect_cities_from_input", "minimum_cost_to_connect_cities" ], [ "minimum_cost_to_connect_cities", "find" ], [ "minimum_cost_to_connect_cities", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
73010314b3e77bdebdde800765d13bbc56b11286
6bf705cfe629a084997664e15e71970f731c82ae
v1.0
instruct
Taco
Taco_11039_I
In a village named Codeville, the villagers love playing with numbers. They are particularly fond of sequences where each number is the sum of the cubes of its digits. To entertain themselves, they decided to create a special function $G(n)$, denoted as $G(n) = n + f(n)$, where $f(n)$ is the sum of the cubes of the dig...
def sum_of_cubes_of_digits(n): return sum(int(digit)**3 for digit in str(n)) def G(n): return n + sum_of_cubes_of_digits(n) def find_kth_term(X, k): term = X for _ in range(1, k): term = G(term) return term def solve_multiple_cases(cases): results = [] for X, k in cases: r...
def test_sum_of_cubes_of_digits(): assert sum_of_cubes_of_digits(123) == 36 assert sum_of_cubes_of_digits(456) == 405 assert sum_of_cubes_of_digits(0) == 0 assert sum_of_cubes_of_digits(9) == 729 def test_G(): assert G(5) == 130 # 5 + 5^3 assert G(89) == 1330 # 89 + (8^3 + 9^3) assert G(133...
[ { "docstring": null, "function_declaration": "def sum_of_cubes_of_digits(n):", "function_name": "sum_of_cubes_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def G(n):", "function_name": "G", "parameter_list": "(n)" }, { "docstring": n...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_cubes_of_digits(n):\n return sum(int(digit)**3 for digit in str(n))\n\ndef G(n):\n return n + sum_of_cubes_of_digits(n)\n\ndef find_kth_term(X, k)...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00011039", "row_id": 11039, "seed_ids": "[3041]" }
0.668906
Taco_11039
I
[ "sum_of_cubes_of_digits", "G", "find_kth_term", "solve_multiple_cases", "main" ]
5
[ [ "G", "sum_of_cubes_of_digits" ], [ "find_kth_term", "G" ], [ "solve_multiple_cases", "find_kth_term" ] ]
3
[ "solve_multiple_cases" ]
false
[]
false
pytest
false
[]
true
d3eebd7067318b5fea0afe434e5d62464b264d09
bd63ebea5fca3099a6ac72cbac54277d25106eb9
v1.0
instruct
Taco
Taco_11092_I
In a city grid, you start at the top-left corner (1, 1) and need to reach the bottom-right corner (n, m). However, some cells in the grid contain mud and are harder to pass through. Each cell contains an integer representing the energy required to pass through it. You can move in four directions: up, down, left, and ri...
import heapq def min_energy_path(grid): n = len(grid) m = len(grid[0]) directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] def is_valid(x, y): return 0 <= x < n and 0 <= y < m pq = [(grid[0][0], 0, 0)] min_cost = [[float('inf')] * m for _ in range(n)] min_cost[0][0] = grid...
def test_min_energy_path_example_1(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_energy_path(grid) == 7 def test_min_energy_path_example_2(): grid = [ [2, 2], [1, 1] ] assert min_energy_path(grid) == 4 def test_min_energy_path_single_cell(): ...
[ { "docstring": null, "function_declaration": "def min_energy_path(grid):", "function_name": "min_energy_path", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def parse_grid_and_calculate_min_energy(n, m, grid_values):", "function_name": "parse_grid_and_ca...
[ 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 min_energy_required(n, m, grid):\n \"\"\"\n Returns the minimum energy required to reach the bottom-right corner from the top-left corner...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00011092", "row_id": 11092, "seed_ids": "[1169]" }
0.708723
Taco_11092
I
[ "min_energy_path", "parse_grid_and_calculate_min_energy" ]
2
[ [ "parse_grid_and_calculate_min_energy", "min_energy_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0cec688452a09fef7a38affe173985c0fabd3fc5
3ff08baebeb54b17d3c00fb8a1c5444d4a016211
v1.0
instruct
Taco
Taco_11129_I
You are given a tree with \(N\) nodes, where each node is identified by a number from 1 to \(N\). Each edge in the tree has a positive integer weight associated with it. Your task is to find the longest path in the tree, where the length of a path is defined as the sum of the weights of the edges along the path. ###...
from collections import defaultdict, deque def find_longest_path(N, edges): def bfs(start): dist = [-1] * (N + 1) dist[start] = 0 queue = deque([start]) farthest_node = start max_dist = 0 while queue: node = queue.popleft() for neighb...
from solution import longest_path_in_tree def test_longest_path_example1(): N = 3 edges = [ (1, 2, 3), (2, 3, 4) ] assert longest_path_in_tree(N, edges) == 7 def test_longest_path_example2(): N = 5 edges = [ (1, 2, 1), (2, 3, 2), (2, 4, 3), (4, 5...
[ { "docstring": null, "function_declaration": "def find_longest_path(N, edges):", "function_name": "find_longest_path", "parameter_list": "(N, edges)" }, { "docstring": "Returns the length of the longest path in a tree with N nodes and given edges.", "function_declaration": "def longest_p...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef find_furthest_node(start, graph):\n \"\"\"\n Perform BFS to find the furthest node from the given start nod...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00011129", "row_id": 11129, "seed_ids": "[16009]" }
0.71289
Taco_11129
I
[ "find_longest_path", "longest_path_in_tree" ]
2
[ [ "longest_path_in_tree", "find_longest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bf62ccbc3e13a1cc724bf1112205d764a0b50bcf
bede10777763f537c2de826d451a4e1eb1080ce0
v1.0
instruct
Taco
Taco_11174_I
A group of researchers is planning an experiment in a special laboratory that contains n chambers connected by non-directional pipes. Each chamber has a unique security level s, and each pipe has a length l and a security restriction r, denoting the minimum security level required to pass through the pipe. The pipes fo...
import heapq def read_input(): n, q = map(int, input().split()) security_levels = list(map(int, input().split())) edges = [] for _ in range(n - 1): a, b, l = map(int, input().split()) a -= 1 b -= 1 security_restriction = min(security_levels[a], security_levels[b]) ...
def test_dijkstra_max_security(): n = 5 edges = [ (0, 1, 3, 1), (1, 2, 2, 1), (2, 3, 5, 4), (3, 4, 7, 2) ] start = 0 result = dijkstra_max_security(n, edges, start) assert result == [0, 1, 1, 4, 4] def test_solve_transport_operations(): n, q = 5, 3 securi...
[ { "docstring": null, "function_declaration": "def read_input():", "function_name": "read_input", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def dijkstra_max_security(n, edges, start):", "function_name": "dijkstra_max_security", "parameter_list": "(n, ...
[ 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": "import heapq\n\ndef max_security_level_on_shortest_path(n, q, security_levels, pipes, transport_operations):\n def dijkstra_max_security(n, start, adj_list):\n ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00011174", "row_id": 11174, "seed_ids": "[2788]" }
0.673297
Taco_11174
I
[ "read_input", "dijkstra_max_security", "solve_transport_operations" ]
3
[ [ "solve_transport_operations", "dijkstra_max_security" ], [ "solve_transport_operations", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
false
[]
true
f26b5a1f44b67f27e7b04723b96b03791f1b9b2d
524573c8494ac655062caef6ab7254e5a121d74f
v1.0
instruct
Taco
Taco_11199_I
**You are given a list of intervals where each interval represents a meeting and consists of a start time and an end time. Your task is to determine if a person can attend all the meetings without any overlapping. If it is possible for the person to attend all the meetings, return "YES", otherwise return "NO". Input F...
def can_attend_all_meetings(test_cases): results = [] for case in test_cases: intervals = case["intervals"] # Sort intervals by start time intervals.sort(key=lambda x: x[0]) # Check for any overlap for i in range(1, len(intervals)): if intervals[i][0]...
from solution import meetings_scheduler def test_meetings_scheduler_single_test_case_no_overlap(): input_str = "1\n3\n1 3\n3 5\n5 6" expected_output = "YES" assert meetings_scheduler(input_str) == expected_output def test_meetings_scheduler_single_test_case_with_overlap(): input_str = "1\n2\n1 4\n3 5"...
[ { "docstring": null, "function_declaration": "def can_attend_all_meetings(test_cases):", "function_name": "can_attend_all_meetings", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "pa...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_attend_all_meetings(test_cases):\n results = []\n \n for meetings in test_cases:\n meetings.sort(key=lambda x: x[0])\n \n for...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00011199", "row_id": 11199, "seed_ids": "[6853]" }
0.698853
Taco_11199
I
[ "can_attend_all_meetings", "parse_input", "format_output", "meetings_scheduler" ]
4
[ [ "meetings_scheduler", "can_attend_all_meetings" ], [ "meetings_scheduler", "format_output" ], [ "meetings_scheduler", "parse_input" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
c56b77463d0e54fd936ba56bc1cc70eefc345406
36cc71209794b5fde9e2490a53031d659ef8a02e
v1.0
instruct
Taco
Taco_11216_I
You are working as a software developer for SynthWave Technologies, a company specializing in authentication security systems. Your next project involves creating a system that validates passwords according to specific company requirements. You are provided with a set of rules that a valid password must satisfy. A val...
import re def validate_password(password): if len(password) < 8: return "Invalid" if not re.search(r'[A-Z]', password): return "Invalid" if not re.search(r'[a-z]', password): return "Invalid" if not re.search(r'[0-9]', password): return "Invalid" if not re.search(r'[...
from solution import validate_passwords, validate_password def test_single_valid_password(): assert validate_password("Abcd1234!") == "Valid" def test_single_invalid_password_length(): assert validate_password("Abc12!") == "Invalid" def test_single_invalid_password_no_uppercase(): assert validate_passwor...
[ { "docstring": null, "function_declaration": "def validate_password(password):", "function_name": "validate_password", "parameter_list": "(password)" }, { "docstring": null, "function_declaration": "def validate_passwords(passwords):", "function_name": "validate_passwords", "para...
[ 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 re\n\ndef validate_passwords(passwords):\n \"\"\"\n Validates a list of passwords based on the specific company's rules.\n \n Args:\n passwor...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00011216", "row_id": 11216, "seed_ids": "[7861]" }
0.639517
Taco_11216
I
[ "validate_password", "validate_passwords" ]
2
[ [ "validate_passwords", "validate_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc570aab7605f27355f181502d7c01f7957e0a07
d36f1ad397bc818de9dfa10ea88eec8461dca9b9
v1.0
instruct
Taco
Taco_11273_I
Alice is a big fan of puzzles. Recently, she discovered a new puzzle that involves strings and their beauty. The beauty of a string is determined by the number of distinct subsequences it contains. A subsequence of a string is a sequence that can be derived from the string by deleting some or no elements without changi...
MOD = 1000000007 def distinct_subsequences_count(s): """ Calculate the number of distinct subsequences of the string s modulo 1000000007. """ n = len(s) dp = [0] * (n + 1) last = {} dp[0] = 1 # There's always one subsequence which is the empty subsequence for i in range(1, n + 1)...
from solution import calculate_beauty_of_strings, distinct_subsequences_count def test_distinct_subsequences_count(): assert distinct_subsequences_count("abc") == 7 assert distinct_subsequences_count("aaa") == 3 assert distinct_subsequences_count("aab") == 5 assert distinct_subsequences_count("abcdefgh...
[ { "docstring": "Calculate the number of distinct subsequences of the string s modulo 1000000007.", "function_declaration": "def distinct_subsequences_count(s):", "function_name": "distinct_subsequences_count", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def c...
[ 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": "MOD = 1000000007\n\ndef distinct_subsequences_count(s):\n \"\"\"\n Calculate the number of distinct subsequences of the string s modulo 1000000007.\n \"\"...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00011273", "row_id": 11273, "seed_ids": "[6542]" }
0.712263
Taco_11273
I
[ "distinct_subsequences_count", "calculate_beauty_of_strings" ]
2
[ [ "calculate_beauty_of_strings", "distinct_subsequences_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ae4958c89fe35df76bc529aa12c5b02972cbb8f
eda3afbe7f095295f9384f15973d2071ea24771c
v1.0
instruct
Taco
Taco_11290_I
You are given a list of operations to perform on an initially empty stack. The operations are of two types: "PUSH x" (where x is an integer that needs to be pushed onto the stack) and "POP" (which pops the top element from the stack if the stack is not empty). The task is to process the given operations and print the e...
def process_operations(operations): stack = [] results = [] for operation in operations: if operation.startswith("PUSH"): _, value = operation.split() stack.append(int(value)) elif operation == "POP": if stack: results.append(stack.pop()) ...
from solution import simulate_stack_operations, process_operations def test_single_push_pop(): assert simulate_stack_operations(["2", "PUSH 1", "POP"]) == [1] def test_multiple_push_pops(): assert simulate_stack_operations(["6", "PUSH 3", "PUSH 4", "POP", "POP", "POP", "PUSH 5"]) == [4, 3, "EMPTY"] def test_...
[ { "docstring": null, "function_declaration": "def process_operations(operations):", "function_name": "process_operations", "parameter_list": "(operations)" }, { "docstring": null, "function_declaration": "def simulate_stack_operations(input_lines):", "function_name": "simulate_stack_...
[ 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 stack_operations(operations):\n stack = []\n result = []\n\n for operation in operations:\n if operation.startswith(\"PUSH\"):\n _, ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00011290", "row_id": 11290, "seed_ids": "[22180]" }
0.581313
Taco_11290
I
[ "process_operations", "simulate_stack_operations" ]
2
[ [ "simulate_stack_operations", "process_operations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec12f3cdb14aabb88c5e40c4a3c65fc4c6569760
c508f50b1c8311369094a678a2532f0341f39723
v1.0
instruct
Taco
Taco_11324_I
A city is organized in a grid of size n x n. Each cell within the grid may either be a building (represented by the number 1) or an empty lot (represented by the number 0). The mayor of the city wishes to identify contiguous clusters of buildings for future urban planning. A cluster of buildings is defined as a group o...
def find_clusters(grid, n): def dfs(x, y): if x < 0 or y < 0 or x >= n or y >= n or grid[x][y] == 0: return grid[x][y] = 0 # mark as visited # Visit all adjacent cells (up, down, left, right) dfs(x + 1, y) dfs(x - 1, y) dfs(x, y + 1) dfs(x, y - 1)...
def test_count_clusters_1(): grid = [ "1 1 0 0 0", "1 0 0 1 1", "0 0 0 1 1", "0 1 1 0 0", "0 0 0 0 1" ] assert count_clusters(5, grid) == 4 def test_count_clusters_2(): grid = [ "1 1 0", "0 1 0", "0 0 1" ] assert count_clusters(3, ...
[ { "docstring": null, "function_declaration": "def find_clusters(grid, n):", "function_name": "find_clusters", "parameter_list": "(grid, n)" }, { "docstring": null, "function_declaration": "def count_clusters(n, grid_values):", "function_name": "count_clusters", "parameter_list": ...
[ 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_clusters(grid):\n \"\"\"\n Given a grid of size n x n with 1s representing buildings and 0s representing empty lots,\n count the number of conti...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00011324", "row_id": 11324, "seed_ids": "[5945]" }
0.661103
Taco_11324
I
[ "find_clusters", "count_clusters" ]
2
[ [ "count_clusters", "find_clusters" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3ba0768ded62ec679c055475aca6ae6a03013f56
d8469b629e28f9afbf921227bd6950cd0f2065a3
v1.0
instruct
Taco
Taco_11417_I
You’re developing a navigation app, and you need to implement a feature that finds the shortest path between points in a city. The city is represented as a grid of intersections and streets. However, certain streets are under construction and cannot be used for navigation. You are given the size of the city, the start...
from collections import deque def is_valid_move(x, y, n, m, grid): """ Check if the move x, y is valid within the grid bounds and is not under construction. """ return 0 <= x < n and 0 <= y < m and grid[x][y] == 0 def shortest_path(n, m, start, end, constructions): """ Determine the length of ...
import pytest from solution import shortest_path def test_shortest_path_basic(): # Basic example provided n, m = 5, 5 start = (1, 1) end = (5, 5) constructions = [(2, 2), (3, 3)] assert shortest_path(n, m, start, end, constructions) == 8 def test_shortest_path_no_possible_path(): n, m = 3,...
[ { "docstring": "Check if the move x, y is valid within the grid bounds and is not under construction.", "function_declaration": "def is_valid_move(x, y, n, m, grid):", "function_name": "is_valid_move", "parameter_list": "(x, y, n, m, grid)" }, { "docstring": "Determine the length of the shor...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(n, m, start, end, blocked):\n directions = [(-1,0), (1,0), (0,-1), (0,1)]\n start_x, start_y = start\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00011417", "row_id": 11417, "seed_ids": "[21077]" }
0.768329
Taco_11417
I
[ "is_valid_move", "shortest_path" ]
2
[ [ "shortest_path", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4bf302d99d98a43613e58fad80c8dd161945ea13
2cea0b1f6cf8b591cf263a60790c9c776a0de2bc
v1.0
instruct
Taco
Taco_11447_I
You are given a task to generate a specific pattern of numbers based on the given input. Each test case consists of one integer `N`. For each `N`, you need to print a pattern of size `N x N` (N rows and N columns) where each element in the pattern is the product of its row index and column index (starting from 1). ---...
def generate_pattern(N): """ Generates a pattern of numbers of size NxN where each element is the product of its row and column indices. Starting index is 1. """ pattern = [] for i in range(1, N + 1): row = [] for j in range(1, N + 1): row.append(i * j) p...
from solution import generate_pattern, format_pattern, solution def test_generate_pattern(): assert generate_pattern(1) == [[1]] assert generate_pattern(2) == [[1, 2], [2, 4]] assert generate_pattern(3) == [[1, 2, 3], [2, 4, 6], [3, 6, 9]] def test_format_pattern(): assert format_pattern([[1]]) == '1\...
[ { "docstring": "Generates a pattern of numbers of size NxN where each \nelement is the product of its row and column indices.\nStarting index is 1.", "function_declaration": "def generate_pattern(N):", "function_name": "generate_pattern", "parameter_list": "(N)" }, { "docstring": "Formats th...
[ 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 generate_pattern(N):\n \"\"\"\n Generates a pattern matrix of size N x N where each element in the pattern is \n the product of its row index and colu...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00011447", "row_id": 11447, "seed_ids": "[1179]" }
0.664458
Taco_11447
I
[ "generate_pattern", "format_pattern", "solution" ]
3
[ [ "solution", "format_pattern" ], [ "solution", "generate_pattern" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e5c9374db475702007bc02e22fe879d91f48a4e8
74fa0e20c5f38fce104196820f12fea1a66bbf5a
v1.0
instruct
Taco
Taco_11565_I
You are working as a software engineer at a logistics company. You are tasked with developing a route optimization algorithm for delivery trucks. Each delivery truck needs to visit a series of delivery points in a given order and return to the starting point. The goal is to determine the shortest possible route that vi...
import itertools import math def euclidean_distance(p1, p2): return math.sqrt((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) def shortest_route(N, points): min_route_length = float('inf') permutations = itertools.permutations(points[1:]) for perm in permutations: current_route_length = eucl...
from solution import shortest_route def test_example_1(): N = 4 points = [(0, 0), (2, 0), (2, 2), (0, 2)] assert shortest_route(N, points) == 8.000 def test_example_2(): N = 3 points = [(0, 0), (1, 1), (1, 0)] assert shortest_route(N, points) == 3.414 def test_two_points(): N = 2 poin...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def shortest_route(N, points):", "function_name": "shortest_route", "parameter_list...
[ 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": "import itertools\nimport math\n\ndef calculate_distance(x1, y1, x2, y2):\n \"\"\"\n Calculates the Euclidean distance between two points (x1, y1) and (x2, y2...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00011565", "row_id": 11565, "seed_ids": "[21476]" }
0.761505
Taco_11565
I
[ "euclidean_distance", "shortest_route" ]
2
[ [ "shortest_route", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0e41af6347c69e78caf6ea376fedfa508ea4788d
9d6d3a91acfd2e43587eb37ee7c9b1934523f987
v1.0
instruct
Taco
Taco_11610_I
You are working on a project involving network connections and need to calculate the shortest paths between nodes using Dijkstra's algorithm. The structure of the network is given by a weighted, directed graph. Your task is to write a program that reads the graph data and computes the shortest path from a given starti...
import heapq def dijkstra(n, edges, s): graph = {i: [] for i in range(1, n + 1)} for u, v, w in edges: graph[u].append((w, v)) distances = {i: float('inf') for i in range(1, n + 1)} distances[s] = 0 priority_queue = [(0, s)] while priority_queue: current_distance, u = h...
def test_shortest_paths(): n, m = 5, 6 edges = [(1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 1)] s = 1 assert shortest_paths(n, m, edges, s) == ["0", "2", "3", "9", "6"] def test_disconnected_graph(): n, m = 4, 2 edges = [(1, 2, 3), (3, 4, 5)] s = 1 assert shortest_path...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, s):", "function_name": "dijkstra", "parameter_list": "(n, edges, s)" }, { "docstring": null, "function_declaration": "def shortest_paths(n, m, edges, s):", "function_name": "shortest_paths", "parameter_list": "(...
[ 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(n, edges, s):\n graph = [[] for _ in range(n)]\n for u, v, w in edges:\n graph[u-1].append((v-1, w)) # Adjust 1-based in...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00011610", "row_id": 11610, "seed_ids": "[6947]" }
0.740704
Taco_11610
I
[ "dijkstra", "shortest_paths" ]
2
[ [ "shortest_paths", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6b7c356384ac409065824d8735bb8b4b760da7ba
6167d1f65e3e18c86b6be3c5f4299883d63d8c0b
v1.0
instruct
Taco
Taco_11616_I
Create a program to determine the largest rectangular area that can be obtained from a histogram. A histogram is represented by a list of integers where each integer represents the height of a bar. The width of each bar is 1. Input The input consists of multiple data sets. Each data set is a sequence of positive inte...
def largest_rectangle_area(histogram): """ Calculates the largest rectangular area that can be obtained. """ stack = [] max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) inde...
from solution import process_histogram_input, largest_rectangle_area def test_largest_rectangle_area(): assert largest_rectangle_area([2, 1, 5, 6, 2, 3]) == 10 assert largest_rectangle_area([4, 2]) == 4 assert largest_rectangle_area([]) == 0 assert largest_rectangle_area([1]) == 1 assert largest_re...
[ { "docstring": "Calculates the largest rectangular area that can be obtained.", "function_declaration": "def largest_rectangle_area(histogram):", "function_name": "largest_rectangle_area", "parameter_list": "(histogram)" }, { "docstring": "Processes multiple datasets of histograms and return...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_rectangle_area(histogram):\n \"\"\"\n Computes the largest rectangular area in a histogram.\n :param histogram: List[int] - List of integers r...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00011616", "row_id": 11616, "seed_ids": "[8935]" }
0.627197
Taco_11616
I
[ "largest_rectangle_area", "process_histogram_input" ]
2
[ [ "process_histogram_input", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
98f3132f1edeb34a85a1ed54f74bdcfd61f80bce
143b2a2f62ae94be556efa0d179d50221b4f356d
v1.0
instruct
Taco
Taco_11622_I
You are given an undirected graph with $n$ nodes and $m$ edges. Each edge has a positive weight. Your task is to compute and print the length of the longest shortest path in the graph for each query. A shortest path between two nodes is the path with the minimum total weight between them, and the longest shortest path...
import heapq def dijkstra(graph, start): distances = {node: float('infinity') for node in graph} distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) if current_distance > distances[current_node]: ...
def test_solution(): n = 5 m = 4 edges = [(1, 2, 4), (1, 3, 2), (3, 4, 7), (2, 5, 5)] q = 2 queries = [ [1, 2, 3], [4, 5], ] expected_output = [6, -1] result = longest_shortest_path(n, m, edges, q, queries) assert result == expected_output def test_single_node(): ...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": null, "function_declaration": "def longest_shortest_path(n, m, edges, q, queries):", "function_name": "longest_shortest_path",...
[ 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(graph, start):\n distances = {node: float('infinity') for node in graph}\n distances[start] = 0\n priority_queue = [(0, start...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00011622", "row_id": 11622, "seed_ids": "[14611]" }
0.796364
Taco_11622
I
[ "dijkstra", "longest_shortest_path" ]
2
[ [ "longest_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
f5171f9e760e99a5e64eb286b1b9dcb7dd67e8d3
752a315be1ce0aea460a15c156a932fe7b0b241b
v1.0
instruct
Taco
Taco_11623_I
In the small town of Pathville, there are n intersections connected by m one-way streets such that it's possible to reach any intersection from any other intersection using the streets. Each street has an associated time t which indicates the time it takes to travel from one intersection to another. The town has p ...
import heapq def dijkstra(n, graph, start): """ Use Dijkstra's algorithm to find the shortest path from start to all other nodes. """ min_heap = [(0, start)] dist = {i: float('inf') for i in range(1, n + 1)} dist[start] = 0 while min_heap: current_distance, u = heapq.heappop(mi...
import pytest from solution import minimized_maximum_travel_time def test_example_1(): n, m, p = 5, 6, 3 bus_stops = [1, 3, 5] streets = [ (1, 2, 3), (2, 3, 2), (3, 4, 4), (4, 5, 1), (2, 5, 5), (5, 1, 2) ] assert minimized_maximum_travel_time(n, m, p,...
[ { "docstring": "Use Dijkstra's algorithm to find the shortest path from start to all other nodes.", "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def minimized_...
[ 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\nimport sys\nfrom collections import defaultdict\n\ndef dijkstra(graph, start):\n \"\"\" Finds the shortest paths from the start node to all other ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00011623", "row_id": 11623, "seed_ids": "[21279]" }
0.768884
Taco_11623
I
[ "dijkstra", "minimized_maximum_travel_time" ]
2
[ [ "minimized_maximum_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f79f3338647c4b477b23976218e56e50be49e98f
702b22f58185019c141b7ec7460f7dcb96f4291d
v1.0
instruct
Taco
Taco_11631_I
Alice likes symmetry and finds palindromes to be fascinating. She decides to play a game with her friend Bob using this concept. She provides Bob with various strings, and for each string, she wants to determine if it can be rearranged to form a palindrome. A string can be rearranged to form a palindrome if at most on...
def can_form_palindrome(s): """ Checks if a given string can be rearranged to form a palindrome. :param s: The input string. :return: 'Yes' if the string can be rearranged to form a palindrome, otherwise 'No'. """ from collections import Counter char_counts = Counter(s) odd_count = ...
from solution import can_form_palindrome, check_palindromes def test_can_form_palindrome(): assert can_form_palindrome("civic") == "Yes" assert can_form_palindrome("ivicc") == "Yes" assert can_form_palindrome("hello") == "No" assert can_form_palindrome("aabb") == "Yes" assert can_form_palindrome("x...
[ { "docstring": "Checks if a given string can be rearranged to form a palindrome.\n:param s: The input string.\n:return: 'Yes' if the string can be rearranged to form a palindrome, otherwise 'No'.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parame...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_palindrome(s):\n from collections import Counter\n count = Counter(s)\n odd_count = sum(1 for val in count.values() if val % 2 == 1)\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00011631", "row_id": 11631, "seed_ids": "[22149]" }
0.80494
Taco_11631
I
[ "can_form_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0ed3ca9eb63c23af53eb5ef8329c62bbbc8b039
e011f1bbebaa4efc46d2840fb1ec2b41d5e667d6
v1.0
instruct
Taco
Taco_11667_I
Given an integer array nums, return the difference between the largest and smallest prime numbers contained in the array. If the array contains fewer than 2 prime numbers, return -1. Example 1: Input: nums = [10, 15, 3, 7, 19] Output: 16 Explanation: The prime numbers in the array are 3, 7, and 19. The largest prime n...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def prime_diff(nums): primes = [num for num in num...
from solution import is_prime, prime_diff def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False def test_prime_diff_example1(): nums = [10, 15, 3, 7, 19] assert prime_diff(nums) == 16 ...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_diff(nums):", "function_name": "prime_diff", "parameter_list": "(nums)" } ]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return Tr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00011667", "row_id": 11667, "seed_ids": "[10775]" }
0.8147
Taco_11667
I
[ "is_prime", "prime_diff" ]
2
[ [ "prime_diff", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b75f6627364628264b4ef0ec9705b43387abeee0
bda53d638375e294a37b65fa0b5b190dfd2c8c81
v1.0
instruct
Taco
Taco_11760_I
Mina loves strings. She always tries to find interesting patterns in the strings she receives from her friends. One day, she noticed that some strings could be made uniform by changing the order of their characters. A string is considered uniform if every character appears the same number of times. Now, Mina wants to k...
def can_be_uniform(s): """ Checks if the string can be rearranged such that every character appears the same number of times. """ from collections import Counter counts = Counter(s) values = list(counts.values()) return all(x == values[0] for x in values) def check_uniformity(test_cases): ...
from solution import can_be_uniform, check_uniformity def test_can_be_uniform(): assert can_be_uniform('aabbcc') == True assert can_be_uniform('aaabbc') == False assert can_be_uniform('aabccc') == False assert can_be_uniform('abcabc') == True assert can_be_uniform('aaa') == True assert can_be_u...
[ { "docstring": "Checks if the string can be rearranged such that every character appears the same number of times.", "function_declaration": "def can_be_uniform(s):", "function_name": "can_be_uniform", "parameter_list": "(s)" }, { "docstring": "Given a list of test cases, returns a list of \...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef can_be_uniform(s):\n \"\"\"\n Checks if a given string can be rearranged such that each character appears the same num...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00011760", "row_id": 11760, "seed_ids": "[12288]" }
0.717546
Taco_11760
I
[ "can_be_uniform", "check_uniformity" ]
2
[ [ "check_uniformity", "can_be_uniform" ] ]
1
[]
false
[]
false
pytest
true
[]
true
572043f01ef27b69b56860ae8538b9caf34b885b
a5c7280149075976585316a34ee0c63a51128c4d
v1.0
instruct
Taco
Taco_11804_I
You are given an undirected graph with N nodes and M edges. Each edge has a positive weight. The goal is to find the minimum weight required to connect all the nodes in the graph in such a way that there is exactly one cycle in the resulting subgraph. -----Constraints----- - 2 ≤ N ≤ 1000 - 1 ≤ M ≤ 2000 - The weight of...
import sys from heapq import heappop, heappush def find(parent, u): if parent[u] != u: parent[u] = find(parent, parent[u]) return parent[u] def union(parent, rank, u, v): root_u = find(parent, u) root_v = find(parent, v) if root_u != root_v: if rank[root_u] > rank[root_v]: ...
from solution import minimum_weight_one_cycle def test_sample(): n = 4 edges = [ (1, 2, 1), (2, 3, 2), (3, 4, 3), (4, 1, 4), (1, 3, 5) ] assert minimum_weight_one_cycle(n, edges) == 10 def test_single_additional_edge(): n = 3 edges = [ (1, 2, 1),...
[ { "docstring": null, "function_declaration": "def find(parent, u):", "function_name": "find", "parameter_list": "(parent, u)" }, { "docstring": null, "function_declaration": "def union(parent, rank, u, v):", "function_name": "union", "parameter_list": "(parent, rank, u, v)" }, ...
[ 0, 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": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n \n def find(self, u):\n if self.pare...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00011804", "row_id": 11804, "seed_ids": "[25069]" }
0.793807
Taco_11804
I
[ "find", "union", "minimum_weight_one_cycle", "main" ]
4
[ [ "minimum_weight_one_cycle", "find" ], [ "minimum_weight_one_cycle", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c9e279b64451c8470c46589d98c13606305a1170
20a42b822247d036d023d5a5ac9a66721054311d
v1.0
instruct
Taco
Taco_11806_I
You are given several integers. Write a program that determines if each integer is a happy number. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will ...
def is_happy_number(n): """ Returns True if n is a happy number; otherwise, returns False. """ seen = set() while n != 1 and n not in seen: seen.add(n) n = sum(int(digit) ** 2 for digit in str(n)) return n == 1 def determine_happiness(m, numbers): """ For each number in ...
from solution import is_happy_number, determine_happiness def test_is_happy_number(): assert is_happy_number(19) == True assert is_happy_number(2) == False assert is_happy_number(1) == True assert is_happy_number(7) == True assert is_happy_number(20) == False def test_determine_happiness(): as...
[ { "docstring": "Returns True if n is a happy number; otherwise, returns False.", "function_declaration": "def is_happy_number(n):", "function_name": "is_happy_number", "parameter_list": "(n)" }, { "docstring": "For each number in numbers, determines if it is a happy number and\nreturns a lis...
[ 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_happy_number(n):\n \"\"\"\n Returns True if n is a happy number; otherwise, returns False.\n \"\"\"\n seen = set()\n while n != 1 and n not i...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00011806", "row_id": 11806, "seed_ids": "[4793]" }
0.590258
Taco_11806
I
[ "is_happy_number", "determine_happiness" ]
2
[ [ "determine_happiness", "is_happy_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3850eb4a715777e603b8cde2dfa9d7285e12abbc
33d3f6a7fd36d88b049ab682472798ac59cb2141
v1.0
instruct
Taco
Taco_11820_I
Imagine you are developing a simplified driving navigation system. Your task is to calculate the shortest path between two locations in a city represented as a graph, where intersections are nodes and streets are edges. Each street has a travel time associated with it. Given the total number of intersections (n), tota...
import heapq from collections import defaultdict, deque def dijkstra(n, edges, start, end): graph = defaultdict(list) for u, v, t in edges: graph[u].append((v, t)) graph[v].append((u, t)) min_heap = [(0, start)] shortest_path = {i: float('inf') for i in range(1, n + 1)} sho...
from solution import find_shortest_path def test_example_case(): n = 5 m = 6 edges = [ (1, 2, 4), (1, 3, 2), (2, 3, 2), (2, 4, 1), (3, 5, 5), (4, 5, 3) ] a = 1 b = 5 assert find_shortest_path(n, m, edges, a, b) == 7 def test_no_path(): n ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start, end):", "function_name": "dijkstra", "parameter_list": "(n, edges, start, end)" }, { "docstring": null, "function_declaration": "def find_shortest_path(n, m, edges, a, b):", "function_name": "find_shortest_pa...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_travel_time(n, m, streets, a, b):\n graph = {}\n \n # Build the graph\n for u, v, t in streets:\n if u not in graph...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00011820", "row_id": 11820, "seed_ids": "[17759]" }
0.758102
Taco_11820
I
[ "dijkstra", "find_shortest_path" ]
2
[ [ "find_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5421f7d5a6dbb54efaefefb7da70ef73c1e987a2
cb14c602db7672f6dbe2e0023277566eb2023931
v1.0
instruct
Taco
Taco_11833_I
Alina is fascinated by palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. For example, 121 and 1331 are palindromic numbers, while 123 and 1234 are not. Alina wonders if she can find the smallest palindromic number greater than or equal to a given number n. ----...
def is_palindromic(number): """ Checks if a given number is palindromic. """ str_number = str(number) return str_number == str_number[::-1] def find_smallest_palindrome(n): """ Finds the smallest palindromic number greater than or equal to n. """ while not is_palindromic(n): ...
from solution import is_palindromic, find_smallest_palindrome def test_is_palindromic(): assert is_palindromic(121) == True assert is_palindromic(131) == True assert is_palindromic(123) == False assert is_palindromic(1331) == True assert is_palindromic(12321) == True def test_find_smallest_palindr...
[ { "docstring": "Checks if a given number is palindromic.", "function_declaration": "def is_palindromic(number):", "function_name": "is_palindromic", "parameter_list": "(number)" }, { "docstring": "Finds the smallest palindromic number greater than or equal to n.", "function_declaration":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def smallest_palindrome(n: int) -> int:\n \"\"\"\n Returns the smallest palindromic number greater than or equal to n.\n \"\"\"\n def is_palindrome(x: ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00011833", "row_id": 11833, "seed_ids": "[25431]" }
0.834916
Taco_11833
I
[ "is_palindromic", "find_smallest_palindrome" ]
2
[ [ "find_smallest_palindrome", "is_palindromic" ] ]
1
[]
false
[]
false
pytest
true
[]
true
88e42c1cb1dfa2e763cd824e153d7fc15ec2be57
4a089fecd2ebbf87731c132c40794a15a44f7061
v1.0
instruct
Taco
Taco_11910_I
Alex, an avid gardener, decides to organize the various plants in his garden into clusters to manage them better and make his daily watering routine easier. Each plant in his garden has a unique preference for water, light, and soil type, represented as tuples with three integers: `(water, light, soil)`. Alex wants to...
import numpy as np def euclidean_distance(p1, p2): return np.sqrt(np.sum((np.array(p1) - np.array(p2)) ** 2)) def k_means_clustering(plants, k): centroids = plants[:k] prev_centroids = [[None, None, None]] * k while centroids != prev_centroids: clusters = [[] for _ in range(k)] for pla...
from solution import k_means_clustering def test_k_means_clustering_simple(): plants = [(3, 5, 1), (10, 10, 10), (2, 3, 2), (11, 11, 10), (4, 5, 1), (9, 9, 9)] k = 2 clusters = k_means_clustering(plants, k) # Both clusters should have 3 plants each assert len(clusters) == 2 assert len(clus...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def k_means_clustering(plants, k):", "function_name": "k_means_clustering", "parame...
[ 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 numpy as np\n\ndef euclidean_distance(p1, p2):\n return np.sqrt(np.sum((np.array(p1) - np.array(p2)) ** 2))\n\ndef k_means_clustering(plants, k):\n ce...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00011910", "row_id": 11910, "seed_ids": "[17023]" }
0.614021
Taco_11910
I
[ "euclidean_distance", "k_means_clustering", "print_clusters", "main" ]
4
[ [ "k_means_clustering", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
3427349e11c60cfc1cc1b6dc4494bbc4eb191b91
2a90085c5d77c67e59e91aa8080ab27a8256ec73
v1.0
instruct
Taco
Taco_11923_I
# Palindrome Partitioning Write a function `palindrome_partitions` (or `palindromePartitions`/`PalindromePartitions` depending on language rules) that, given a string `s`, returns all possible ways to partition `s` such that each substring is a palindrome. ### Example For `s = "aab"` the solution could look like this...
def is_palindrome(s): """ Helper function to check if a given string 's' is a palindrome. """ return s == s[::-1] def palindrome_partitions(s): """ Returns all possible ways to partition 's' such that each substring is a palindrome. """ def backtrack(start, path): if start == le...
from solution import palindrome_partitions def test_single_character(): assert palindrome_partitions("a") == [["a"]] def test_two_characters_all_same(): assert palindrome_partitions("aa") == [["a", "a"], ["aa"]] def test_two_characters_different(): assert palindrome_partitions("ab") == [["a", "b"]] def ...
[ { "docstring": "Helper function to check if a given string 's' is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns all possible ways to partition 's' such that each substring is a palindrome....
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n return s == s[::-1]\n\ndef palindrome_partitions(s):\n result = []\n def backtrack(start, path):\n if start == len(s):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00011923", "row_id": 11923, "seed_ids": "[22003]" }
0.747541
Taco_11923
I
[ "is_palindrome", "palindrome_partitions" ]
2
[ [ "palindrome_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4993eabc0c99b28cc653584ba6e43061672db453
e91f16e09ca029a4431d7805533350d001546166
v1.0
instruct
Taco
Taco_11929_I
Two local parks are connected by a continuous hiking trail. Due to the high demand for walking trails, each park has decided to reserve certain portions of the trail for exclusive use by their visitors. Your task is to ensure that the reserved sections do not overlap. Each park provides its reserved segments of the tr...
def find_overlap(segment_list_1, segment_list_2): """ Determines whether there is an overlap between segments from two parks and identifies the overlapping segment. Args: segment_list_1 (list of tuples): List of tuples where each tuple represents a segment in the first park. segment_list_2 (list of...
from solution import check_overlap def test_no_overlap(): assert check_overlap(2, [(5, 10), (15, 20)], 1, [(21, 25)]) == ("NO OVERLAP",) def test_overlap_case_1(): assert check_overlap(3, [(1, 5), (10, 15), (20, 25)], 2, [(3, 8), (16, 19)]) == ("OVERLAP", 3, 5) def test_overlap_case_2(): assert check_ove...
[ { "docstring": "Determines whether there is an overlap between segments from two parks and identifies the overlapping segment.\n\nArgs:\nsegment_list_1 (list of tuples): List of tuples where each tuple represents a segment in the first park.\nsegment_list_2 (list of tuples): List of tuples where each tuple repr...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_overlap(reservations_park1, reservations_park2):\n \"\"\"\n Determine if there is an overlap between two sets of reserved segments.\n \n rese...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00011929", "row_id": 11929, "seed_ids": "[8316]" }
0.640205
Taco_11929
I
[ "find_overlap", "check_overlap" ]
2
[ [ "check_overlap", "find_overlap" ] ]
1
[]
false
[]
false
pytest
true
[]
true
025e10267b06c3f6d67e82fbc3059a9c19e301bd
a58a3064f6daa5a502ccf8cebf4d5711b15b55c5
v1.0
instruct
Taco
Taco_11947_I
Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. The returned list should have the prime numbers in the same order as they appeared in the input list. Note that 1 is not considered a prime number. **Function Signature:** ```python def find...
from typing import List def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: ...
from solution import find_primes def test_find_primes_basic(): assert find_primes([2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 3, 5, 7, 11] assert find_primes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert find_primes([11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == [11, 13, 17, 19, 23, 29, 31, 37,...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def find_pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00011947", "row_id": 11947, "seed_ids": "[1590]" }
0.688603
Taco_11947
I
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c71308adcfae2c586220dcb9191511a2196d876d
e20eb8275f0f7310c2c161c1cf315328e7e554ba
v1.0
instruct
Taco
Taco_12024_I
Write a program that determines whether a given sequence of moves on a chessboard will result in a valid path for a knight starting at a specific position. Recall that a knight moves in an L-shape: two squares in one direction and then one square perpendicular, or one square in one direction and then two squares perpen...
def parse_chess_position(position): """ Parses a chess position in standard notation (e.g., 'e2') and returns the corresponding 0-indexed (x, y) tuple. """ col = ord(position[0]) - ord('a') row = int(position[1]) - 1 return (col, row) def is_valid_knight_move(start, move): """ Determine...
import pytest from solution import parse_chess_position, is_valid_knight_move, is_within_bounds, is_valid_knight_path def test_parse_chess_position(): assert parse_chess_position('a1') == (0, 0) assert parse_chess_position('h8') == (7, 7) assert parse_chess_position('e2') == (4, 1) assert parse_chess_p...
[ { "docstring": "Parses a chess position in standard notation (e.g., 'e2') and returns the corresponding 0-indexed (x, y) tuple.", "function_declaration": "def parse_chess_position(position):", "function_name": "parse_chess_position", "parameter_list": "(position)" }, { "docstring": "Determin...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_knight_move(start, n, moves):\n def pos_to_coords(pos):\n col = ord(pos[0]) - ord('a')\n row = int(pos[1]) - 1\n return (row, ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00012024", "row_id": 12024, "seed_ids": "[20515]" }
0.693703
Taco_12024
I
[ "parse_chess_position", "is_valid_knight_move", "is_within_bounds", "is_valid_knight_path" ]
4
[ [ "is_valid_knight_path", "is_valid_knight_move" ], [ "is_valid_knight_path", "is_within_bounds" ], [ "is_valid_knight_path", "parse_chess_position" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c89471438bf59ce855e03abf15d830010161f3b4
0ddd4a1ec74cc56c64ba839dffe00bd47d03aaf1
v1.0
instruct
Taco
Taco_12038_I
In an ancient kingdom, the king wishes to organize the delivery of resources between various cities. There are **n** cities and **m** direct roads connecting some pairs of cities. Along each road, the king has noted two values: the maximum load capacity of the road and the minimum time required to traverse the road. Th...
import heapq def can_delivery_be_made(n, m, roads, deliveries): # Create adjacency list for the graph graph = [[] for _ in range(n + 1)] for u, v, L, T in roads: graph[u].append((v, L, T)) graph[v].append((u, L, T)) results = [] for a, b, R, M in deliveries: results.app...
from solution import can_delivery_be_made def test_single_path(): n = 4 m = 4 roads = [ (1, 2, 10, 5), (2, 3, 10, 3), (3, 4, 5, 2), (1, 3, 15, 10), ] deliveries = [ (1, 4, 5, 10), (1, 4, 15, 10), ] assert can_delivery_be_made(n, m, roads, deli...
[ { "docstring": null, "function_declaration": "def can_delivery_be_made(n, m, roads, deliveries):", "function_name": "can_delivery_be_made", "parameter_list": "(n, m, roads, deliveries)" }, { "docstring": null, "function_declaration": "def dijkstra(graph, start, end, n, R, M):", "func...
[ 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 can_delivery_be_made(n, m, roads, deliveries):\n # Create adjacency list for the graph\n graph = [[] for _ in range(n + 1)]\n for u, v...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00012038", "row_id": 12038, "seed_ids": "[7412]" }
0.768791
Taco_12038
I
[ "can_delivery_be_made", "dijkstra" ]
2
[ [ "can_delivery_be_made", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
84e67c71491a1c4d083b77f6efd061b440be5cec
413282400ef00ee8b6a9a2a4aa8949cffbb0e04c
v1.0
instruct
Taco
Taco_12081_I
Given an array of integers, find the length of the longest subsequence such that each element in the subsequence is a power of two. Example 1: Input: arr = [1, 8, 4, 16, 2, 32] Output: 5 Explanation: The longest subsequence composed of powers of two is [1, 2, 4, 8, 16]. Example 2: Input: arr = [10, 20, 15, 3, 6, 9] Ou...
def is_power_of_two(n): """ Helper function to determine if a number is a power of two. """ return (n & (n - 1)) == 0 and n != 0 def longestPowerOfTwoSubsequence(arr): """ Returns the length of the longest subsequence where each element is a power of two. """ return sum(1 for x in arr i...
from solution import is_power_of_two, longestPowerOfTwoSubsequence def test_is_power_of_two(): assert is_power_of_two(1) == True assert is_power_of_two(2) == True assert is_power_of_two(4) == True assert is_power_of_two(8) == True assert is_power_of_two(16) == True assert is_power_of_two(32) ==...
[ { "docstring": "Helper function to determine if a number is a power of two.", "function_declaration": "def is_power_of_two(n):", "function_name": "is_power_of_two", "parameter_list": "(n)" }, { "docstring": "Returns the length of the longest subsequence where each element is a power of two."...
[ 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 longestPowerOfTwoSubsequence(arr):\n \"\"\"\n Returns the length of the longest subsequence where each element is a power of two.\n \"\"\"\n def is...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00012081", "row_id": 12081, "seed_ids": "[17490]" }
0.71209
Taco_12081
I
[ "is_power_of_two", "longestPowerOfTwoSubsequence" ]
2
[ [ "longestPowerOfTwoSubsequence", "is_power_of_two" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7c66615b7cac63f32588b5b49668fff847c53d3
3650ee7dd9e416aa160db8ebf10975353f91f352
v1.0
instruct
Taco
Taco_12105_I
The city of Codeville is upgrading its communication network. The network consists of n communication towers that need to be connected with m bidirectional cables. Each cable has a certain bandwidth capacity. The network must be designed to handle q queries, which will help determine the overall efficiency of the commu...
def initialize_towers(n, m, connections): # Initialize matrix with zero bandwidths bandwidth_matrix = [[0 if i != j else float('inf') for j in range(n)] for i in range(n)] for a, b, c in connections: bandwidth_matrix[a-1][b-1] = max(bandwidth_matrix[a-1][b-1], c) bandwidth_matrix[b-1][a-1] ...
def test_initialize_towers(): n = 4 m = 3 connections = [(1, 2, 5), (2, 3, 10), (3, 4, 20)] expected = [ [float('inf'), 5, 0, 0], [5, float('inf'), 10, 0], [0, 10, float('inf'), 20], [0, 0, 20, float('inf')] ] assert initialize_towers(n, m, connections) == expecte...
[ { "docstring": null, "function_declaration": "def initialize_towers(n, m, connections):", "function_name": "initialize_towers", "parameter_list": "(n, m, connections)" }, { "docstring": null, "function_declaration": "def floyd_warshall(n, bandwidth_matrix):", "function_name": "floyd_...
[ 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\nclass UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [0] * n\n self.maxBand = 0\n \n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00012105", "row_id": 12105, "seed_ids": "[24334]" }
0.689208
Taco_12105
I
[ "initialize_towers", "floyd_warshall", "handle_queries", "main" ]
4
[ [ "handle_queries", "floyd_warshall" ] ]
1
[ "handle_queries" ]
false
[]
false
pytest
false
[]
true
fe2dc3b8b10b538a899c094ae815100ff821c2ea
187ec572cbf19d2431f2b30c896c0e1b0349db47
v1.0
instruct
Taco
Taco_12152_I
Alex, the software developer, enjoys solving puzzles in graphs. He found a directed graph with `n` nodes and `m` directed edges. Each edge connects two nodes `u` and `v`, and represents a one-way path from `u` to `v`. Alex suspects that there might be closed loops in the graph and wants to know if the graph contains an...
from collections import defaultdict def has_cycle_dfs(node, visited, rec_stack, graph): visited[node] = True rec_stack[node] = True for neighbour in graph[node]: if not visited[neighbour]: if has_cycle_dfs(neighbour, visited, rec_stack, graph): return True e...
from solution import solve def test_case_1(): test_cases = [ (4, 4, [(1, 2), (2, 3), (3, 4), (4, 2)]), (5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]) ] assert solve(test_cases) == ["YES", "NO"] def test_case_2(): test_cases = [ (3, 3, [(1, 2), (2, 3), (3, 1)]), (6, 5, [(1, 2)...
[ { "docstring": null, "function_declaration": "def has_cycle_dfs(node, visited, rec_stack, graph):", "function_name": "has_cycle_dfs", "parameter_list": "(node, visited, rec_stack, graph)" }, { "docstring": null, "function_declaration": "def contains_cycle(n, edges):", "function_name"...
[ 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 has_cycle(n, edges):\n from collections import defaultdict\n \n def dfs(node, visited, rec_stack):\n visited[node] = True\n rec_stack[no...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012152", "row_id": 12152, "seed_ids": "[24255]" }
0.761302
Taco_12152
I
[ "has_cycle_dfs", "contains_cycle", "solve" ]
3
[ [ "contains_cycle", "has_cycle_dfs" ], [ "solve", "contains_cycle" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8fe1f5f70060ba87d1e7f18aeb49bbdd0be2a7e5
b68c88111645c617f471f5bbddd7683abbf44afd
v1.0
instruct
Taco
Taco_12210_I
In Techland, people use a unique sorting mechanism known as TechSort for their lists. TechSort operates differently from traditional sorting algorithms. The mechanism works as follows: 1) Identify all the prime numbers in the list. 2) Sort these prime numbers in ascending order and place them back in their original po...
def is_prime(num): if num < 2: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def tech_sort(nums): prime_indices = [i for i, num in enumerate(nums)...
from solution import process_input def test_tech_sort_example_case(): input_data = [ (7, 13, 5, 3, 4, 8, 10, 11), (4, 22, 3, 14, 17) ] expected_output = [ [3, 5, 11, 4, 8, 10, 13], [22, 3, 14, 17] ] assert process_input(2, input_data) == expected_output def test_tec...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def tech_sort(nums):", "function_name": "tech_sort", "parameter_list": "(nums)" }, { "docstring": nul...
[ 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 \"\"\"Check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012210", "row_id": 12210, "seed_ids": "[10555]" }
0.593549
Taco_12210
I
[ "is_prime", "tech_sort", "process_input" ]
3
[ [ "process_input", "tech_sort" ], [ "tech_sort", "is_prime" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
39e87ef2641a35797416e1d523ce54f705b81e8c
e5f1d7c2b1f517a4b7368abc472ff66d64d0cc2d
v1.0
instruct
Taco
Taco_12270_I
In a galaxy far, far away, the interstellar council uses a unique binary tree structure to transmit secret messages between planets. Each planet represents a node in the tree, and each message travels from the root planet to a leaf planet. The secret message transmission is designed so that every node in the tree cont...
class TreeNode: def __init__(self, node_id, value): self.node_id = node_id self.value = value self.left = None self.right = None def build_tree(nodes): tree = {} for node in nodes: node_id, left_id, right_id, node_value = node if node_id not in tree: ...
from solution import find_max_sum def test_single_node(): assert find_max_sum(1, [(1, [(0, -1, -1, 1)])]) == [1] def test_balanced_tree(): assert find_max_sum(1, [(5, [(0, 1, 2, 5), (1, 3, 4, 10), (2, -1, -1, 20), (3, -1, -1, 1), (4, -1, -1, 50)])]) == [65] def test_left_heavy_tree(): assert find_max_sum...
[]
[ 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 find_max_sum(node, children, values, memo):\n if node == -1:\n return 0\n if node in memo:\n return memo[node]\n \n left_child, right...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00012270", "row_id": 12270, "seed_ids": "[4447]" }
0.616972
Taco_12270
I
[ "build_tree", "max_sum_path", "find_max_sum" ]
3
[ [ "find_max_sum", "build_tree" ], [ "find_max_sum", "max_sum_path" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
8746bfd39bdf79607d159a9efb240bf91f3234e4
18ba107b0174fe7d07824917da9a792631ea168c
v1.0
instruct
Taco
Taco_12295_I
A factory produces different types of widgets in three colors: red, green, and blue. Each batch of production must follow a schedule such that no two widgets of the same color are produced consecutively. The factory is facing a challenge where the production manager needs to ensure that widgets are produced in a way th...
def can_produce_batch(r, g, b): """ Function to check if we can produce widgets of three colors red, green, blue such that no two consecutive widgets are of the same color. :param r: int - Number of red widgets :param g: int - Number of green widgets :param b: int - Number of blue widgets ...
def test_can_produce_batch_possible(): assert can_produce_batch(2, 2, 2) == "Possible" assert can_produce_batch(5, 5, 5) == "Possible" assert can_produce_batch(3, 4, 2) == "Possible" assert can_produce_batch(1, 1, 1) == "Possible" assert can_produce_batch(1, 2, 1) == "Possible" def test_can_produce...
[ { "docstring": "Function to check if we can produce widgets of three colors red, green, blue\nsuch that no two consecutive widgets are of the same color.\n\n:param r: int - Number of red widgets\n:param g: int - Number of green widgets\n:param b: int - Number of blue widgets\n:return: str - \"Possible\" or \"Im...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_produce_without_consecutive_same_color(n, batches):\n result = []\n for r, g, b in batches:\n max_widget = max(r, g, b)\n rest_widgets ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012295", "row_id": 12295, "seed_ids": "[23571]" }
0.642293
Taco_12295
I
[ "can_produce_batch", "check_batches" ]
2
[ [ "check_batches", "can_produce_batch" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7ba3af296923b6d0baf9c9be5874039c433e1e9f
94c5cfc9201fe7f0fb8643c3fc9ca69a736441c6
v1.0
instruct
Taco
Taco_12382_I
## Task Given a binary tree, write a function to determine if two nodes are cousins. In a binary tree, cousins are nodes that are at the same level, but have different parents. ### Input - The root node of the binary tree. - Two integer values representing the nodes to be checked for cousin relationship. ### Output...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def find_depth_and_parent(node, val, depth=0, parent=None): if node is None: return None, None if node.val == val: return depth, parent left_resul...
from solution import TreeNode, isCousins def test_isCousins_true(): root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(3) root.left.left = TreeNode(4) root.right.right = TreeNode(5) assert isCousins(root, 4, 5) == True def test_isCousins_false_same_parent(): root = TreeNode(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, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef isCousi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012382", "row_id": 12382, "seed_ids": "[3982]" }
0.554347
Taco_12382
I
[ "find_depth_and_parent", "isCousins" ]
2
[ [ "isCousins", "find_depth_and_parent" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
5b6698f8662c63fea79c337d6c4fb91bdc56fd9c
2e016c55ac1f8d470f617d06d949784fc8d39ec1
v1.0
instruct
Taco
Taco_12430_I
You are given an array of integers. Your task is to form two groups such that the absolute difference between the sums of the two groups is minimized. If there are multiple ways to achieve this, print any of them. The solution must ensure that every element from the array belongs to exactly one group. -----Input----...
from itertools import combinations def find_min_diff_groups(arr): total_sum = sum(arr) n = len(arr) min_diff = float('inf') best_group1 = [] best_group2 = [] for size in range(n // 2 + 1): for combo in combinations(arr, size): group1_sum = sum(combo) group2_sum ...
import pytest from solution import find_min_diff_groups, process_test_cases def test_find_min_diff_groups(): group1, group2 = find_min_diff_groups([1, 6, 5, 11]) assert abs(sum(group1) - sum(group2)) == 1 group1, group2 = find_min_diff_groups([10, 20, 15]) assert abs(sum(group1) - sum(group2)) == ...
[ { "docstring": null, "function_declaration": "def find_min_diff_groups(arr):", "function_name": "find_min_diff_groups", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def process_test_cases(test_cases):", "function_name": "process_test_cases", "paramet...
[ 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_partition(n, arr):\n \"\"\"\n Function to partition the array into two groups with minimal\n absolute difference between their sums.\n \"\"\"\...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00012430", "row_id": 12430, "seed_ids": "[13822]" }
0.753223
Taco_12430
I
[ "find_min_diff_groups", "process_test_cases", "solve" ]
3
[ [ "process_test_cases", "find_min_diff_groups" ], [ "solve", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
78b5ee6d16e03a56e83b465e739b302a76c4749f
f6c7a2c1d7f869647d4494d7f692862760301dde
v1.0
instruct
Taco
Taco_12583_I
In a faraway kingdom, there are n towns connected by m bidirectional roads. Each road has a non-negative weight, representing the travel cost. The kingdom's ruler wants to ensure that there's always a route, possibly indirect, between any two towns. You are asked to find the minimum cost required to ensure that the ent...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
def test_minimum_cost_to_connect_towns_case1(): n = 4 m = 5 roads = [ [1, 2, 3], [2, 3, 4], [3, 4, 1], [4, 1, 2], [1, 3, 5] ] assert minimum_cost_to_connect_towns(n, m, roads) == 6 def test_minimum_cost_to_connect_towns_case2(): n = 3 m = 1 roads ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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 find(parent, i):\n if parent[i] != i:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(parent, rank, x, y):\n root_x = fin...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00012583", "row_id": 12583, "seed_ids": "[22513]" }
0.735356
Taco_12583
I
[ "find", "union", "minimum_cost_to_connect_towns" ]
3
[ [ "minimum_cost_to_connect_towns", "find" ], [ "minimum_cost_to_connect_towns", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
7720876096581c527de4f1779abb9e42b997521a
a94b82ea9ab52b7c0e3aba48e64ecf63478a30c7
v1.0
instruct
Taco
Taco_12604_I
Design a program that takes a sequence of positive integers and determines if they are prime numbers. A prime number is a number that is only divisible by 1 and itself. The input consists of multiple datasets where each row contains one integer. The end of the input is indicated by a single line of zeros. For each inte...
def is_prime(n): """ Determines if a given number n is a prime number. Returns "Prime" if the number is prime, and "Not Prime" otherwise. """ if n <= 1: return "Not Prime" if n == 2: return "Prime" if n % 2 == 0: return "Not Prime" limit = int(n ** 0.5) + 1 ...
from solution import is_prime, check_prime_numbers def test_is_prime(): assert is_prime(29) == "Prime" assert is_prime(14) == "Not Prime" assert is_prime(1) == "Not Prime" assert is_prime(2) == "Prime" assert is_prime(17) == "Prime" assert is_prime(18) == "Not Prime" assert is_prime(19) == ...
[ { "docstring": "Determines if a given number n is a prime number.\nReturns \"Prime\" if the number is prime, and \"Not Prime\" otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of numbers, returns a l...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a given number n is a prime number.\n Returns \"Prime\" if the number is prime, and \"Not Prime\" otherwise.\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00012604", "row_id": 12604, "seed_ids": "[22093]" }
0.674744
Taco_12604
I
[ "is_prime", "check_prime_numbers" ]
2
[ [ "check_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c275d3fe9e3f86a9f270a042b2dae201861fddb9
d0403835ae59431fc119b6f4862af73d5db959b3
v1.0
instruct
Taco
Taco_12612_I
Problem Let's play a game with numbers called "Reverse-Sum Palindrome". The rules of the game are as follows: 1. Given an integer number, obtain its reverse by reversing its digits. 2. Add the original number and its reverse together. 3. Check if the sum is a palindrome (a number that reads the same backward as forwa...
def reverse_number(n): """ Returns the reverse of the given number n. """ return int(str(n)[::-1]) def is_palindrome(n): """ Checks if the given number n is a palindrome. """ s = str(n) return s == s[::-1] def steps_to_palindrome(n): """ Determines the number of steps requi...
from solution import reverse_number, is_palindrome, steps_to_palindrome def test_reverse_number(): assert reverse_number(123) == 321 assert reverse_number(1200) == 21 assert reverse_number(1) == 1 def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False as...
[ { "docstring": "Returns the reverse of the given number n.", "function_declaration": "def reverse_number(n):", "function_name": "reverse_number", "parameter_list": "(n)" }, { "docstring": "Checks if the given number n is a palindrome.", "function_declaration": "def is_palindrome(n):", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reverse_number(n):\n \"\"\"\n Returns the reverse of the given number n.\n \"\"\"\n return int(str(n)[::-1])\n\ndef is_palindrome(n):\n \"\"\"\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00012612", "row_id": 12612, "seed_ids": "[16290]" }
0.735243
Taco_12612
I
[ "reverse_number", "is_palindrome", "steps_to_palindrome" ]
3
[ [ "steps_to_palindrome", "is_palindrome" ], [ "steps_to_palindrome", "reverse_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c6860c8be693afc78e53ce727c6f1b04dd3652f8
78995da336a83570b29d8f0e007bcc28dbfab234
v1.0
instruct
Taco
Taco_12613_I
A park is designed with several pathways representing a connected, undirected graph. Each pathway has a specific distance associated with it. The objective is to find the minimum distance required to connect all parts of the park (i.e., find the minimum spanning tree of the graph). You are provided with the number of...
def kruskal(n, edges): """ Function to find the minimum cost to connect all nodes using Kruskal's algorithm. """ # Sort edges based on weight edges.sort(key=lambda x: x[2]) parent = list(range(n)) def find(x): if parent[x] != x: parent[x] = find(parent[x]) r...
from solution import minimum_distance_to_connect_all_parts def test_sample_1(): n = 4 m = 5 paths = [ [1, 2, 2], [1, 3, 3], [1, 4, 1], [2, 3, 4], [3, 4, 5] ] assert minimum_distance_to_connect_all_parts(n, m, paths) == 6 def test_sample_2(): n = 3 m ...
[ { "docstring": "Function to find the minimum cost to connect all nodes using Kruskal's algorithm.", "function_declaration": "def kruskal(n, edges):", "function_name": "kruskal", "parameter_list": "(n, edges)" }, { "docstring": "Given the number of nodes, number of edges, and the list of edge...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012613", "row_id": 12613, "seed_ids": "[13741]" }
0.742184
Taco_12613
I
[ "kruskal", "minimum_distance_to_connect_all_parts" ]
2
[ [ "minimum_distance_to_connect_all_parts", "kruskal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8c273f7be7892783e7189bf9dea97c1aeeb238fe
0e3991cd8de3c7bf397791f24d38bb87d62168fc
v1.0
instruct
Taco
Taco_12646_I
You are given a list of students and their scores in a particular subject. Your task is to compute the final letter grade for a given student based on their score. The grading scale is as follows: - A: 90 <= score <= 100 - B: 80 <= score < 90 - C: 70 <= score < 80 - D: 60 <= score < 70 - F: score < 60 Write a program...
def compute_grade(score): """ Return the letter grade based on the score using the grading scale. """ if 90 <= score <= 100: return 'A' elif 80 <= score < 90: return 'B' elif 70 <= score < 80: return 'C' elif 60 <= score < 70: return 'D' else: retu...
from solution import compute_grade, process_student_grades, get_student_grades def test_compute_grade(): assert compute_grade(95) == 'A' assert compute_grade(85) == 'B' assert compute_grade(75) == 'C' assert compute_grade(65) == 'D' assert compute_grade(55) == 'F' def test_process_student_grades()...
[ { "docstring": "Return the letter grade based on the score using the grading scale.", "function_declaration": "def compute_grade(score):", "function_name": "compute_grade", "parameter_list": "(score)" }, { "docstring": "Process the student score data and return a dictionary with names and th...
[ 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 compute_grade(score):\n \"\"\"\n This function takes a score and returns the corresponding letter grade.\n \"\"\"\n if 90 <= score <= 100:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012646", "row_id": 12646, "seed_ids": "[14628]" }
0.728359
Taco_12646
I
[ "compute_grade", "process_student_grades", "get_student_grades" ]
3
[ [ "get_student_grades", "process_student_grades" ], [ "process_student_grades", "compute_grade" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b1b9fb5edf1a021c782f785cc587a5d02d0a9b86
e47a85808a841e2e8aa2ca3565d9612ae738309d
v1.0
instruct
Taco
Taco_12686_I
You are given two sequences of $n$ integers each such that the sequences are permutations of each other. You can perform the following operations any number of times to make these sequences identical: 1. Choose any element from the first sequence and move it to the end, shifting all subsequent elements one position to...
def min_moves_to_identical(n, seq1, seq2): """ Parameters: n (int): The length of the sequences. seq1 (list): The first sequence of integers. seq2 (list): The second sequence of integers. Returns: int: The minimum number of moves required to make the sequences identical. """ # creat...
from solution import min_moves_to_identical def test_example1(): assert min_moves_to_identical(3, [1, 2, 3], [3, 2, 1]) == 4 def test_example2(): assert min_moves_to_identical(5, [5, 4, 3, 2, 1], [1, 2, 3, 4, 5]) == 8 def test_no_moves(): assert min_moves_to_identical(3, [1, 2, 3], [1, 2, 3]) == 0 def t...
[ { "docstring": "Parameters:\nn (int): The length of the sequences.\nseq1 (list): The first sequence of integers.\nseq2 (list): The second sequence of integers.\n\nReturns:\nint: The minimum number of moves required to make the sequences identical.", "function_declaration": "def min_moves_to_identical(n, seq...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_moves_to_make_sequences_identical(n, seq1, seq2):\n # Create a dictionary to store the positions of elements in seq2 for quick lookup\n position_in_s...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00012686", "row_id": 12686, "seed_ids": "[2400]" }
0.748448
Taco_12686
I
[ "min_moves_to_identical", "binary_search" ]
2
[ [ "min_moves_to_identical", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
24c8e3b69a3f68593e87b67aa334862f5f823368
8f84dbc2b421d2c5b268f0967b477b3d7173722d
v1.0
instruct
Taco
Taco_12735_I
You are given a string consisting of digits (0-9) and lowercase letters (a-z). Each digit can be transformed into a corresponding letter where 0 corresponds to 'a', 1 to 'b', ..., and 9 to 'j'. Your task is to find all possible transformations of the given string and return them in lexicographical order. A transformat...
def digit_to_letter(digit): return chr(ord('a') + int(digit)) def generate_transformations(s): transformations = {s} for i, char in enumerate(s): if char.isdigit(): new_transformations = set() for transformation in transformations: new_transformations.ad...
from solution import generate_transformations def test_single_digit(): assert generate_transformations("2") == ["2", "c"] def test_single_non_digit(): assert generate_transformations("a") == ["a"] def test_combined_string_1(): assert generate_transformations("2a4") == ["2a4", "2ae", "ca4", "cae"] def te...
[ { "docstring": null, "function_declaration": "def digit_to_letter(digit):", "function_name": "digit_to_letter", "parameter_list": "(digit)" }, { "docstring": null, "function_declaration": "def generate_transformations(s):", "function_name": "generate_transformations", "parameter_...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def transform_string(s: str):\n corresponding_letters = [\n 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'\n ]\n\n possible_transformations = set...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00012735", "row_id": 12735, "seed_ids": "[22960]" }
0.792585
Taco_12735
I
[ "digit_to_letter", "generate_transformations" ]
2
[ [ "generate_transformations", "digit_to_letter" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5be7d5300de61b0c810ee6ea0cb16cd788680742
5d14f36f9a9259d37670928843d7862cb37c2c81
v1.0
instruct
Taco
Taco_12760_I
Write a program to determine the smallest common multiple of three given numbers greater than a specified number `x`. The common multiple must be divisible by all three numbers. Example 1: Input: a = 4, b = 5, c = 6, x = 10 Output: 60 Explanation: The smallest common multiple of 4, 5, and 6 greater than 10 is 60. Exa...
import math def lcm(a, b): return abs(a * b) // math.gcd(a, b) def smallest_common_multiple(a, b, c, x): multiple = lcm(lcm(a, b), c) if x % multiple == 0: return x + multiple else: return ((x // multiple) + 1) * multiple
from solution import smallest_common_multiple def test_example_1(): assert smallest_common_multiple(4, 5, 6, 10) == 60 def test_example_2(): assert smallest_common_multiple(3, 7, 9, 20) == 63 def test_example_3(): assert smallest_common_multiple(2, 3, 5, 50) == 60 def test_example_4(): assert smalle...
[ { "docstring": null, "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def smallest_common_multiple(a, b, c, x):", "function_name": "smallest_common_multiple", "parameter_list": "(a, b, c,...
[ 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 math import gcd\n\ndef lcm(a, b):\n \"\"\"Calculate the least common multiple of a and b.\"\"\"\n return a * b // gcd(a, b)\n\ndef smallest_common_multi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012760", "row_id": 12760, "seed_ids": "[8825]" }
0.688672
Taco_12760
I
[ "lcm", "smallest_common_multiple" ]
2
[ [ "smallest_common_multiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
924768410e258d33c968b9400f0467ef92a83626
6af69ee1dab76b611827b3c7d07f741c4585155a
v1.0
instruct
Taco
Taco_12831_I
Alice has recently learned about binary search trees (BST) in her data structures class. A binary search tree is a binary tree in which for each node, the value of all the nodes in the left subtree is less than the value of the node, and the value of all the nodes in the right subtree is greater than the value of the n...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def insert_into_bst(root, value): if root is None: return TreeNode(value) elif value < root.value: root.left = insert_into_bst(root.left, value) else: root.ri...
from solution import height_of_bst def test_height_of_bst_example1(): assert height_of_bst(9, [5, 3, 8, 1, 4, 7, 10, 2, 9]) == 3 def test_height_of_bst_example2(): assert height_of_bst(5, [10, 5, 15, 4, 6]) == 2 def test_height_of_bst_single_node(): assert height_of_bst(1, [42]) == 0 def test_height_of_...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key):\n self.left = None\n self.right = None\n self.val = key\n\ndef insert(root, key):\n if root i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00012831", "row_id": 12831, "seed_ids": "[5624]" }
0.622765
Taco_12831
I
[ "insert_into_bst", "compute_height", "height_of_bst" ]
3
[ [ "height_of_bst", "compute_height" ], [ "height_of_bst", "insert_into_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
e83d21e2d3c22606c9b5f4c20baea3318c31716d
32b3c11cb353fc1e2ae1b19c9a039ea6f39d3095
v1.0
instruct
Taco
Taco_12835_I
Maria is a nature enthusiast and loves tracking the movements of various species in the forest using her smart gadgets. Recently, she recorded GPS coordinates of a particularly elusive bird known for its erratic flying patterns. She wants to analyze these coordinates to determine the bird's longest uninterrupted straig...
def max_straight_path_length(test_cases): results = [] for N, points in test_cases: if N < 2: results.append(N) continue max_length = 0 for i in range(N): slopes = {} duplicate = 1 for j in range(i + 1, N): ...
def test_function(): test_cases = [ (5, [(1, 1), (2, 2), (3, 3), (4, 5), (5, 6)]), (4, [(1, 2), (4, 5), (7, 8), (10, 11)]), (3, [(0, 0), (0, 0), (0, 0)]), (6, [(1, 2), (2, 4), (3, 6), (4, 8), (5, 10), (6, 15)]), (2, [(1, 2), (1, 3)]) ] expected_results = [3, 4, 3, 5,...
[ { "docstring": null, "function_declaration": "def max_straight_path_length(test_cases):", "function_name": "max_straight_path_length", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def get_gcd(a, b):", "function_name": "get_gcd", "parameter_lis...
[ 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 gcd(a, b):\n \"\"\"\n Computes the greatest common divisor of a and b using the Euclidean algorithm.\n \"\"\"\n while b:\n a, b = b, a % b\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012835", "row_id": 12835, "seed_ids": "[7291]" }
0.695918
Taco_12835
I
[ "max_straight_path_length", "get_gcd" ]
2
[ [ "max_straight_path_length", "get_gcd" ] ]
1
[]
false
[]
false
pytest
false
[]
true
421506bddbf7dafaebaed92e2a7674f2bcdf678f
618c82ff03d9ec8acfee607fea2535029d01b733
v1.0
instruct
Taco
Taco_12841_I
You are given an undirected tree with $n$ nodes numbered from $1$ to $n$. A tree is an acyclic connected graph. Each node has a value associated with it. Your task is to find the maximum sum of nodes in a simple path between two nodes in this tree. A simple path is a path that does not revisit any node. You need to re...
import sys sys.setrecursionlimit(200000) def dfs(node, parent, graph, values, subtree_sum, max_sum): # base case if node not in graph: return 0 current_sum = values[node - 1] for neighbor in graph[node]: if neighbor == parent: continue child_sum = dfs(neighbor, ...
from solution import max_path_sum def test_case_1(): n = 5 values = [1, 2, 3, 4, 5] edges = [(1, 2), (1, 3), (3, 4), (3, 5)] assert max_path_sum(n, values, edges) == 15 def test_case_2(): n = 3 values = [1, 10, 10] edges = [(1, 2), (1, 3)] assert max_path_sum(n, values, edges) == 21 d...
[ { "docstring": null, "function_declaration": "def dfs(node, parent, graph, values, subtree_sum, max_sum):", "function_name": "dfs", "parameter_list": "(node, parent, graph, values, subtree_sum, max_sum)" }, { "docstring": null, "function_declaration": "def max_path_sum(n, values, edges):...
[ 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_max_sum_in_path(n, values, edges):\n from collections import defaultdict, deque\n \n def dfs(u, parent):\n max1, max2 = 0, 0\n glob...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012841", "row_id": 12841, "seed_ids": "[14888]" }
0.705716
Taco_12841
I
[ "dfs", "max_path_sum" ]
2
[ [ "max_path_sum", "dfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec24ef416fc53d69e601568617b1edc91a3d7022
0d6ffaa5cb118384c284c8a30d4eefa546cd656d
v1.0
instruct
Taco
Taco_12872_I
Given a sequence of numbers where each number in the sequence (except the first) is formed by reversing the digits of the previous number and adding `x`. Your task is to determine the `n`-th number in the sequence for different sets of test cases. The sequence `b` is defined as: - `b1 = start` - `b[n] = reverse(b[n-1]...
def reverse_number(num): """ Helper function to reverse the digits of a number. """ return int(str(num)[::-1]) def nth_number_in_sequence(start, x, n): """ Given the starting number `start`, the increment `x`, and the position `n`, this function returns the `n`-th number in the sequence. ...
import pytest from solution import nth_number_in_sequence, process_test_cases def test_reverse_number(): assert reverse_number(123) == 321 assert reverse_number(98765) == 56789 assert reverse_number(1000) == 1 assert reverse_number(5005) == 5005 def test_nth_number_in_sequence(): assert nth_number...
[ { "docstring": "Helper function to reverse the digits of a number.", "function_declaration": "def reverse_number(num):", "function_name": "reverse_number", "parameter_list": "(num)" }, { "docstring": "Given the starting number `start`, the increment `x`, and the position `n`,\nthis function ...
[ 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 reverse_number(y):\n \"\"\"\n Returns the number obtained by reversing the digits of y.\n \"\"\"\n return int(str(y)[::-1])\n\ndef nth_sequence_num...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00012872", "row_id": 12872, "seed_ids": "[24261]" }
0.769519
Taco_12872
I
[ "reverse_number", "nth_number_in_sequence", "process_test_cases" ]
3
[ [ "nth_number_in_sequence", "reverse_number" ], [ "process_test_cases", "nth_number_in_sequence" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
546c7de4d971be2ebe29a79a052a919fdbc943f4
70178337305d17c7e6982ccd22a12585f6073f06
v1.0
instruct
Taco
Taco_12911_I
Given an array of n integers, where the i-th integer represents the amount of money present at the i-th house. Houses are arranged in a circle. A thief plans to rob houses, but cannot rob consecutive houses due to an alarm system. As the houses are arranged in a circle, the first and last house are also considered cons...
def robHouses(nums): if len(nums) == 1: return nums[0] return max(rob_linear(nums[:-1]), rob_linear(nums[1:])) def rob_linear(nums): prev, curr = 0, 0 for num in nums: prev, curr = curr, max(curr, prev + num) return curr
from solution import robHouses def test_example_1(): assert robHouses([2, 3, 2]) == 3 def test_example_2(): assert robHouses([1, 2, 3, 1]) == 4 def test_example_3(): assert robHouses([1, 2, 3]) == 3 def test_single_house(): assert robHouses([5]) == 5 def test_two_houses(): assert robHouses([1, ...
[ { "docstring": null, "function_declaration": "def robHouses(nums):", "function_name": "robHouses", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def rob_linear(nums):", "function_name": "rob_linear", "parameter_list": "(nums)" } ]
[ 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 robHouses(nums):\n if len(nums) == 1:\n return nums[0]\n\n return max(rob_linear(nums[:-1]), rob_linear(nums[1:]))\n\ndef rob_linear(nums):\n p...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00012911", "row_id": 12911, "seed_ids": "[23991]" }
0.650296
Taco_12911
I
[ "robHouses", "rob_linear" ]
2
[ [ "robHouses", "rob_linear" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6d64e93fa8eb89a056dfdc3a5b3d984d30872b42
db66db27f47e813fd704cde3d9c7abfbed808dc6