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_55766_I
Jenny likes playing with strings and came up with a new game. She will provide a word, and the task is to determine the smallest number of contiguous substrings into which the word can be split such that each substring is a palindrome. A palindrome is a string that reads the same forward and backward. Input The first...
def is_palindrome(s): return s == s[::-1] def min_palindrome_partitions(s): n = len(s) dp = [0] * (n + 1) dp[n] = 0 for i in range(n - 1, -1, -1): min_cut = float('inf') for j in range(i, n): if is_palindrome(s[i:j+1]): min_cut = min(min_cut, 1 + dp[j+1]...
def test_min_palindrome_partitions_single_char(): assert min_palindrome_partitions("a") == 1 def test_min_palindrome_partitions_double_palindrome(): assert min_palindrome_partitions("aa") == 1 assert min_palindrome_partitions("ab") == 2 def test_min_palindrome_partitions_example_cases(): assert min_pa...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def min_palindrome_partitions(s):", "function_name": "min_palindrome_partitions", "parameter_list": "(s...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_palindrome_partitions(s):\n \"\"\"\n Returns the minimum number of contiguous substrings into which the input word \n can be split such that each ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00055766", "row_id": 55766, "seed_ids": "[14970]" }
0.770319
Taco_55766
I
[ "is_palindrome", "min_palindrome_partitions" ]
2
[ [ "min_palindrome_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
false
[]
true
83bd246b64d371cada2f86507ab30be769c77ba9
03ebea6aa0b8e84ed0864066b9108e50f9a4f367
v1.0
instruct
Taco
Taco_55833_I
Alice loves her art collection and wants to display her paintings in a unique way. She has a collection of 10 unique paintings and she wants to hang them in a hallway that has a series of picture frames arranged in a linear sequence. The constraints are such that neighboring picture frames should exhibit paintings that...
from itertools import permutations def calculate_relation_score(p1, p2): score = 0 if p1[1] == p2[1]: # same artist score += 3 if p1[2] == p2[2]: # same year score += 2 if p1[3] == p2[3]: # same type score += 1 return score def can_arrange_paintings(f, paintings): if...
from solution import can_arrange_paintings, calculate_relation_score def test_calculate_relation_score(): painting1 = ["MonaLisa", "LeonardoDaVinci", "1503", "Portrait"] painting2 = ["StarryNight", "VanGogh", "1889", "Landscape"] painting3 = ["GirlWithAPearlEarring", "Vermeer", "1665", "Portrait"] ass...
[ { "docstring": null, "function_declaration": "def calculate_relation_score(p1, p2):", "function_name": "calculate_relation_score", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def can_arrange_paintings(f, paintings):", "function_name": "can_arrange_pa...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef calculate_relation_score(p1, p2):\n score = 0\n if p1[1] == p2[1]: # same artist\n score += 3\n if p1[2]...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00055833", "row_id": 55833, "seed_ids": "[1387]" }
0.594787
Taco_55833
I
[ "calculate_relation_score", "can_arrange_paintings", "read_input" ]
3
[ [ "can_arrange_paintings", "calculate_relation_score" ] ]
1
[ "read_input" ]
false
[]
false
pytest
true
[]
true
2572f527f101fe4b80bd0e4838d78a5a8bd1d426
cb168f5086bffd424434b4190b7dd3877177a247
v1.0
instruct
Taco
Taco_55865_I
There is a square grid of size n × n, where each cell of the grid can be either traversable or blocked. Alice wants to navigate from the top-left cell (1, 1) to the bottom-right cell (n, n) using only right and down moves. She can also use teleportation gadgets, which allow her to move from one traversable cell directl...
from collections import deque def min_teleportation_gadgets(n, k, grid): def neighbors(x, y): for nx, ny in ((x+1, y), (x, y+1), (x-1, y), (x, y-1)): if 0 <= nx < n and 0 <= ny < n and grid[nx][ny] == '0': yield nx, ny start = (0, 0) end = (n-1, n-1) if gri...
def test_alice_can_reach_possible(): grid = [ "00000", "01110", "00000", "01110", "00000" ] assert alice_can_reach(5, 1, grid) == "YES 1" def test_alice_can_reach_impossible(): grid = [ "0100", "0110", "0000", "0111", ] ass...
[ { "docstring": null, "function_declaration": "def min_teleportation_gadgets(n, k, grid):", "function_name": "min_teleportation_gadgets", "parameter_list": "(n, k, grid)" }, { "docstring": null, "function_declaration": "def alice_can_reach(n, k, grid):", "function_name": "alice_can_re...
[ 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": "from collections import deque\n\ndef min_teleportations_needed(grid, n, k):\n # Directions for moving right and down\n directions = [(0, 1), (1, 0)]\n\n #...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00055865", "row_id": 55865, "seed_ids": "[2509]" }
0.728436
Taco_55865
I
[ "min_teleportation_gadgets", "alice_can_reach" ]
2
[ [ "alice_can_reach", "min_teleportation_gadgets" ] ]
1
[]
false
[]
false
pytest
false
[]
true
cca9f3089992deba01aad99508a85f8b66026507
74c508315f874db4d8cf364345d65423393b63c4
v1.0
instruct
Taco
Taco_55927_I
Anna has two arrays of integers `a` and `b` of length `n` and `m` respectively. She wants to find the maximum sum of elements she can obtain by selecting any subarray from `a` and another subarray from `b`, and then concatenate one after another. A subarray from array `a` is a contiguous portion of the array, so is a ...
def max_subarray_sum(array): """ Helper function to find the maximum subarray sum using Kadane's algorithm. """ max_current = max_global = array[0] for num in array[1:]: max_current = max(num, max_current + num) if max_current > max_global: max_global = max_current ...
from solution import max_concat_subarray_sum def test_example1(): a = [1, 2, 3, 4] b = [-1, 2, 3] assert max_concat_subarray_sum(a, b) == 15 def test_example2(): a = [-1, -2, -3, -4, -5] b = [1, 2, 3, 4] assert max_concat_subarray_sum(a, b) == 10 def test_all_negative(): a = [-1, -2, -3] ...
[ { "docstring": "Helper function to find the maximum subarray sum using Kadane's algorithm.", "function_declaration": "def max_subarray_sum(array):", "function_name": "max_subarray_sum", "parameter_list": "(array)" }, { "docstring": "Returns the maximum sum of any subarray from a concatenated...
[ 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 max_subarray_sum(array):\n \"\"\"\n Helper function to find the maximum subarray sum using Kadane's algorithm.\n \"\"\"\n max_current = max_global ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00055927", "row_id": 55927, "seed_ids": "[8853]" }
0.724009
Taco_55927
I
[ "max_subarray_sum", "max_concat_subarray_sum" ]
2
[ [ "max_concat_subarray_sum", "max_subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e81c5bc75a36c523d9e4395f17ac4fe3ae0d13da
80edbbf7fa7f11ec68899d6a82bc7c4006bd153d
v1.0
instruct
Taco
Taco_55931_I
Alyssa is working on a secret message system where each message is encoded based on a specific pattern. The encoding process involves shifting each character in the message a given number of positions forward in the alphabet, wrapping around if necessary. The rules for encoding are as follows: 1. Each character in th...
def encode_message(shift, message): """ Encodes a given message by shifting each letter by the specified shift value. Args: shift (int): The shift value (1 <= shift <= 25) message (str): The message to be encoded. Returns: str: The encoded message. """ encoded_message = [] ...
from solution import encode_message def test_encode_simple(): assert encode_message(3, "hello world") == "khoor zruog" def test_encode_with_max_shift(): assert encode_message(25, "hello world") == "gdkkn vnqkc" def test_encode_with_wrap_around(): assert encode_message(1, "xyz") == "yza" assert encode...
[ { "docstring": "Encodes a given message by shifting each letter by the specified shift value.\n\nArgs:\nshift (int): The shift value (1 <= shift <= 25)\nmessage (str): The message to be encoded.\n\nReturns:\nstr: The encoded message.", "function_declaration": "def encode_message(shift, message):", "func...
[ 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 encode_message(shift, message):\n \"\"\"\n Encodes the message by shifting each letter by the given shift value.\n \n Args:\n shift (int): The f...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00055931", "row_id": 55931, "seed_ids": "[1126]" }
0.641004
Taco_55931
I
[ "encode_message", "encoder" ]
2
[ [ "encoder", "encode_message" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d45491212ec4a6ae015574af52521e6e21f4cc32
51fe3b08aae9bbd489f0de65a69666a8b72633d3
v1.0
instruct
Taco
Taco_55941_I
In the kingdom of Oddland, the kingdom's balance is maintained using an ancient number system consisting of bizarre properties. One such property is that the sum of the digits of a number should be an odd number. Albert, the new head of Oddland Academy, has come up with an interesting problem for his students. Given ...
def sum_of_digits(n): """ Returns the sum of digits of the number n. """ return sum(int(digit) for digit in str(n)) def oddland_number(N): """ Returns the smallest integer greater than or equal to N whose sum of digits is odd. """ while sum_of_digits(N) % 2 == 0: N += 1 ...
from solution import oddland_number def test_oddland_number_example1(): assert oddland_number(47) == 47 def test_oddland_number_example2(): assert oddland_number(28) == 29 def test_oddland_number_edge_case(): assert oddland_number(1) == 1 def test_oddland_number_increment(): assert oddland_number(44...
[ { "docstring": "Returns the sum of digits of the number n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the smallest integer greater than or equal to N \nwhose sum of digits is odd.", "function_dec...
[ 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 sum_of_digits_is_odd(n):\n \"\"\"\n Returns True if the sum of digits of n is odd, else returns False.\n \"\"\"\n return sum(int(digit) for digit i...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00055941", "row_id": 55941, "seed_ids": "[16736]" }
0.679554
Taco_55941
I
[ "sum_of_digits", "oddland_number" ]
2
[ [ "oddland_number", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f695250d9b01b45fb1f845dba8d1dd0770813fef
4d27a9abcb63389cdbfdc34cc73c9b1fa8f22c1c
v1.0
instruct
Taco
Taco_55945_I
Jacob works for a company where he needs to analyze sequences of numbers. His task is to determine whether a given sequence can be split into two non-empty subsequences such that each subsequence is sorted in strictly increasing or strictly decreasing order. Note that the subsequences do not need to be contiguous porti...
def can_split_sequence(sequence): n = len(sequence) inc_ord = sorted(sequence) dec_ord = sorted(sequence, reverse=True) if inc_ord != sequence and dec_ord != sequence: return "YES" else: return "NO" def analyze_sequences(test_cases): results = [] for test_case in test_cases...
def test_can_split_sequence_scenario1(): assert can_split_sequence([5, 1, 4, 3, 2]) == "YES" def test_can_split_sequence_scenario2(): assert can_split_sequence([4, 3, 2, 1]) == "NO" def test_can_split_sequence_scenario3(): assert can_split_sequence([2, 4, 1, 5, 3, 6]) == "YES" def test_can_split_sequence...
[ { "docstring": null, "function_declaration": "def can_split_sequence(sequence):", "function_name": "can_split_sequence", "parameter_list": "(sequence)" }, { "docstring": null, "function_declaration": "def analyze_sequences(test_cases):", "function_name": "analyze_sequences", "par...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_split(nums):\n n = len(nums)\n \n # Check strictly increasing subsequences\n inc = [nums[0]]\n for i in range(1, n):\n if nums[i] ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00055945", "row_id": 55945, "seed_ids": "[5681]" }
0.748505
Taco_55945
I
[ "can_split_sequence", "analyze_sequences", "process_input" ]
3
[ [ "analyze_sequences", "can_split_sequence" ], [ "process_input", "analyze_sequences" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
d1dcc3182f96ddcff16bdfe02a44f7d9fba5e39b
0a37e3a20ead401cc4c3baca9ccce0cc1af8769f
v1.0
instruct
Taco
Taco_55970_I
You are given an array of n positive integers. In one operation, you can select any two adjacent elements in the array, remove them, and insert their sum back into the array. The goal is to determine if it is possible to reduce the array to a single element which is a prime number. If it is possible, output "YES" and p...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def reduce_to_prime(n, arr): ...
from solution import reduce_array_to_prime def test_prime_array(): import io import sys captured_output = io.StringIO() sys.stdout = captured_output reduce_array_to_prime(5, [2, 3, 5, 7, 11]) sys.stdout = sys.__stdout__ assert "YES" in captured_output.getvalue() def test_small_array(): ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def reduce_to_prime(n, arr):", "function_name": "reduce_to_prime", "parameter_list": "(n, arr)" }, { ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "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": "00055970", "row_id": 55970, "seed_ids": "[21558]" }
0.715476
Taco_55970
I
[ "is_prime", "reduce_to_prime", "reduce_array_to_prime" ]
3
[ [ "reduce_array_to_prime", "reduce_to_prime" ], [ "reduce_to_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
50e820711b59d9a43cbe4c35f19bd43eb4691b19
f68484af1892e1b81daf0b77b909d96f1a0288d9
v1.0
instruct
Taco
Taco_55992_I
Dr. Adams is researching a specific type of number transformation and calls it ‘Digit Swap Square’. A number is transformed by swapping any two of its digits once. If any such permutation leads to a number that is a perfect square, then the original number is considered a Digit Swap Square. For example, 81 becomes a pe...
import math def is_perfect_square(x): """ Returns True if x is a perfect square, False otherwise. """ root = int(math.sqrt(x)) return root * root == x def digit_swap_square(q, queries): """ For each number in queries, check if any permutation of its digits (including the number itself) is ...
def test_digit_swap_square(): assert digit_swap_square(3, [13, 82, 144]) == ["NO", "NO", "YES"] def test_digit_swap_square_single_digit(): assert digit_swap_square(1, [1]) == ["YES"] assert digit_swap_square(1, [2]) == ["NO"] def test_digit_swap_square_double_digit(): assert digit_swap_square(1, [49])...
[ { "docstring": "Returns True if x is a perfect square, False otherwise.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": "For each number in queries, check if any permutation of its digits (including the nu...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_digit_swap_square(n):\n \"\"\"\n Determines if any permutation of the digits of n is a perfect square.\n \"\"\"\n from math import isqrt, sqrt\n...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00055992", "row_id": 55992, "seed_ids": "[19806]" }
0.652671
Taco_55992
I
[ "is_perfect_square", "digit_swap_square" ]
2
[ [ "digit_swap_square", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0fbcdbb7d2eea6898648c401b80b1d451e2b49a4
96cf09e6f9da99f5b76027621238782ce3c154d2
v1.0
instruct
Taco
Taco_56033_I
Given an integer array A of length N, compute the prefix sum array P where P[i] denotes the sum of elements from the start of the array up to the i-th element, inclusive. Then, find the sum of all unique values in the prefix sum array P. ------ Input Format ------ - The first line contains an integer T, the number of...
def compute_prefix_sum_array(A): """ Computes the prefix sum array for a given array A. """ P = [0] * len(A) P[0] = A[0] for i in range(1, len(A)): P[i] = P[i-1] + A[i] return P def sum_of_unique_prefix_sums(A): """ Computes the sum of all unique values in the prefix sum arr...
def test_compute_prefix_sum_array(): assert compute_prefix_sum_array([1, 2, 3, 4, 5]) == [1, 3, 6, 10, 15] assert compute_prefix_sum_array([1, 1, 1, 1]) == [1, 2, 3, 4] assert compute_prefix_sum_array([5, 5, 5, 5]) == [5, 10, 15, 20] def test_sum_of_unique_prefix_sums(): assert sum_of_unique_prefix_sum...
[ { "docstring": "Computes the prefix sum array for a given array A.", "function_declaration": "def compute_prefix_sum_array(A):", "function_name": "compute_prefix_sum_array", "parameter_list": "(A)" }, { "docstring": "Computes the sum of all unique values in the prefix sum array.", "funct...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def prefix_sum_unique(arr):\n \"\"\"\n Given an array of integers, computes the prefix sum array and returns the sum of all unique values in it.\n \"\"\"\...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00056033", "row_id": 56033, "seed_ids": "[19497]" }
0.688035
Taco_56033
I
[ "compute_prefix_sum_array", "sum_of_unique_prefix_sums", "process_test_cases", "main" ]
4
[ [ "process_test_cases", "sum_of_unique_prefix_sums" ], [ "sum_of_unique_prefix_sums", "compute_prefix_sum_array" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
a4fd6025ae707b84010b85df2cebb0af93dcf18c
d46bcd0df18d78356233f0ff06f761144f06c6d0
v1.0
instruct
Taco
Taco_56102_I
Given an integer array `arr` of size `n`, you need to determine if there exist two distinct indices i and j such that the product of elements at these indices is a perfect square. A perfect square is an integer that is the square of another integer (for example, 1, 4, 9, 16, etc.). Input The first line contains an int...
import math from itertools import combinations def is_perfect_square(x): root = int(math.isqrt(x)) return root * root == x def find_perfect_square_product(arr): for i, j in combinations(range(len(arr)), 2): if is_perfect_square(arr[i] * arr[j]): return "YES" return "NO"
from solution import find_perfect_square_product def test_example1(): arr = [2, 3, 4, 6, 8] assert find_perfect_square_product(arr) == "YES" def test_example2(): arr = [11, 13, 17, 19] assert find_perfect_square_product(arr) == "NO" def test_single_element(): arr = [5] assert find_perfect_squ...
[ { "docstring": null, "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def find_perfect_square_product(arr):", "function_name": "find_perfect_square_product", "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 math\nfrom itertools import combinations\n\ndef is_perfect_square(x):\n root = int(math.isqrt(x))\n return root * root == x\n\ndef find_perfect_square...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00056102", "row_id": 56102, "seed_ids": "[15202]" }
0.660453
Taco_56102
I
[ "is_perfect_square", "find_perfect_square_product" ]
2
[ [ "find_perfect_square_product", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
228c1576e90b24f81e0761bc116bd6d0923966ef
89e1b8a8876913b275c68594326d1d2d15747298
v1.0
instruct
Taco
Taco_56116_I
In a small village, there are n houses arranged in a row. Each house has a certain amount of coin treasure. Thieves plan to rob the houses and want to maximize the amount of treasure they can steal. However, they have a simple constraint: if they rob two adjacent houses, the police will be alerted. Therefore, they need...
def max_robbery(treasures): """ Given a list of treasures in each house, this function returns the maximum amount of treasure the thieves can steal without alerting the police by robbing two adjacent houses. """ n = len(treasures) if n == 0: return 0 if n == 1: return tre...
from solution import max_treasure def test_example1(): assert max_treasure(5, [2, 7, 9, 3, 1]) == 12 def test_example2(): assert max_treasure(3, [2, 1, 4]) == 6 def test_example3(): assert max_treasure(6, [5, 5, 10, 40, 50, 35]) == 80 def test_single_house(): assert max_treasure(1, [7]) == 7 def te...
[ { "docstring": "Given a list of treasures in each house, this function returns the maximum\namount of treasure the thieves can steal without alerting the police by\nrobbing two adjacent houses.", "function_declaration": "def max_robbery(treasures):", "function_name": "max_robbery", "parameter_list":...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_treasure(n, treasures):\n if n == 1:\n return treasures[0]\n \n dp = [0] * n\n dp[0] = treasures[0]\n dp[1] = max(treasures[0], treas...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056116", "row_id": 56116, "seed_ids": "[22923]" }
0.726934
Taco_56116
I
[ "max_robbery", "max_treasure" ]
2
[ [ "max_treasure", "max_robbery" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cbf188ec602afdc7851255b059840adee01776dc
7e80234efdd356cfdc3d82f02d7e9f902161913a
v1.0
instruct
Taco
Taco_56229_I
You are given a rectangular grid of size N x M where each cell contains a non-negative integer representing an elevation map. The task is to find the minimum effort path from the top-left cell (0, 0) to the bottom-right cell (N-1, M-1). A path is defined as a sequence of adjacent cells in the grid where you move from ...
from heapq import heappop, heappush import sys def minimum_effort_path(elevation): N, M = len(elevation), len(elevation[0]) directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] # Using a priority queue to track cells to visit, starting with the top-left corner (0,0) pq = [(0, 0, 0)] # (effort, row, co...
from solution import main def test_example_case(): input_string = "3\n3 3\n1 2 2\n3 8 2\n5 3 5\n2 2\n1 2\n3 4\n4 4\n1 2 2 3\n3 8 2 7\n5 8 5 9\n6 3 4 1\n" expected_output = "2\n2\n3" assert main(input_string) == expected_output def test_single_cell(): input_string = "1\n1 1\n0\n" expected_output = ...
[ { "docstring": null, "function_declaration": "def minimum_effort_path(elevation):", "function_name": "minimum_effort_path", "parameter_list": "(elevation)" }, { "docstring": null, "function_declaration": "def solve_minimum_effort_path(test_cases):", "function_name": "solve_minimum_ef...
[ 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 heapq\n\ndef minimum_effort_path(elevation_map):\n \"\"\"\n Function to find the minimum effort path from top-left to bottom-right of the grid.\n \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056229", "row_id": 56229, "seed_ids": "[18708]" }
0.678648
Taco_56229
I
[ "minimum_effort_path", "solve_minimum_effort_path", "parse_input", "format_output", "main" ]
5
[ [ "solve_minimum_effort_path", "minimum_effort_path" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
eab50460f113a639f0fd815e2a25d0e9345d73a4
1780a4379cd8c61b17a4372e536561ecff04bd01
v1.0
instruct
Taco
Taco_56278_I
Given a string S. The task is to check if it contains any anagram of a pattern P by completing the functions findAnagrams() and checkInclusion(). The function checkInclusion() should return `true` if the pattern's anagram is found as a substring within the given string, and `false` otherwise. The function findAnagrams(...
def findAnagrams(s: str, p: str): from collections import Counter len_s, len_p = len(s), len(p) if len_p > len_s: return [] p_count = Counter(p) s_count = Counter() result = [] for i in range(len_s): s_count[s[i]] += 1 if i >= len_p: if s_count[s[i - l...
from solution import findAnagrams, checkInclusion def test_example_1(): s = "cbaebabacd" p = "abc" assert findAnagrams(s, p) == [0, 6] assert checkInclusion(s, p) == True def test_example_2(): s = "af" p = "be" assert findAnagrams(s, p) == [] assert checkInclusion(s, p) == False def t...
[ { "docstring": null, "function_declaration": "def findAnagrams(s, p):", "function_name": "findAnagrams", "parameter_list": "(s, p)" }, { "docstring": null, "function_declaration": "def checkInclusion(s, p):", "function_name": "checkInclusion", "parameter_list": "(s, p)" } ]
[ 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 findAnagrams(s: str, p: str):\n from collections import Counter\n\n len_s, len_p = len(s), len(p)\n if len_p > len_s:\n return []\n\n p_coun...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00056278", "row_id": 56278, "seed_ids": "[12903]" }
0.696249
Taco_56278
I
[ "findAnagrams", "checkInclusion" ]
2
[ [ "checkInclusion", "findAnagrams" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3720e94e393f3fb88c165ca7968de527218e099c
670e009e210a3176da7a2c22586a8908823d8d54
v1.0
instruct
Taco
Taco_56344_I
Tommy is organizing a sports league with `n` distinct teams labeled from 1 to `n`. He wants to schedule matches such that each team plays with exactly one other team. However, due to various constraints, not all teams can play against each other. Tommy seeks your help to find if it's possible to schedule the matches in...
def find_matches(n, m, pairs): from collections import defaultdict import networkx as nx if n % 2 == 1: return -1 graph = defaultdict(list) for a, b in pairs: graph[a].append(b) graph[b].append(a) matching = [] visited = set() def dfs(node, match): ...
from solution import find_matches, schedule_matches def test_example1(): n = 4 m = 3 pairs = [(1, 2), (2, 3), (3, 4)] result = find_matches(n, m, pairs) assert result == [(1, 2), (3, 4)] def test_example2(): n = 3 m = 2 pairs = [(1, 2), (2, 3)] result = find_matches(n, m, pairs...
[ { "docstring": null, "function_declaration": "def find_matches(n, m, pairs):", "function_name": "find_matches", "parameter_list": "(n, m, pairs)" }, { "docstring": null, "function_declaration": "def schedule_matches(n, m, pair_list):", "function_name": "schedule_matches", "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": "def find_matches(n, m, pairs):\n from collections import defaultdict\n import networkx as nx\n\n if n % 2 == 1:\n return -1\n\n graph = defaultd...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00056344", "row_id": 56344, "seed_ids": "[16591]" }
0.758834
Taco_56344
I
[ "find_matches", "schedule_matches" ]
2
[ [ "schedule_matches", "find_matches" ] ]
1
[]
false
[]
false
pytest
true
[ "networkx" ]
false
7beac3399f0b97bacacd1f431c20a00962e16954
520805f5001a9ee61f83902860ac91082ce8234e
v1.0
instruct
Taco
Taco_56357_I
Given a Binary Search Tree and an integer key. The task is to delete the node with the given key from the BST and return the new root. Example 1: Input: 5 / \ 3 7 / \ / \ 2 4 6 8 Key: 3 Output: 5 / \ 2 7 \ / \ ...
class TreeNode: def __init__(self, key): self.val = key self.left = None self.right = None def deleteNode(root, key): if not root: return root if key < root.val: root.left = deleteNode(root.left, key) elif key > root.val: root.right = deleteNode(root.rig...
import pytest from solution import TreeNode, deleteNode, inorderTraversal def test_delete_node_case1(): root = TreeNode(5) root.left = TreeNode(3) root.right = TreeNode(7) root.left.left = TreeNode(2) root.left.right = TreeNode(4) root.right.left = TreeNode(6) root.right.right = TreeNode(8)...
[]
[ 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.val = key\n self.left = None\n self.right = None\n\ndef deleteNode(root, key):\n if no...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00056357", "row_id": 56357, "seed_ids": "[14238]" }
0.562047
Taco_56357
I
[ "deleteNode", "minValueNode", "inorderTraversal" ]
3
[ [ "deleteNode", "minValueNode" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
c1342b2e4be3ebe8b82fddcaa27e0cb826a4e01b
ed0589d2dd4b7cd70831ecd7c29e3395b0f3cb08
v1.0
instruct
Taco
Taco_56395_I
**DESCRIPTION:** A software company is developing a new data processing software that takes lists of integers and performs certain operations on them. One feature they want to include is a function that, given a list of integers, returns the average of all the prime numbers within the list. A prime number is a number ...
def is_prime(n): """ Returns True if n is a prime number, otherwise returns False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True de...
from solution import average_primes def test_average_primes_with_mixed_numbers(): assert average_primes([2, 3, 4, 5, 6, 7, 8, 9]) == 4.25 def test_average_primes_with_no_primes(): assert average_primes([10, 15, 20, 25, 30]) == 0.0 def test_average_primes_with_all_primes(): assert average_primes([11, ...
[ { "docstring": "Returns True if n is a prime number, otherwise returns False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the average of all the prime numbers in the list.\nIf there are no prime numbers, return...
[ 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 \"\"\"A helper function to check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056395", "row_id": 56395, "seed_ids": "[9594]" }
0.58269
Taco_56395
I
[ "is_prime", "average_primes" ]
2
[ [ "average_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
62b3958e64c2a9d7696823074362c38d060e795b
7dba4d874a17e191dba621d4ffc1371133f6c8c7
v1.0
instruct
Taco
Taco_56448_I
You are given a series of tasks. Each task consists of climbing a staircase with `n` steps. You can climb the stairs by taking either one step or two steps at a time. Calculate the number of unique ways to climb to the top for each task. Input The input consists of multiple test cases. Each test case is represented ...
def count_ways(n): """ Return the number of unique ways to climb a staircase with n steps. """ if n == 0: return 0 elif n == 1: return 1 elif n == 2: return 2 # Using dynamic programming to store the number of ways to solve subproblems dp = [0] * (n + 1) ...
from solution import count_ways, process_staircases def test_count_ways(): assert count_ways(0) == 0 assert count_ways(1) == 1 assert count_ways(2) == 2 assert count_ways(3) == 3 assert count_ways(4) == 5 assert count_ways(5) == 8 assert count_ways(10) == 89 def test_process_staircases(): ...
[ { "docstring": "Return the number of unique ways to climb a staircase with n steps.", "function_declaration": "def count_ways(n):", "function_name": "count_ways", "parameter_list": "(n)" }, { "docstring": "Process a list of steps, and return a list of results for each\nsteps count in the for...
[ 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 climb_stairs(n):\n \"\"\"\n Calculate the number of unique ways to climb to the top of a staircase with n steps.\n You can either take 1 step or 2 ste...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056448", "row_id": 56448, "seed_ids": "[1843]" }
0.744677
Taco_56448
I
[ "count_ways", "process_staircases" ]
2
[ [ "process_staircases", "count_ways" ] ]
1
[]
false
[]
false
pytest
true
[]
true
533fe6d9052ae82c5252d4c3890fdbdcbdbb6068
a9cccdfb857b9e15e8530386caf946a6c8a0a544
v1.0
instruct
Taco
Taco_56500_I
Quentin is planning his vegetable garden! He starts with two integers \(M\) and \(D\). His goal is to determine if it's possible to arrange \(D\) vegetable plots in a grid of size \(M \times M\), such that: - Each plot is a 1x1 square. - No two plots share a row or a column. - The Manhattan distance between any two plo...
def find_plots(M, D): """ Function to find possible coordinates for D vegetable plots in an MxM grid. """ if D > M: return "This arrangement is not possible" plots = [] for i in range(D): plots.append((i, i)) return plots def vegetable_garden(test_cases): ...
def test_find_plots(): # test case 1 assert find_plots(4, 3) == [(0, 0), (1, 1), (2, 2)] # test case 2 assert find_plots(5, 5) == [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)] # test case 3 - expecting impossible assert find_plots(5, 6) == "This arrangement is not possible" # test ...
[ { "docstring": "Function to find possible coordinates for D vegetable plots in an MxM grid.", "function_declaration": "def find_plots(M, D):", "function_name": "find_plots", "parameter_list": "(M, D)" }, { "docstring": null, "function_declaration": "def vegetable_garden(test_cases):", ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def plot_vegetable_garden(T, test_cases):\n results = []\n \n for M, D in test_cases:\n if D > (M + 1) // 2:\n results.append(\"This arr...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00056500", "row_id": 56500, "seed_ids": "[17744]" }
0.676703
Taco_56500
I
[ "find_plots", "vegetable_garden" ]
2
[ [ "vegetable_garden", "find_plots" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4282e45c70b797f08ca9620ffed50181b2dcbe56
0cf8185fe53b0ee982708432b7cea1f2e2af5cd6
v1.0
instruct
Taco
Taco_56547_I
John is obsessed with palindromes. He believes that palindromic numbers possess special properties and wants to explore them further. Given a number M, he wants to find the smallest palindromic number which is strictly greater than M. -----Input----- First line of input contains number of test cases T. For each test ...
def is_palindrome(num): return str(num) == str(num)[::-1] def next_palindrome(M): M = int(M) while True: M += 1 if is_palindrome(M): return M def find_palindromes_for_test_cases(test_cases): results = [] for M in test_cases: results.append(next_palindrome(M)) ...
from solution import main def test_example_cases(): input_data = "2\n123\n808" expected_output = "131\n818" assert main(input_data) == expected_output def test_single_digit_palindrome(): input_data = "1\n5" expected_output = "6" assert main(input_data) == expected_output def test_larger_palin...
[ { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def next_palindrome(M):", "function_name": "next_palindrome", "parameter_list": "(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": "def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\ndef next_palindrome(m):\n m += 1\n while not is_palindrome(m):\n m += 1\n return m\n\nd...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056547", "row_id": 56547, "seed_ids": "[15767]" }
0.720927
Taco_56547
I
[ "is_palindrome", "next_palindrome", "find_palindromes_for_test_cases", "main" ]
4
[ [ "find_palindromes_for_test_cases", "next_palindrome" ], [ "next_palindrome", "is_palindrome" ] ]
2
[ "find_palindromes_for_test_cases" ]
false
[]
false
pytest
true
[]
true
139631915fd72e6b8b3c28b9d3d657fc622cb583
7c483ba819c00983643561d406e1db47621f3ad4
v1.0
instruct
Taco
Taco_56590_I
Given a file system represented as a tree rooted at the directory "/", you need to implement a function to list all files under a given directory path. Each file or directory is represented as a string. Directories are represented as paths ending with a slash ("/"). Your task is to write a function `listFiles` that tak...
from typing import List # This would be a mock function for the example def isFile(path: str) -> bool: """ Mock `isFile` function definition. This function should determine whether the given path is a file. It's expected to return `True` if the path is a file, `False` if it's a directory. """ f...
from solution import listFiles def test_list_files_root(): result = listFiles("/") assert sorted(result) == sorted(["/file4.txt", "/folder1/file1.txt", "/folder1/folder2/file2.txt", "/folder1/folder3/file3.txt"]) def test_list_files_folder1(): result = listFiles("/folder1/") assert sorted(result) == s...
[ { "docstring": "Mock `isFile` function definition.\nThis function should determine whether the given path is a file.\nIt's expected to return `True` if the path is a file, `False` if it's a directory.", "function_declaration": "def isFile(path):", "function_name": "isFile", "parameter_list": "(path)...
[ 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 typing import List\n\n# Helper functions provided for the solution\ndef isFile(path: str) -> bool:\n file_system = {\n \"/\": False,\n \"/fol...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00056590", "row_id": 56590, "seed_ids": "[2194]" }
0.743205
Taco_56590
I
[ "isFile", "listFiles" ]
2
[ [ "listFiles", "isFile" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c3593cfb1e7c75efae76073bf9204a93050d9a48
e588de6182d8871d921fba8e74455379c4431719
v1.0
instruct
Taco
Taco_56605_I
Given an integer `n`, your task is to determine if it can be represented as a sum of three prime numbers. If it is possible, return one possible combination as a list `[p1, p2, p3]` where `p1`, `p2`, and `p3` are prime numbers. If there are multiple solutions, return any one of them. If no such combination exists, retu...
def is_prime(num): """ Helper function to check if a number is prime. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def prime_sum_triple(n): """ Function to determine if n can be represented as ...
from solution import prime_sum_triple def test_prime_sum_triple_existence(): assert prime_sum_triple(30) != [] assert prime_sum_triple(17) != [] assert prime_sum_triple(23) != [] assert prime_sum_triple(30000) != [] def test_prime_sum_triple_specific_cases(): # 30 can be 7 + 11 + 12 or any other v...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to determine if n can be represented as a sum of three prime numbers.\nReturns one possible combin...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num < 2:\n return False\n for i in range(2, int(nu...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00056605", "row_id": 56605, "seed_ids": "[9397]" }
0.600926
Taco_56605
I
[ "is_prime", "prime_sum_triple" ]
2
[ [ "prime_sum_triple", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
533a4a9219e332243e96e28fd18ede6ecdd79c27
2a139f592cfd6d1e1d35b96d4799141d09d57d3f
v1.0
instruct
Taco
Taco_56623_I
You are given a list of integers, and you have to determine the length of the longest subsequence such that when sorted, every pair of adjacent elements have a product that is a perfect square. A perfect square is an integer that can be expressed as the square of another integer. For example, 4, 9, and 16 are perfect ...
def is_perfect_square(num): """ Checks if a number is a perfect square. """ root = int(num**0.5) return root * root == num def longest_subsequence_with_perfect_square_product(arr): """ Returns the length of the longest subsequence such that when sorted, every pair of adjacent elements h...
from solution import longest_subsequence_with_perfect_square_product def test_example_1(): assert longest_subsequence_with_perfect_square_product([1, 4, 16, 9, 25]) == 5 def test_example_2(): assert longest_subsequence_with_perfect_square_product([2, 3, 5, 7, 11, 13]) == 1 def test_single_element(): asse...
[ { "docstring": "Checks if a number is a perfect square.", "function_declaration": "def is_perfect_square(num):", "function_name": "is_perfect_square", "parameter_list": "(num)" }, { "docstring": "Returns the length of the longest subsequence such that\nwhen sorted, every pair of adjacent ele...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_perfect_square(num):\n \"\"\"\n Checks if a number is a perfect square.\n \"\"\"\n root = int(num**0.5)\n return root * root == num\n\ndef lo...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00056623", "row_id": 56623, "seed_ids": "[7473]" }
0.671893
Taco_56623
I
[ "is_perfect_square", "longest_subsequence_with_perfect_square_product" ]
2
[ [ "longest_subsequence_with_perfect_square_product", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
341f8622c30922408a6a629fcbc121aa03f3ebff
50b54c320dcbe5d65d2856c7bd084d3528392fce
v1.0
instruct
Taco
Taco_56645_I
Alice is a gardener and she loves planting different types of flowers in her garden. She plants flowers in a straight line and wants to maximize the beauty of her garden by having contiguous segments of flowers that bloom. Each type of flower blooms at a certain time and lasts for a certain duration. Given an array b...
def max_bloom_flowers(bloom, wilt): events = [] for i in range(len(bloom)): events.append((bloom[i], 1)) # +1 for bloom events.append((wilt[i] + 1, -1)) # -1 for wilt (end of bloom day + 1) # Sort events by days; if same day, end event (-1) comes before start event (+1) events.sort(ke...
from solution import max_number_of_flowers def test_sample_case(): assert max_number_of_flowers(5, [1, 2, 3, 4, 5], [3, 4, 5, 6, 7]) == 3 def test_no_overlap(): assert max_number_of_flowers(3, [1, 5, 10], [2, 6, 12]) == 1 def test_full_overlap(): assert max_number_of_flowers(3, [1, 1, 1], [5, 5, 5]) == 3...
[ { "docstring": null, "function_declaration": "def max_bloom_flowers(bloom, wilt):", "function_name": "max_bloom_flowers", "parameter_list": "(bloom, wilt)" }, { "docstring": null, "function_declaration": "def max_number_of_flowers(n, bloom, wilt):", "function_name": "max_number_of_fl...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_flowers_in_bloom(bloom, wilt):\n \"\"\"\n Determines the maximum number of flowers that are in bloom simultaneously.\n \"\"\"\n events = []\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056645", "row_id": 56645, "seed_ids": "[20924]" }
0.617527
Taco_56645
I
[ "max_bloom_flowers", "max_number_of_flowers" ]
2
[ [ "max_number_of_flowers", "max_bloom_flowers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d752c995e5c484e7180494b38a62ce65d45f599
2e20836374496747cc670ec7272d998f5b1fe68f
v1.0
instruct
Taco
Taco_56698_I
# Task You are given a list of `n` integers, where each integer represents the number of pages in a particular book. You are also given `k` number of students. Your task is to allocate books to each student in such a way that the maximum number of pages assigned to a student is minimized. Each student must get at least...
def can_allocate_books(books, n, k, max_pages): """ Helper function to check if it's possible to allocate books such that the maximum number of pages assigned to a student is less than or equal to max_pages. """ students_required = 1 current_pages = 0 for pages in books: if curr...
from solution import allocate_books def test_allocate_books_example(): assert allocate_books([12, 34, 67, 90], 2) == 113 def test_allocate_books_single_book_per_student(): assert allocate_books([12, 34, 67, 90], 4) == 90 def test_allocate_books_single_student(): assert allocate_books([12, 34, 67, 90], 1)...
[ { "docstring": "Helper function to check if it's possible to allocate books such that\nthe maximum number of pages assigned to a student is less than or equal to max_pages.", "function_declaration": "def can_allocate_books(books, n, k, max_pages):", "function_name": "can_allocate_books", "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 is_valid_distribution(books, n, k, max_pages):\n students_required = 1\n current_sum = 0\n\n for pages in books:\n if current_sum + pages > max...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056698", "row_id": 56698, "seed_ids": "[19796]" }
0.749477
Taco_56698
I
[ "can_allocate_books", "allocate_books" ]
2
[ [ "allocate_books", "can_allocate_books" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c310eaa145df17dfeb82b7321a3979917eb61dc5
f2285bd290815d66673a7e00006dd025e4adb89e
v1.0
instruct
Taco
Taco_56703_I
A kingdom consists of N cities and M bidirectional roads that connect pairs of cities. Each road has a certain travel cost associated with it. The king wants to construct a network where every citizen can travel between any two cities with the minimum total travel cost. The king decided to build this network as a Minim...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] = xroot e...
def test_minimum_total_travel_cost(): # Test Sample Input N, M = 4, 5 roads = [ (1, 2, 5), (2, 3, 3), (1, 3, 7), (4, 3, 2), (4, 1, 6) ] assert minimum_total_travel_cost(N, M, roads) == 10 # Test Larger Input N, M = 3, 3 roads = [ (1, 2, 1)...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n \ndef union(parent, rank, x, y):\n xroot ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056703", "row_id": 56703, "seed_ids": "[7688]" }
0.742646
Taco_56703
I
[ "find", "union", "minimum_total_travel_cost" ]
3
[ [ "minimum_total_travel_cost", "find" ], [ "minimum_total_travel_cost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
6738974e7180b9c518d3512db9107315312e9b97
f59177aec2c0831b2f8eef333ccfd01c0916c741
v1.0
instruct
Taco
Taco_56709_I
In a faraway land, there is a special sequence of numbers known as "Mystic Numbers." Mystic Numbers follow a unique rule based on binary representation of numbers. Let's understand the special property of these numbers. A number N is called a Mystic Number if the count of '1's in its binary representation is a prime n...
def is_prime(n): """Utility function to check if a number is prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 r...
from solution import is_prime, is_mystic_number, mystic_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(18) == False def test_is_mystic_number(): assert is_mystic_number(6) == True # bin...
[ { "docstring": "Utility function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Function to determine if a number is a Mystic Number.", "function_declaration": "def is_mystic_number(x):"...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n retur...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00056709", "row_id": 56709, "seed_ids": "[20420]" }
0.61467
Taco_56709
I
[ "is_prime", "is_mystic_number", "mystic_numbers" ]
3
[ [ "is_mystic_number", "is_prime" ], [ "mystic_numbers", "is_mystic_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6d09516641bcf2e4e686473024ffe165415b020f
4367367b26589322cbd5906397bd4d7dd413c886
v1.0
instruct
Taco
Taco_56792_I
Given an array of positive integers, rearrange the elements to form the maximum possible integer and return that integer. Example 1: Input: arr = [3, 30, 34, 5, 9] Output: 9534330 Explanation: By arranging elements in descending order, you will form 9534330 which is the largest possible integer. Example 2: Input: arr...
from functools import cmp_to_key def compare(x, y): """ Compare two elements by their possible concatenations in both orders. """ if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def maxInteger(arr): """ Given an array of positive integers...
from solution import maxInteger def test_example_1(): assert maxInteger([3, 30, 34, 5, 9]) == "9534330" def test_example_2(): assert maxInteger([1, 10, 2]) == "2110" def test_single_element(): assert maxInteger([5]) == "5" def test_all_same_digits(): assert maxInteger([11, 11, 11]) == "111111" def ...
[ { "docstring": "Compare two elements by their possible concatenations in both orders.", "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Given an array of positive integers, rearrange the elements to form the maximum poss...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare_numbers(x, y):\n # Custom comparator for sorting the numbers\n if x + y > y + x:\n return -1\n elif...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056792", "row_id": 56792, "seed_ids": "[7752]" }
0.741438
Taco_56792
I
[ "compare", "maxInteger" ]
2
[ [ "maxInteger", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
51043ec79af97c02d267e73a297da986815a6d2b
c4ec70a1cd0eb7dfed37955f203bb2d448301c87
v1.0
instruct
Taco
Taco_56796_I
You've encountered a situation where you need to compare two lists of words to find if they are anagrams at the level of individual characters as well as the sums of their ASCII values. Specifically, two words are considered anagrams if they contain the same characters in any order. If the sum of the ASCII values of th...
def is_super_anagram(word1, word2): """ Helper function to check if two words are super anagrams. """ if sorted(word1) == sorted(word2) and sum(ord(char) for char in word1) == sum(ord(char) for char in word2): return True return False def are_there_super_anagrams(list1, list2): """ ...
def test_are_there_super_anagrams(): assert are_there_super_anagrams(["listen", "apple", "silent"], ["enlist", "banana", "tinsel"]) == "YES" assert are_there_super_anagrams(["hello"], ["world"]) == "NO" assert are_there_super_anagrams(["abc"], ["cba"]) == "YES" assert are_there_super_anagrams(["anagram"...
[ { "docstring": "Helper function to check if two words are super anagrams.", "function_declaration": "def is_super_anagram(word1, word2):", "function_name": "is_super_anagram", "parameter_list": "(word1, word2)" }, { "docstring": "Function to check if there exists at least one pair of super a...
[ 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_super_anagram(word1, word2):\n \"\"\"\n Determines if two words are super anagrams.\n \"\"\"\n return sorted(word1) == sorted(word2) and sum(map...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00056796", "row_id": 56796, "seed_ids": "[19230]" }
0.592504
Taco_56796
I
[ "is_super_anagram", "are_there_super_anagrams" ]
2
[ [ "are_there_super_anagrams", "is_super_anagram" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0e98947544a0f4fee77ee1b0373c7e09dcb7611d
b7f402268834469030a5758034aa7fbabccd6527
v1.0
instruct
Taco
Taco_56817_I
Alyssa has an array of integers, and she wants to perform several operations on it. She is particularly interested in the "prefix sum" operation. The prefix sum of an array is a new array where each element at index \(i\) is the sum of all elements from the original array from index \(0\) to \(i\). However, Alyssa's a...
def calculate_prefix_sums(arr, queries): prefix_sums = [] current_sum = 0 for num in arr: current_sum += num prefix_sums.append(current_sum) result = [prefix_sums[q] for q in queries] return result # Helper function to process input and call the main function def process_input_for_...
from solution import calculate_prefix_sums, process_input_for_prefix_sums def test_calculate_prefix_sums(): assert calculate_prefix_sums([1, 2, 3, 4, 5], [0, 2, 4]) == [1, 6, 15] assert calculate_prefix_sums([-1, 2, -3, 4, 5], [0, 1, 3]) == [-1, 1, 2] assert calculate_prefix_sums([10, -10, 10], [0, 1, 2]) ...
[ { "docstring": null, "function_declaration": "def calculate_prefix_sums(arr, queries):", "function_name": "calculate_prefix_sums", "parameter_list": "(arr, queries)" }, { "docstring": null, "function_declaration": "def process_input_for_prefix_sums(N, array, Q, queries):", "function_...
[ 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 compute_prefix_sums(n, array, queries):\n \"\"\"\n Computes the prefix sums up to specified indices.\n \n Parameters:\n n (int): The number of e...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056817", "row_id": 56817, "seed_ids": "[16009]" }
0.605816
Taco_56817
I
[ "calculate_prefix_sums", "process_input_for_prefix_sums" ]
2
[ [ "process_input_for_prefix_sums", "calculate_prefix_sums" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b450412a6827e08283aa8a8ac3d9c61b968736d8
a309a4b2359f06f2eecff444adfeac66a6e3d18e
v1.0
instruct
Taco
Taco_56849_I
Robin is a food blogger and he always takes note of how satisfied he is with the dishes he tries. Recently, he decided to calculate a satisfaction score for each meal. The satisfaction score is the number of distinct prime factors of the meal's calorie count. Robin has a list of calorie counts for different meals, and...
def prime_factors_count(n): """ Returns the number of distinct prime factors of n. """ distinct_primes = set() factor = 2 while n % factor == 0: distinct_primes.add(factor) n //= factor factor = 3 while factor * factor <= n: while n % factor == 0: dist...
import pytest from solution import satisfaction_scores, prime_factors_count def test_prime_factors_count(): assert prime_factors_count(10) == 2 assert prime_factors_count(15) == 2 assert prime_factors_count(21) == 2 assert prime_factors_count(23) == 1 assert prime_factors_count(35) == 2 assert ...
[ { "docstring": "Returns the number of distinct prime factors of n.", "function_declaration": "def prime_factors_count(n):", "function_name": "prime_factors_count", "parameter_list": "(n)" }, { "docstring": "Returns a list of satisfaction scores for each calorie count in calorie_counts.", ...
[ 0, 0, 0, 0, 1, 1, 1, 1, 1 ]
5
medium
0.556
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import isqrt\n\ndef prime_factors_count(n):\n \"\"\"\n Return the number of distinct prime factors of n.\n \"\"\"\n count = 0\n if n % 2 =...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00056849", "row_id": 56849, "seed_ids": "[7135]" }
0.6433
Taco_56849
I
[ "prime_factors_count", "satisfaction_scores" ]
2
[ [ "satisfaction_scores", "prime_factors_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a2a04a2a54853a36e20f999de68ce19ccaf60bb6
ff86f64bad7b491e2088f65fc12e800b5dbb561f
v1.0
instruct
Taco
Taco_56856_I
You are working on developing a spell checking application. Your task is to determine if each word in a document is spelled correctly based on a given dictionary. The dictionary contains a list of correctly spelled words. Additionally, you are required to suggest the closest possible word from the dictionary for the m...
def levenshtein_distance(word1, word2): """ Compute the Levenshtein distance between two words. """ len1, len2 = len(word1), len(word2) dp = [[0] * (len2 + 1) for _ in range(len1 + 1)] for i in range(len1 + 1): dp[i][0] = i for j in range(len2 + 1): dp[0][j] = j for i i...
from solution import levenshtein_distance, spell_check def test_levenshtein_distance(): assert levenshtein_distance("apple", "apple") == 0 assert levenshtein_distance("appl", "apple") == 1 assert levenshtein_distance("apple", "aple") == 1 assert levenshtein_distance("apple", "appli") == 1 assert le...
[ { "docstring": "Compute the Levenshtein distance between two words.", "function_declaration": "def levenshtein_distance(word1, word2):", "function_name": "levenshtein_distance", "parameter_list": "(word1, word2)" }, { "docstring": "Check each word in the document and suggest the closest word...
[ 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 levenshtein_distance(s1, s2):\n \"\"\"\n Compute the Levenshtein distance between two strings.\n \"\"\"\n len_s1, len_s2 = len(s1), len(s2)\n \n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056856", "row_id": 56856, "seed_ids": "[9691]" }
0.647696
Taco_56856
I
[ "levenshtein_distance", "spell_check" ]
2
[ [ "spell_check", "levenshtein_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e9b8131bc89b1e9d2c3bfcfc64ddc4d7fe8f005
40c55136ac759f4e45790688e009217fbc3197b6
v1.0
instruct
Taco
Taco_56863_I
You are given a binary tree where each node contains a positive integer value. Your task is to find the maximum sum path from any node to any node in the tree. The path must contain at least one node and does not need to pass through the root. Constraints * The number of nodes in the tree is in the range [1, 1000]. *...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(n, edges, values): if n == 0: return None nodes = [TreeNode(value) for value in values] from collections import defaultdict children = defaultdic...
def test_example_1(): n = 5 edges = [(1, 2), (1, 3), (3, 4), (3, 5)] values = [10, 2, 10, 20, 1] assert find_max_sum_path(n, edges, values) == 42 def test_example_2(): n = 3 edges = [(1, 2), (1, 3)] values = [5, 7, 8] assert find_max_sum_path(n, edges, values) == 20 def test_single_nod...
[]
[ 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": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef c...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00056863", "row_id": 56863, "seed_ids": "[22957]" }
0.688746
Taco_56863
I
[ "build_tree", "maximum_path_sum", "find_max_sum_path" ]
3
[ [ "find_max_sum_path", "build_tree" ], [ "find_max_sum_path", "maximum_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
c7caa3de87c5b2cc27a8474e605606c1a751687c
d45527bac30df6f98e8304c853dd51dd96cb6f16
v1.0
instruct
Taco
Taco_56888_I
You are given a binary tree represented by an array A of length N, where each element at index i (0-based) indicates the parent of node i. The root of the binary tree will always be represented by -1, which means node i is the root if A[i] = -1. You need to flatten this binary tree into a linked list in-place. Flatten...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(parent_array): nodes = [TreeNode(i) for i in range(len(parent_array))] root = None for i, p in enumerate(parent_array): if p == -1: root = nodes[i] e...
def test_flatten_binary_tree(): # Test case 1 T = 2 test_cases = [ (5, [-1, 0, 0, 1, 1]), (3, [-1, 0, 1]), ] assert process_test_cases(T, test_cases) == [ [0, 1, 3, 4, 2], [0, 1, 2], ] def test_single_node(): T = 1 test_cases = [ (1, [-1]), ] ...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val):\n self.val = val\n self.left = None\n self.right = None\n\ndef flatten_tree(A):\n if not A:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00056888", "row_id": 56888, "seed_ids": "[24782]" }
0.617323
Taco_56888
I
[ "build_tree", "flatten_binary_tree_util", "flatten_binary_tree", "preorder_traversal", "process_test_cases", "solve" ]
6
[ [ "flatten_binary_tree", "flatten_binary_tree_util" ], [ "process_test_cases", "build_tree" ], [ "process_test_cases", "flatten_binary_tree" ], [ "process_test_cases", "preorder_traversal" ], [ "solve", "process_test_cases" ] ]
5
[ "process_test_cases" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
5439da20a23b4dd3ec9fd7b51953317e5954d0d5
3afc1cfdf7322e93105fa1d6ae3f7688e74798fa
v1.0
instruct
Taco
Taco_56935_I
Sam is working on a system that requires validating email addresses. An email address consists of a local part, an "@" symbol, and a domain part. The local part may contain alphanumeric characters, dots ('.'), underscores ('_'), and hyphens ('-'), but it must start and end with an alphanumeric character. The domain mus...
import re def validate_email_addresses(email_addresses): """ Takes a list of email addresses and returns a list of booleans indicating whether each email address is valid or not. """ validations = [] for email in email_addresses: if is_valid_email(email): validations.append(True...
from solution import validate_email_addresses def test_valid_emails(): emails = ["john.doe@example.com", "jane_doe@domain.co.uk"] assert validate_email_addresses(emails) == [True, True] def test_invalid_emails(): emails = ["invalid-email-@example..com", "_invalid@example.com"] assert validate_email_ad...
[ { "docstring": "Takes a list of email addresses and returns a list of booleans indicating whether each email address is valid or not.", "function_declaration": "def validate_email_addresses(email_addresses):", "function_name": "validate_email_addresses", "parameter_list": "(email_addresses)" }, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef validate_email_addresses(email_addresses):\n \"\"\"\n Validates a list of email addresses based on the given rules.\n \n Parameters:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00056935", "row_id": 56935, "seed_ids": "[11150]" }
0.55036
Taco_56935
I
[ "validate_email_addresses", "is_valid_email" ]
2
[ [ "validate_email_addresses", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2c1ec2d58d49f44b3d4744934369cffa49437f35
25dafa36715f0194aa54edc564732b56c204263d
v1.0
instruct
Taco
Taco_56945_I
Given an undirected graph with $n$ vertices and $m$ edges, each vertex representing a city and each edge representing a bidirectional road connecting two cities, you need to determine whether you can separate the graph into two disjoint sets such that no two cities in the same set are connected by a road. If it's possi...
from collections import deque def is_bipartite(n, edges): # Create an adjacency list adj = [[] for _ in range(n + 1)] for u, v in edges: adj[u].append(v) adj[v].append(u) # Array to store the color of each vertex (0: not colored, 1: color 1, 2: color 2) color = [0] * (n + 1) #...
def test_case_1(): output = separate_cities(4, 4, [(1, 2), (2, 3), (3, 4), (4, 1)]) assert output == "YES\n1 2 1 2" def test_case_2(): output = separate_cities(3, 3, [(1, 2), (2, 3), (1, 3)]) assert output == "NO" def test_case_3(): output = separate_cities(5, 4, [(1, 2), (2, 3), (4, 5)]) poss...
[ { "docstring": null, "function_declaration": "def is_bipartite(n, edges):", "function_name": "is_bipartite", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def separate_cities(n, m, edges):", "function_name": "separate_cities", "parameter_list": "...
[ 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_bipartite(n, edges):\n from collections import deque\n\n # Build the adjacency list\n adj_list = [[] for _ in range(n + 1)]\n for u, v in edges:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056945", "row_id": 56945, "seed_ids": "[15560]" }
0.667911
Taco_56945
I
[ "is_bipartite", "separate_cities" ]
2
[ [ "separate_cities", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0d0b7a371fa222e28c08064efd35fe89eab0e82c
ecc14743ecf64ad6407d58e0d9c30e38ca516715
v1.0
instruct
Taco
Taco_56977_I
A city is planning to introduce a new public transit route and wants to maximize the number of commuters that can utilize this route efficiently. The city map consists of $N$ intersections connected by $M$ bidirectional streets. Each street between the intersections has a capacity, which is the maximum number of commut...
from collections import deque def bfs_capacity(graph, capacity, source, sink, parent): visited = [False] * len(graph) queue = deque([source]) visited[source] = True while queue: node = queue.popleft() for adj, cap in graph[node]: if not visited[adj] and capacity[node][adj]...
def test_case_1(): N = 4 M = 5 S = 1 T = 4 edges = [ (1, 2, 40), (1, 3, 20), (2, 3, 10), (2, 4, 30), (3, 4, 20) ] assert max_flow(N, M, S, T, edges) == 50 def test_case_2(): N = 3 M = 3 S = 1 T = 3 edges = [ (1, 2, 5), ...
[ { "docstring": null, "function_declaration": "def bfs_capacity(graph, capacity, source, sink, parent):", "function_name": "bfs_capacity", "parameter_list": "(graph, capacity, source, sink, parent)" }, { "docstring": null, "function_declaration": "def max_flow(N, M, S, T, edges):", "f...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs(capacity, source, sink, parent):\n visited = set()\n queue = deque([source])\n visited.add(source)\n\n while q...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00056977", "row_id": 56977, "seed_ids": "[15603]" }
0.667228
Taco_56977
I
[ "bfs_capacity", "max_flow" ]
2
[ [ "max_flow", "bfs_capacity" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5ffebc67a426fbf3053e90ef8e8da982515b9c4a
98f87faa17e05c0056a725c7252ed3ded2e1cecc
v1.0
instruct
Taco
Taco_57009_I
Farmer John has a rectangular field, represented as a grid of size NxM where each cell can either be empty, contain grass, or contain a rock. Farmer John wants to plant a special type of crop that requires a clear and rectangular section of land. He needs your help to find the largest rectangular section of the field t...
def maximalRectangle(matrix): if not matrix: return 0 max_area = 0 heights = [0] * len(matrix[0]) for row in matrix: for i in range(len(row)): if row[i] == 'G': heights[i] += 1 else: heights[i] = 0 max_area = max(max_area,...
def test_largest_grass_rectangle(): assert largestGrassRectangle(4, 5, [ ['G', '.', 'G', 'G', 'G'], ['.', 'G', '.', '.', '.'], ['G', 'G', 'G', 'R', 'R'], ['G', 'G', 'G', 'G', 'G'] ]) == 6 assert largestGrassRectangle(4, 5, [ ['G', 'G', 'G', 'G', 'G'], ['G', '...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "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 maximalRectangleArea(field):\n if not field:\n return 0\n\n n = len(field)\n m = len(field[0])\n \n # Heights will store the continuous h...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00057009", "row_id": 57009, "seed_ids": "[6412]" }
0.646668
Taco_57009
I
[ "maximalRectangle", "largestRectangleArea", "largestGrassRectangle" ]
3
[ [ "largestGrassRectangle", "maximalRectangle" ], [ "maximalRectangle", "largestRectangleArea" ] ]
2
[]
false
[]
false
pytest
false
[]
true
be061ca7eaa12e5f514d8a9ceacfa836c3a0a57a
18fb50ce0b45e9c63259927baa662069c57c3cc2
v1.0
instruct
Taco
Taco_57011_I
You are given a string `s` of length `n`. Your task is to transform this string into a palindrome by rearranging its characters, while making the minimum possible number of swaps between any two characters. If it is not possible to rearrange the characters of the string to form a palindrome, output "IMPOSSIBLE". A str...
from collections import Counter def can_form_palindrome(s): """ Check if it is possible to rearrange the string s into a palindrome. """ count = Counter(s) odd_count = sum(1 for val in count.values() if val % 2 != 0) # A palindrome can have at most one character with an odd count return odd...
from solution import rearrange_to_palindrome def test_palindrome_even_length(): assert rearrange_to_palindrome("aabb") in {"abba", "baab"} assert rearrange_to_palindrome("ccbb") in {"bccb", "cbbc"} def test_palindrome_odd_length(): assert rearrange_to_palindrome("aabbc") in {"abcba", "bacab", "cabac"} de...
[ { "docstring": "Check if it is possible to rearrange the string s into a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def rearrange_to_palindrome(s):",...
[ 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 can_form_palindrome(s):\n from collections import Counter\n count = Counter(s)\n odd_count = sum(1 for c in count if count[c] % 2 != 0)\n return od...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00057011", "row_id": 57011, "seed_ids": "[4141]" }
0.843962
Taco_57011
I
[ "can_form_palindrome", "rearrange_to_palindrome" ]
2
[ [ "rearrange_to_palindrome", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54d6ee62def9c1d48d969b44d6a3713d6ddac117
639cac8bf61c3e12368514cee30cf1488487f27b
v1.0
instruct
Taco
Taco_57094_I
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is `9009` = `91` × `99`. A useful property to note is that for a number to be palindromic, its reverse must be equal to itself. Your task is to find the largest palindrome made from the product of two 3-d...
def is_palindrome(n): """ Check if a number is a palindrome. """ return str(n) == str(n)[::-1] def largest_palindrome_product(): """ Find the largest palindrome made from the product of two 3-digit numbers. """ max_palindrome = 0 for i in range(999, 99, -1): for j in range(i...
from solution import largest_palindrome_product, is_palindrome def test_is_palindrome(): assert is_palindrome(9009) == True assert is_palindrome(12321) == True assert is_palindrome(12345) == False assert is_palindrome(1) == True def test_largest_palindrome_product(): assert largest_palindrome_prod...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Find the largest palindrome made from the product of two 3-digit numbers.", "function_declaration": "def larg...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef largest_palindrome_product():\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00057094", "row_id": 57094, "seed_ids": "[19207]" }
0.733742
Taco_57094
I
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d4dd988cb9732bd55991f7be24077f09ab9a547c
e90883613a91b5cfca8eaf5f6fd1212041975928
v1.0
instruct
Taco
Taco_57098_I
A string is called “balanced” if every character in the string appears the same number of times. For example, the string "aabbcc" is balanced because each character appears twice, while the string "aaabbc" is not balanced because 'a' appears three times, 'b' appears twice, and 'c' appears once. Your task is to write a...
def is_balanced(s): from collections import Counter char_counts = Counter(s) values = list(char_counts.values()) return all(val == values[0] for val in values) def process_strings(strings): results = [] for s in strings: if s == "*": break results.append("YES" i...
from solution import is_balanced, process_strings def test_is_balanced(): assert is_balanced("aabbcc") == True assert is_balanced("aaabbc") == False assert is_balanced("abcdab") == False assert is_balanced("aaaa") == True assert is_balanced("") == True assert is_balanced("x" * 100) == True def...
[ { "docstring": null, "function_declaration": "def is_balanced(s):", "function_name": "is_balanced", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def process_strings(strings):", "function_name": "process_strings", "parameter_list": "(strings)" } ]
[ 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_balanced(s):\n from collections import Counter\n \n char_counts = Counter(s)\n values = list(char_counts.values())\n return all(val == values...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00057098", "row_id": 57098, "seed_ids": "[21646]" }
0.683083
Taco_57098
I
[ "is_balanced", "process_strings" ]
2
[ [ "process_strings", "is_balanced" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1269f1b78a8deddd5845086ba9266858fa7037bd
a73d772c09231035f592b9fbbb8111300e49ac1e
v1.0
instruct
Taco
Taco_57100_I
In a computer graphics software, layers of images are manipulated in various ways. One common operation is to merge a series of layers together into a single image. The merging process involves combining the pixel values of each layer in a specific order, usually by a given set of pairwise operations. Each layer is rep...
def merge_layers(layers, merge_operations): N, M = len(layers), len(layers[0]) def merge(A, B): for i in range(M): for j in range(M): layers[A][i][j] = max(layers[A][i][j], layers[B][i][j]) for A, B in merge_operations: merge(A - 1, B - 1) def query_layer(l...
def test_merge_layers(): layers = [ [ [1, 2], [3, 4] ], [ [5, 6], [7, 8] ], [ [1, 2], [3, 4] ] ] merge_operations = [(1, 2), (2, 3), (1, 3)] expected_layers = [ [ [...
[ { "docstring": null, "function_declaration": "def merge_layers(layers, merge_operations):", "function_name": "merge_layers", "parameter_list": "(layers, merge_operations)" }, { "docstring": null, "function_declaration": "def query_layer(layers, L, R, C):", "function_name": "query_lay...
[ 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 merge_layers(N, M, K, Q, layers, merges, queries):\n for a, b in merges:\n a -= 1 # Convert to zero-indexed\n b -= 1 # Convert to zero-index...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057100", "row_id": 57100, "seed_ids": "[4810]" }
0.575336
Taco_57100
I
[ "merge_layers", "query_layer", "process_graphics_merging" ]
3
[ [ "process_graphics_merging", "merge_layers" ], [ "process_graphics_merging", "query_layer" ] ]
2
[]
false
[]
false
pytest
false
[]
true
88d012ed2a58a8913eb238911dc421f15ab543b2
9332be919aa2fa4cdf0f668baf8672f7b989eca9
v1.0
instruct
Taco
Taco_57101_I
Wandering Trees Story In a small village surrounded by a vast forest, the villagers have a unique problem. The trees in the forest often wander around during the night, leading to a different configuration of the forest every morning. The villagers decided to map the forest every day. They represent the forest as a r...
from collections import defaultdict from typing import List, Tuple def hash_tree(children, root, parent): """ Helper function to recursively generate hash representation of the tree """ primes = [31, 29, 23, 19, 17] subtree_hash = [] for child in children[root]: if child != parent: ...
def test_process_input(): input_data = '''2 3 1 2 1 3 3 1 2 1 3 4 1 2 2 3 3 4 4 1 2 1 3 1 4''' expected_output = ["Yes", "No"] assert process_input(input_data) == expected_output def test_are_isomorphic_identical_trees(): edges1 = [(1, 2), (1, 3)] edges2 = [(1, 2), (1, 3)] assert are_isomorphic...
[ { "docstring": "Helper function to recursively generate hash representation of the tree", "function_declaration": "def hash_tree(children, root, parent):", "function_name": "hash_tree", "parameter_list": "(children, root, parent)" }, { "docstring": null, "function_declaration": "def are_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef build_tree(edges, n):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n tree[v]....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057101", "row_id": 57101, "seed_ids": "[17011]" }
0.634915
Taco_57101
I
[ "hash_tree", "are_isomorphic", "process_input" ]
3
[ [ "are_isomorphic", "hash_tree" ], [ "process_input", "are_isomorphic" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
80ca2c6af0609277bb4ddf266a5a0a0ee7f5ac9a
98483db5db86923e499e86ef65ba51b09809677a
v1.0
instruct
Taco
Taco_57177_I
Given an integer array \(A\) of length \(N\). Find the minimum number of operations to make all elements of \(A\) equal, where each operation consists of choosing two distinct elements \(A_i\) and \(A_j\) (1 ≤ i, j ≤ N) and one of the following: 1. Add the value of \(A_i\) to \(A_j\). 2. Add the value of \(A_j\) to \(...
def min_operations_to_equal_elements(arr): """ Calculate the minimum number of operations needed to make all elements in the array equal. """ from collections import Counter frequency = Counter(arr) max_frequency = max(frequency.values()) return len(arr) - max_frequency def process_inp...
from solution import min_operations_to_equal_elements, process_input, min_operations def test_case_1(): assert min_operations_to_equal_elements([2, 3, 5]) == 2 def test_case_2(): assert min_operations_to_equal_elements([1, 1, 1, 1]) == 0 def test_case_3(): assert min_operations_to_equal_elements([0, 0, 0...
[ { "docstring": "Calculate the minimum number of operations needed to make all elements in the array equal.", "function_declaration": "def min_operations_to_equal_elements(arr):", "function_name": "min_operations_to_equal_elements", "parameter_list": "(arr)" }, { "docstring": "Process the inp...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_operations_to_equal_elements(n, arr):\n \"\"\"\n Returns the minimum number of operations to make all elements in the array equal.\n \"\"\"\n f...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057177", "row_id": 57177, "seed_ids": "[4824]" }
0.793003
Taco_57177
I
[ "min_operations_to_equal_elements", "process_input", "min_operations" ]
3
[ [ "min_operations", "process_input" ], [ "process_input", "min_operations_to_equal_elements" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
bf514e57ca6f86f70d954bc24eb0ee9371d5fb73
90dab975dd487b3bf427e352d389659f861203af
v1.0
instruct
Taco
Taco_57272_I
James, an astronomy student, loves to study star constellations represented by coordinate points in a 2D space. He defines a constellation as a set of points where no three points are collinear. Given a set of points, he wants to determine if they can form a valid constellation. The input consists of: - The first line...
def is_valid_constellation(points): """ Returns 'YES' if given points can form a valid constellation, otherwise 'NO' """ n = len(points) def are_collinear(p1, p2, p3): """ Check if three points are collinear. """ return (p2[1] - p1[1]) * (p3[0] - p1[0]) == (p3[1...
import pytest from solution import is_valid_constellation, parse_and_solve def test_is_valid_constellation_collinear(): points = [(1, 1), (2, 2), (3, 3), (4, 4)] assert is_valid_constellation(points) == 'NO' def test_is_valid_constellation_not_collinear(): points = [(0, 0), (1, 2), (2, 3), (3, 1), (4, 4)]...
[ { "docstring": "Returns 'YES' if given points can form a valid constellation, \notherwise 'NO'", "function_declaration": "def is_valid_constellation(points):", "function_name": "is_valid_constellation", "parameter_list": "(points)" }, { "docstring": "Process multiple test cases and returns t...
[ 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_valid_constellation(points):\n def are_collinear(p1, p2, p3):\n # Check if the area of the triangle formed by points (p1, p2, p3) is zero\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057272", "row_id": 57272, "seed_ids": "[9239]" }
0.576068
Taco_57272
I
[ "is_valid_constellation", "process_input", "parse_and_solve" ]
3
[ [ "parse_and_solve", "process_input" ], [ "process_input", "is_valid_constellation" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
43ee9dcf78dadd4456a84a6a86f282f2d4cd25bd
8be461e57973a2949775145e50b5e6fbafb12a86
v1.0
instruct
Taco
Taco_57286_I
You are building a new project management tool to help a company track its ongoing projects and their dependencies. Each project can depend on one or more other projects that must be completed first. The company wants to determine the order in which they should complete the projects to respect all dependencies. Your t...
from collections import defaultdict, deque def find_project_order(N, D, dependencies): """ Determines the order of project completions based on dependencies. Args: N : int : Number of projects D : int : Number of dependencies dependencies : list of tuples : List containing tuples of depend...
import pytest from solution import project_management_tool def test_single_valid_order(): N, D = 4, 3 dependencies = [(1, 2), (2, 3), (3, 4)] assert project_management_tool(N, D, dependencies) == "1 2 3 4" def test_impossible_due_to_cycle(): N, D = 4, 4 dependencies = [(1, 2), (2, 3), (3, 1), (3, ...
[ { "docstring": "Determines the order of project completions based on dependencies.\n\nArgs:\nN : int : Number of projects\nD : int : Number of dependencies\ndependencies : list of tuples : List containing tuples of dependencies (A, B)\n\nReturns:\nstr : A space-separated sequence of N integers representing vali...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef find_project_order(N, D, dependencies):\n \"\"\"\n Determines a valid order to complete the projects given ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057286", "row_id": 57286, "seed_ids": "[13213]" }
0.587747
Taco_57286
I
[ "find_project_order", "project_management_tool" ]
2
[ [ "project_management_tool", "find_project_order" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a41368684aafc349074e3c07370e868b4188387
4ef3b6fd77abc3643f5800eb24f4823643dd545d
v1.0
instruct
Taco
Taco_57340_I
Alice is interested in prime numbers, and she recently learned that palindromic prime numbers are quite fascinating. Palindromic prime numbers are prime numbers that remain the same when their digits are reversed. For example, 101 is a palindromic prime number since it is prime and reads the same forwards and backwards...
def is_palindrome(num): """ Check if the given number is a palindrome. """ return str(num) == str(num)[::-1] def is_prime(num): """ Check if the given number is a prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: ...
from solution import is_palindrome, is_prime, smallest_palindromic_prime def test_is_palindrome(): assert is_palindrome(121) assert is_palindrome(131) assert not is_palindrome(123) assert is_palindrome(1) assert is_palindrome(0) def test_is_prime(): assert is_prime(2) assert is_prime(3) ...
[ { "docstring": "Check if the given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Check if the given number is a prime.", "function_declaration": "def is_prime(num):", "functi...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\" Check if a number is prime. \"\"\"\n if num < 2:\n return False\n if num in (2, 3):\n return True\n if num % ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057340", "row_id": 57340, "seed_ids": "[16865]" }
0.786491
Taco_57340
I
[ "is_palindrome", "is_prime", "smallest_palindromic_prime" ]
3
[ [ "smallest_palindromic_prime", "is_palindrome" ], [ "smallest_palindromic_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a240e6060574d3a72c314148db4e969b88f60e6a
45601d7234dd95a5e324f2c8d327771e0353341f
v1.0
instruct
Taco
Taco_57382_I
Dreamoon loves sequences and shifting operations. Let’s define a right circular shift operation on a sequence a as follows: moving the last element to the beginning of the sequence while shifting all other elements one position to the right. For example, applying a right circular shift to the sequence a = [1, 2, 3, 4]...
def is_good_sequence(sequence): """ Determines if the sequence can be made such that all elements are equal through a series of right circular shifts followed by reversing the sequence and performing right circular shifts again. """ unique_elements = set(sequence) return len(unique_elements)...
def test_is_good_sequence(): assert is_good_sequence([4, 1, 2, 3]) == False assert is_good_sequence([1, 1, 1]) == True assert is_good_sequence([2, 4, 4, 2, 2]) == True def test_check_sequences(): assert check_sequences([[4, 1, 2, 3], [1, 1, 1], [2, 4, 4, 2, 2]]) == ["NO", "YES", "YES"] def test_proces...
[ { "docstring": "Determines if the sequence can be made such that all elements are equal\nthrough a series of right circular shifts followed by reversing the sequence\nand performing right circular shifts again.", "function_declaration": "def is_good_sequence(sequence):", "function_name": "is_good_sequen...
[ 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_good_sequence(sequence):\n \"\"\"\n Determine if a sequence can be made all equal through a series of \n right circular shifts and possibly reversi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057382", "row_id": 57382, "seed_ids": "[23802]" }
0.589108
Taco_57382
I
[ "is_good_sequence", "check_sequences", "process_input" ]
3
[ [ "check_sequences", "is_good_sequence" ], [ "process_input", "check_sequences" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
b185ffd8d051aafa8238d1d9dd30bca3b04d33fe
0597bb8b6ab61f96f9aac572ffd63a815b33fb8c
v1.0
instruct
Taco
Taco_57413_I
Given a grid of '*' and '.' characters, your task is to determine the maximum area of rectangles consisting solely of '.' characters in the grid. A rectangle of size r x c is defined as r consecutive rows and c consecutive columns. For example, consider the following grid: ``` 6 0 1 2 3 4 5 0 * * * * * * 1 * ....
def maximalRectangle(matrix): if not matrix: return 0 n = len(matrix) m = len(matrix[0]) heights = [0] * m max_area = 0 for i in range(n): for j in range(m): if matrix[i][j] == '.': heights[j] += 1 else: heights[j] = 0 ...
def test_maximalRectangle_small(): grid = [ "******", "*...**", "*.*.**", "*.*.**", "**.***" ] assert maximalRectangle(grid) == 3 def test_maximalRectangle_empty(): grid = [ "*" ] assert maximalRectangle(grid) == 0 def test_maximalRectangle_one_r...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 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 maximalRectangle(matrix):\n if not matrix:\n return 0\n n = len(matrix)\n m = len(matrix[0])\n heights = [0] * m\n max_area = 0\n \n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00057413", "row_id": 57413, "seed_ids": "[24175]" }
0.677527
Taco_57413
I
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6d663f93053588b8eaee970cb85536aaec4a6157
83519641e432f3c4f075735e7c41f12081c07248
v1.0
instruct
Taco
Taco_57482_I
Miyuki, a renowned software engineer, has recently enrolled in a top-secret development program. As part of her training, she has been assigned the challenge of managing a distributed data storage system. The system consists of `N` servers, indexed from 1 to `N`, and `M` bidirectional network connections between these ...
def find_parent(parent, i): """ A utility function to find the set of an element i """ if parent[i] == i: return i else: return find_parent(parent, parent[i]) def union(parent, rank, x, y): """ A utility function to do union of two subsets x and y """ xroot = find_pa...
def test_minimum_new_connections_required(): test_cases = [ (5, 3, [(1, 2, 1), (2, 3, 2), (4, 5, 3)]), # Expected output: 1 (4, 5, [(1, 2, 1), (1, 3, 2), (3, 4, 1)]), # Expected output: 0 ] assert solve(2, test_cases) == [1, 0] def test_single_server(): test_cases = [ (1,...
[ { "docstring": "A utility function to find the set of an element i", "function_declaration": "def find_parent(parent, i):", "function_name": "find_parent", "parameter_list": "(parent, i)" }, { "docstring": "A utility function to do union of two subsets x and y", "function_declaration": "...
[ 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_root(parent, i):\n if parent[i] == i:\n return i\n else:\n return find_root(parent, parent[i])\n\ndef union(parent, rank, x, y):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057482", "row_id": 57482, "seed_ids": "[3769]" }
0.608218
Taco_57482
I
[ "find_parent", "union", "minimum_new_connections_required", "solve" ]
4
[ [ "minimum_new_connections_required", "find_parent" ], [ "minimum_new_connections_required", "union" ], [ "solve", "minimum_new_connections_required" ], [ "union", "find_parent" ] ]
4
[]
false
[]
false
pytest
false
[]
true
c7b2d5700d1ecbd4a22e6f2f7d159a5d9cda7f88
cffe5b6c4ce9a2f20ec990db13ecf7bc4fb245cb
v1.0
instruct
Taco
Taco_57545_I
A company is planning to optimize their delivery routes. They have a network of $n$ warehouses, described as an unweighted, connected undirected graph. Each warehouse is connected by a road to other warehouses. You must analyze the network and determine key strategic locations that will minimize the maximum delivery d...
import heapq from collections import deque, defaultdict def bfs_farthest_node(graph, start): """ Perform BFS to find the farthest node and its distance from the starting node. """ queue = deque([(start, 0)]) visited = set([start]) farthest_node = start max_dist = 0 while queue: ...
import pytest from solution import process_optimization def test_basic_case(): assert process_optimization(6, [(1, 2), (1, 3), (3, 4), (3, 5), (5, 6)], 2) == 2 def test_single_hub(): assert process_optimization(4, [(1, 2), (2, 3), (3, 4)], 1) == 2 def test_hubs_equal_to_warehouses(): assert process_optim...
[ { "docstring": "Perform BFS to find the farthest node and its distance from the starting node.", "function_declaration": "def bfs_farthest_node(graph, start):", "function_name": "bfs_farthest_node", "parameter_list": "(graph, start)" }, { "docstring": null, "function_declaration": "def m...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef find_farthest_node(start_node, adjacency_list):\n \"\"\"\n Returns the farthest node and its distance from the start_nod...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00057545", "row_id": 57545, "seed_ids": "[9659]" }
0.693348
Taco_57545
I
[ "bfs_farthest_node", "min_max_delivery_distance", "process_optimization" ]
3
[ [ "min_max_delivery_distance", "bfs_farthest_node" ], [ "process_optimization", "min_max_delivery_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ba870f59ec09cae1fda3ce3cfe246bbe0fd38be6
166e624cf0182f7e600a3332bb20a8b82a453f2b
v1.0
instruct
Taco
Taco_57572_I
Tina enjoys exploring various subsequences within arrays. She is particularly interested in finding the length of the Longest Increasing Subsequence (LIS) in a given array. You are given an array of size N and a positive integer Q. Each Q query contains one integer K, and you need to determine if there exists a subs...
def length_of_lis(arr): """ Function to find the length of the Longest Increasing Subsequence (LIS) in the given array. """ if not arr: return 0 n = len(arr) lis = [1] * n for i in range(1, n): for j in range(i): if arr[i] > arr[j] and lis[i] < lis[j] + 1: ...
from solution import length_of_lis, check_subsequence def test_length_of_lis(): assert length_of_lis([9, 1, 3, 7, 5, 6, 20]) == 5 assert length_of_lis([1, 1, 1, 1, 1]) == 1 assert length_of_lis([]) == 0 assert length_of_lis([10, 20, 30, 40, 50]) == 5 assert length_of_lis([50, 40, 30, 20, 10]) == 1 ...
[ { "docstring": "Function to find the length of the Longest Increasing Subsequence (LIS) in the given array.", "function_declaration": "def length_of_lis(arr):", "function_name": "length_of_lis", "parameter_list": "(arr)" }, { "docstring": "For each query, determine if there exists a subseque...
[ 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 lis(array):\n \"\"\"\n Helper function to compute the length of the Longest Increasing Subsequence (LIS).\n \"\"\"\n if not array:\n return ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00057572", "row_id": 57572, "seed_ids": "[3947]" }
0.748731
Taco_57572
I
[ "length_of_lis", "check_subsequence" ]
2
[ [ "check_subsequence", "length_of_lis" ] ]
1
[]
false
[]
false
pytest
true
[]
true
685a6d4d7e1625ee3b91e1eb9a3447c3f9207336
a7f43bbe2bb52c576723423dcff6ec534cfbcd6a
v1.0
instruct
Taco
Taco_57579_I
Write a function that takes a string containing a list of space-separated integers and returns a string with only the prime numbers from the list, separated by commas. For example: ``` Input: "23 4 15 29 17 8" Output: "23,29,17" ``` Return the result as a single string. You can assume the input string will only con...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def extract_primes(int_str): """ Takes a string containing a list of space-s...
from solution import extract_primes def test_extract_primes_all_primes(): assert extract_primes("2 3 5 7 11") == "2,3,5,7,11" def test_extract_primes_no_primes(): assert extract_primes("4 6 8 10 12") == "" def test_extract_primes_mixed(): assert extract_primes("23 4 15 29 17 8") == "23,29,17" def test_e...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a string containing a list of space-separated integers and\nreturns a string of the prime numbers, separated by commas.", "function_declaration":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057579", "row_id": 57579, "seed_ids": "[19176]" }
0.618468
Taco_57579
I
[ "is_prime", "extract_primes" ]
2
[ [ "extract_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c34f9a15b0cd897addc951693f20801964d7352b
e72e713aaeb82c1dc44df4de04be372b00c1943b
v1.0
instruct
Taco
Taco_57586_I
Suppose you are helping a farmer to plant trees in an orchard. The orchard is represented as a 2D grid of size n x m. Each cell can either be empty or contain an obstacle. You are given a list of tree saplings, each specifying the type of tree and its desired growth area in the shape of a rectangular sub-grid of specif...
def can_place_tree(grid, x, y, w, h): for i in range(h): for j in range(w): if grid[x + i][y + j] != '.': return False return True def place_tree(grid, x, y, w, h): for i in range(h): for j in range(w): grid[x + i][y + j] = 'T' def remove_tree(grid, ...
def test_can_place_tree_true(): grid = [ ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'] ] assert can_place_tree(grid, 0, 0, 2, 2) == True def test_can_place_tree_false(): grid = [ ['.', '.', '.'], ['.', '#', '.'], ['.', '.', '.'] ] assert can_p...
[ { "docstring": null, "function_declaration": "def can_place_tree(grid, x, y, w, h):", "function_name": "can_place_tree", "parameter_list": "(grid, x, y, w, h)" }, { "docstring": null, "function_declaration": "def place_tree(grid, x, y, w, h):", "function_name": "place_tree", "par...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_place_tree(grid, n, m, x, y, w, h):\n if x + h > n or y + w > m:\n return False\n for i in range(h):\n for j in range(w):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057586", "row_id": 57586, "seed_ids": "[11320]" }
0.674715
Taco_57586
I
[ "can_place_tree", "place_tree", "remove_tree", "max_trees_planted", "main" ]
5
[ [ "max_trees_planted", "can_place_tree" ], [ "max_trees_planted", "place_tree" ], [ "max_trees_planted", "remove_tree" ] ]
3
[]
false
[]
false
pytest
false
[]
true
aeb053e113e2372942891fe6f6c5c64758e1f1f6
a22aac94b6cb72cf376e49c1281fc880cf82e378
v1.0
instruct
Taco
Taco_57593_I
Alice is working with a grid-based game where she can move her character on a 2D grid from the top-left corner (1, 1) to the bottom-right corner (n, m). The grid has some obstacles, which she cannot pass through. Alice can only move right or down at any step. Alice wants to know the number of distinct paths she can ta...
def num_paths_with_obstacles(grid): n = len(grid) m = len(grid[0]) MOD = 1000000007 if grid[0][0] == '#' or grid[n-1][m-1] == '#': return 0 dp = [[0] * m for _ in range(n)] dp[0][0] = 1 for i in range(n): for j in range(m): if grid[i][j] == '#': ...
def test_example_case_1(): n, m = 3, 3 grid = "...\n.#.\n..." assert number_of_paths(n, m, grid) == 2 def test_example_case_2(): n, m = 3, 3 grid = "...\n.#.\n..#" assert number_of_paths(n, m, grid) == 0 def test_corner_case_starting_point_blocked(): n, m = 3, 3 grid = "#..\n.#.\n..." ...
[ { "docstring": null, "function_declaration": "def num_paths_with_obstacles(grid):", "function_name": "num_paths_with_obstacles", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def number_of_paths(n, m, grid):", "function_name": "number_of_paths", "par...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 1000000007\n\ndef uniquePaths(n, m, grid):\n if grid[0][0] == '#' or grid[n-1][m-1] == '#':\n return 0\n \n dp = [[0] * m for _ in range(n)]\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057593", "row_id": 57593, "seed_ids": "[19153]" }
0.836303
Taco_57593
I
[ "num_paths_with_obstacles", "number_of_paths" ]
2
[ [ "number_of_paths", "num_paths_with_obstacles" ] ]
1
[]
false
[]
false
pytest
false
[]
true
583e7d77454b60e0557600a4df5c0d0f94bea684
81de9ffb3ecdcefca4303301d0e889536e5e6e2e
v1.0
instruct
Taco
Taco_57658_I
You are tasked with creating a safe communication network for a group of secret agents. Each agent can securely communicate with others through a direct communication link represented as an undirected and weighted edge between two vertices in a graph. The vertices represent agents, and the edges represent secure commun...
def find(parent, x): if parent[x] != x: parent[x] = find(parent, parent[x]) return parent[x] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif ra...
def test_minimum_cost_to_connect_agents(): assert minimum_cost_to_connect_agents(4, 5, [(1, 2, 1), (1, 3, 4), (2, 3, 2), (3, 4, 3), (2, 4, 5)]) == 6 assert minimum_cost_to_connect_agents(4, 2, [(1, 2, 1), (3, 4, 2)]) == -1 assert minimum_cost_to_connect_agents(3, 3, [(1, 2, 1), (2, 3, 2), (1, 3, 4)]) == 3 ...
[ { "docstring": null, "function_declaration": "def find(parent, x):", "function_name": "find", "parameter_list": "(parent, x)" }, { "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": "class UnionFind:\n def __init__(self, size):\n self.root = list(range(size))\n self.rank = [1] * size\n\n def find(self, x):\n if self.r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00057658", "row_id": 57658, "seed_ids": "[16588]" }
0.714377
Taco_57658
I
[ "find", "union", "minimum_cost_to_connect_agents" ]
3
[ [ "minimum_cost_to_connect_agents", "find" ], [ "minimum_cost_to_connect_agents", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
17a0184119c56d48145e834db2fc2922ef3a1c69
b67b05ddffccb4a42ad42cfc304824a4d51f8f8e
v1.0
instruct
Taco
Taco_57660_I
Your task is to write a program that helps to arrange the elements of an array in ascending order using the Bubble Sort algorithm. Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is rep...
def bubble_sort(arr): """ Sorts an array using the Bubble Sort algorithm. Parameters: - arr: list of integers Returns: - Sorted list of integers """ n = len(arr) for i in range(n): # Last i elements are already in place for j in range(0, n - i - 1): ...
from solution import sort_input def test_sort_input_example_1(): assert sort_input(5, [64, 34, 25, 12, 22]) == [12, 22, 25, 34, 64] def test_sort_input_example_2(): assert sort_input(4, [4, 3, 2, 1]) == [1, 2, 3, 4] def test_sort_input_sorted(): assert sort_input(3, [1, 2, 3]) == [1, 2, 3] def test_sort...
[ { "docstring": "Sorts an array using the Bubble Sort algorithm.\n\nParameters:\n- arr: list of integers\n\nReturns:\n- Sorted list of integers", "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_list": "(arr)" }, { "docstring": "Sorts the elements of...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bubble_sort(arr):\n \"\"\"\n Perform bubble sort on the given array.\n \"\"\"\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057660", "row_id": 57660, "seed_ids": "[16787]" }
0.585995
Taco_57660
I
[ "bubble_sort", "sort_input" ]
2
[ [ "sort_input", "bubble_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
987cad24820d85f0088708e63a143fa0f861d374
6a924454156d22abe5b92b82c626c149d789c694
v1.0
instruct
Taco
Taco_57729_I
A palindrome is a string that reads the same forward and backward. Given a string, you need to determine the minimum number of adjacent character swaps required to transform it into a palindrome. If it cannot be transformed into a palindrome, return -1. Function Description Complete the `minSwapsToPalindrome` functio...
def minSwapsToPalindrome(s): """ Returns the minimum number of adjacent character swaps required to transform the string `s` into a palindrome. If it's not possible, returns -1. """ if not canFormPalindrome(s): return -1 s = list(s) n = len(s) swap_count = 0 for i ...
from solution import minSwapsToPalindrome def test_example_1(): assert minSwapsToPalindrome("mamad") == 3 def test_example_2(): assert minSwapsToPalindrome("asflkj") == -1 def test_example_3(): assert minSwapsToPalindrome("abcbca") == 1 def test_single_character(): assert minSwapsToPalindrome("a") =...
[ { "docstring": "Returns the minimum number of adjacent character swaps required to transform the \nstring `s` into a palindrome. If it's not possible, returns -1.", "function_declaration": "def minSwapsToPalindrome(s):", "function_name": "minSwapsToPalindrome", "parameter_list": "(s)" }, { "...
[ 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 minSwapsToPalindrome(s):\n \"\"\"\n Returns the minimum number of adjacent character swaps required to transform the \n string `s` into a palindrome. ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00057729", "row_id": 57729, "seed_ids": "[11696]" }
0.840046
Taco_57729
I
[ "minSwapsToPalindrome", "canFormPalindrome" ]
2
[ [ "minSwapsToPalindrome", "canFormPalindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3f73a371e40f485e4ac6f6f3f5fa22937f64addd
22fe39712a1c73238e8e9d15109a76c670f46fae
v1.0
instruct
Taco
Taco_57802_I
A company has a system that tracks employee check-ins and check-outs throughout the day via timestamps in a given format. Given a list of check-in and check-out timestamps for a day, your task is to determine the total number of minutes an employee was present in the office during that day. Each timestamp is a string ...
def calculate_minutes(time1, time2): """ Calculate the minutes between two time stamps in "HH:MM" format """ h1, m1 = map(int, time1.split(':')) h2, m2 = map(int, time2.split(':')) return (h2 - h1) * 60 + (m2 - m1) def total_minutes_present(test_cases): results = [] for case in test_cas...
from solution import calculate_minutes, total_minutes_present, parse_input def test_calculate_minutes(): assert calculate_minutes("09:00", "12:00") == 180 assert calculate_minutes("13:00", "17:00") == 240 assert calculate_minutes("08:30", "12:45") == 255 assert calculate_minutes("14:15", "15:30") == 75...
[ { "docstring": "Calculate the minutes between two time stamps in \"HH:MM\" format", "function_declaration": "def calculate_minutes(time1, time2):", "function_name": "calculate_minutes", "parameter_list": "(time1, time2)" }, { "docstring": null, "function_declaration": "def total_minutes_...
[ 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 calculate_total_minutes(timestamps):\n \"\"\"\n Calculate the total minutes active given check-in and check-out times.\n \n Parameters:\n timest...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00057802", "row_id": 57802, "seed_ids": "[4093]" }
0.668422
Taco_57802
I
[ "calculate_minutes", "total_minutes_present", "parse_input" ]
3
[ [ "total_minutes_present", "calculate_minutes" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
9e5b5f662d0c2fbc6cef20908a1649ada36ef852
debd746c7f210a36c2219adabe45c8d1f6667ed2
v1.0
instruct
Taco
Taco_57883_I
You are given a grid of size `m x n` represented by a list of lists, where each cell contains a positive integer. Your task is to determine the maximum sum of any path from the top-left corner to the bottom-right corner of the grid, where you can only move right or down at each step. Implement a function that takes the...
def is_valid_grid(grid): if not isinstance(grid, list): return False for row in grid: if not isinstance(row, list): return False for cell in row: if not isinstance(cell, int) or cell <= 0: return False return True def max_path_sum(grid): ...
from solution import max_path_sum def test_valid_grid(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert max_path_sum(grid) == 12 def test_single_cell_grid(): grid = [ [5] ] assert max_path_sum(grid) == 5 def test_not_a_grid(): assert max_path_sum("not a ...
[ { "docstring": null, "function_declaration": "def is_valid_grid(grid):", "function_name": "is_valid_grid", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def max_path_sum(grid):", "function_name": "max_path_sum", "parameter_list": "(grid)" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_path_sum(grid):\n \"\"\"\n Returns the maximum sum of any path from the top-left corner to the bottom-right corner \n of the grid, where you can o...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00057883", "row_id": 57883, "seed_ids": "[22220]" }
0.680431
Taco_57883
I
[ "is_valid_grid", "max_path_sum" ]
2
[ [ "max_path_sum", "is_valid_grid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6a8a1256478359c6e0fbf6828144548631b1974a
9471cd72a87125db2d73c9f789d167a0cd4c0271
v1.0
instruct
Taco
Taco_57929_I
In a small village, children play a game using a grid of size n × m. Initially, each cell of the grid contains either a '0' or a '1'. A child is allowed to select any one cell and flip its value (change '0' to '1' or '1' to '0'). They can do this operation as many times as they like on any cell. The game ends when the ...
def is_possible_to_rearrange(grid): n = len(grid) m = len(grid[0]) # Generate the checkerboard pattern grids for comparison checkerboard_1 = [[(i + j) % 2 for j in range(m)] for i in range(n)] checkerboard_2 = [[(i + j + 1) % 2 for j in range(m)] for i in range(n)] def is_matching(grid, pa...
import pytest from solution import solution def test_case_1(): input_text = "2\n3 3\n010\n101\n010\n3 3\n000\n111\n000" expected_output = "YES\nNO" assert solution(input_text) == expected_output def test_case_2(): input_text = "1\n2 2\n01\n10" expected_output = "YES" assert solution(input_text...
[ { "docstring": null, "function_declaration": "def is_possible_to_rearrange(grid):", "function_name": "is_possible_to_rearrange", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def possible_rearrangement(test_cases):", "function_name": "possible_rearrangem...
[ 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_possible_to_rearrange(n, m, grid):\n \"\"\"\n Determines if it is possible to rearrange the grid such that \n no two adjacent cells (horizontally o...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057929", "row_id": 57929, "seed_ids": "[11240]" }
0.694803
Taco_57929
I
[ "is_possible_to_rearrange", "possible_rearrangement", "parser", "solution" ]
4
[ [ "possible_rearrangement", "is_possible_to_rearrange" ], [ "solution", "parser" ], [ "solution", "possible_rearrangement" ] ]
3
[]
false
[]
false
pytest
true
[]
true
6370ab6bd4d011a0be8cae6b3f2489766c102b79
58668ad6c997216280eeee1b1e7d267f56ed9eda
v1.0
instruct
Taco
Taco_57954_I
Given a rectangular grid of characters, check whether there exists a contiguous substring in any row or column that reads the same forward and backward (i.e., is a palindrome). -----Input----- The first line contains an integer $t$ ($1 \le t \le 100$) — the number of test cases. The description of the test cases foll...
def is_palindrome(s): return s == s[::-1] def contains_palindrome(grid, n, m): # Check each row for palindromes for row in grid: for k in range(2, m+1): # Minimum palindrome length is 2 for i in range(m - k + 1): if is_palindrome(row[i:i+k]): return ...
from solution import check_palindrome_substrings def test_single_case_yes(): test_cases = [ ([ "abc", "aba", "xyz" ], 3, 3)] assert check_palindrome_substrings(test_cases) == ["YES"] def test_single_case_no(): test_cases = [ ([ "abc", ...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def contains_palindrome(grid, n, m):", "function_name": "contains_palindrome", "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_palindrome(s):\n return s == s[::-1]\n\ndef has_palindromic_substring(grid, n, m):\n for row in grid:\n for length in range(2, m+1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00057954", "row_id": 57954, "seed_ids": "[983]" }
0.803295
Taco_57954
I
[ "is_palindrome", "contains_palindrome", "check_palindrome_substrings" ]
3
[ [ "check_palindrome_substrings", "contains_palindrome" ], [ "contains_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b2497af961eec2dc1bf1c34260617afcd7c5067d
b81a132f8f10f55d204f5f2479fd1bbe281671f3
v1.0
instruct
Taco
Taco_58021_I
A company is planning to design a new transportation system in Metro City. The city is represented as an unweighted, bidirectional graph with n intersections, numbered from 1 to n. Initially, there are no roads between the intersections. During the construction phase, m bidirectional roads will be built, one after ano...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[rootX] < rank[root...
from solution import count_connected_components def test_case_1(): n = 5 roads = [(1, 2), (3, 4), (2, 4)] expected = [4, 3, 2] assert count_connected_components(n, roads) == expected def test_case_2(): n = 2 roads = [(1, 2)] expected = [1] assert count_connected_components(n, roads) ==...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_parent(parent, x):\n if parent[x] != x:\n parent[x] = find_parent(parent, parent[x])\n return parent[x]\n\ndef union(parent, rank, x, y):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00058021", "row_id": 58021, "seed_ids": "[5201]" }
0.694951
Taco_58021
I
[ "find", "union", "count_connected_components" ]
3
[ [ "count_connected_components", "find" ], [ "count_connected_components", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5f2d6eaf531df82296404317d3f3fb69ed550037
d818fe4de14810c30d234181a91c345dae0c9b09
v1.0
instruct
Taco
Taco_58056_I
Consider a tree (connected acyclic graph) consisting of N nodes, where each node i has an integer value v_i. You are given the task of finding the maximum possible sum of values of the nodes that can be collected by visiting nodes on exactly one simple path. A simple path is a path that does not visit any vertex more ...
import sys from collections import defaultdict sys.setrecursionlimit(200000) def dfs(node, parent, values, adj_list): max1 = max2 = 0 for neighbor in adj_list[node]: if neighbor == parent: continue current_sum = dfs(neighbor, node, values, adj_list) if current_sum > max1: ...
def test_max_path_sum(): assert max_path_sum( 5, [1, 2, 3, 4, 5], [(1, 2), (1, 3), (3, 4), (3, 5)] ) == 12 def test_simple_case(): assert max_path_sum( 2, [1, 2], [(1, 2)] ) == 3 def test_line_tree(): assert max_path_sum( 4, [1, ...
[ { "docstring": null, "function_declaration": "def dfs(node, parent, values, adj_list):", "function_name": "dfs", "parameter_list": "(node, parent, values, adj_list)" }, { "docstring": null, "function_declaration": "def max_path_sum(n, vals, edges):", "function_name": "max_path_sum", ...
[ 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 sys\nfrom collections import defaultdict\n\nsys.setrecursionlimit(200000)\n\ndef dfs(node, parent, values, adj_list):\n max1 = max2 = 0\n for neighbor...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00058056", "row_id": 58056, "seed_ids": "[16416]" }
0.767599
Taco_58056
I
[ "dfs", "max_path_sum", "parse_input" ]
3
[ [ "max_path_sum", "dfs" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
c51a4e43cda97f463f85b8e0a64bba8539b8b994
21d7529c21940bc2bb56ed5a5e8b6c9e55306564
v1.0
instruct
Taco
Taco_58096_I
Given a string S, determine if S can be rearranged into a palindrome. Return all possible palindromic arrangements in any order. If no palindromic arrangement exists, return an empty list. Example 1: Input: "aabb" Output: ["abba", "baab"] Example 2: Input: "abc" Output: [] Example 3: Input: "racecar" Output: ["racec...
from collections import Counter from itertools import permutations def can_form_palindrome(s): """ Check if the input string can be rearranged into a palindrome. """ count = Counter(s) odd_count = sum(1 for c in count if count[c] % 2 != 0) return odd_count <= 1 def generate_palindromic_permuta...
from solution import generate_palindromic_permutations def test_generate_palindromic_permutations_example1(): result = generate_palindromic_permutations("aabb") expected = sorted(["abba", "baab"]) assert sorted(result) == expected def test_generate_palindromic_permutations_example2(): result = generat...
[ { "docstring": "Check if the input string can be rearranged into a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": "Return all palindromic permutations of the input string.", "function_...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nfrom itertools import permutations\n\ndef can_form_palindrome(s):\n \"\"\"\n Function to determine if the string s can be re...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00058096", "row_id": 58096, "seed_ids": "[20688]" }
0.755012
Taco_58096
I
[ "can_form_palindrome", "generate_palindromic_permutations" ]
2
[ [ "generate_palindromic_permutations", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
30ada208668f063c25fb8c2e0fbca4c4ec61d1d3
b0058eaa6abde5dc1b37c5d18c679a5603dac96c
v1.0
instruct
Taco
Taco_58107_I
You have been tasked with developing a method to determine if a given list of strings can be rearranged to form a sequence such that each successive string differs from the previous one by exactly one character. Two strings are considered to differ by one character if they are the same length and differ by exactly one ...
from itertools import permutations def differ_by_one_char(s1, s2): """ Check if two strings differ by exactly one character. """ count_diff = 0 for a, b in zip(s1, s2): if a != b: count_diff += 1 if count_diff > 1: return False return count_diff == 1 def...
from solution import can_form_sequence def test_example_true(): assert can_form_sequence(["abc", "bbc", "bac"]) == True def test_example_false(): assert can_form_sequence(["abc", "def", "ghi"]) == False def test_single_string(): assert can_form_sequence(["abc"]) == True def test_two_strings_one_char_dif...
[ { "docstring": "Check if two strings differ by exactly one character.", "function_declaration": "def differ_by_one_char(s1, s2):", "function_name": "differ_by_one_char", "parameter_list": "(s1, s2)" }, { "docstring": "Determine if the given list of strings can be rearranged to form a sequenc...
[ 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 itertools import permutations\n\ndef differ_by_one_char(s1, s2):\n \"\"\"\n Check if two strings differ by exactly one character.\n \"\"\"\n count...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00058107", "row_id": 58107, "seed_ids": "[11280]" }
0.771631
Taco_58107
I
[ "differ_by_one_char", "can_form_sequence" ]
2
[ [ "can_form_sequence", "differ_by_one_char" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0e8803714430fd0cdc48fdef8cfe3c52536d555
e9ca5a63fcdda2065876a1369a389c1ec81fa5e2
v1.0
instruct
Taco
Taco_58117_I
Two integers N and M are given as inputs. Write a program to find the number of common divisors of N and M. -----Input----- The first line contains an integer T, the total number of test cases. Then, T lines follow, each line containing two integers N and M. -----Output----- Display the number of common divisors fo...
def gcd(a, b): """ Helper function to compute the greatest common divisor of a and b using Euclid's algorithm. """ while b: a, b = b, a % b return a def common_divisors_count(n, m): """ Returns the number of common divisors between two numbers n and m. """ common_gcd = gcd(n...
from solution import gcd, common_divisors_count, solve def test_gcd(): assert gcd(12, 18) == 6 assert gcd(100, 75) == 25 assert gcd(7, 13) == 1 assert gcd(0, 18) == 18 assert gcd(18, 0) == 18 def test_common_divisors_count(): assert common_divisors_count(12, 18) == 4 assert common_divisors...
[ { "docstring": "Helper function to compute the greatest common divisor of a and b using Euclid's algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the number of common divisors between two numbers n and 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": "def gcd(a, b):\n \"\"\"\n Returns the greatest common divisor of a and b.\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\ndef common_divi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058117", "row_id": 58117, "seed_ids": "[2829]" }
0.671997
Taco_58117
I
[ "gcd", "common_divisors_count", "solve" ]
3
[ [ "common_divisors_count", "gcd" ], [ "solve", "common_divisors_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1369c4de56a6b8657cdd19cc78c9bf88cc6e2dc4
cb35f1129e1588c5efaee5a318d143c6fb2b7cee
v1.0
instruct
Taco
Taco_58136_I
In a kingdom far away, there are n islands connected by m bidirectional bridges. Each bridge has a certain magical value associated with it. The wizard of the kingdom decided to organize a transportation network such that people can travel from one island to any other island. To accomplish this, he wants to choose a su...
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...
from solution import minimum_possible_total_magical_value def test_example1(): n = 4 m = 5 bridges = [ (1, 2, 1), (1, 3, 4), (1, 4, 3), (2, 3, 2), (3, 4, 5) ] assert minimum_possible_total_magical_value(n, m, bridges) == 6 def test_example2(): n = 3 ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n rootX = find(parent, x)\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058136", "row_id": 58136, "seed_ids": "[19021]" }
0.759882
Taco_58136
I
[ "find", "union", "kruskal", "minimum_possible_total_magical_value" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_possible_total_magical_value", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
aea81243146d8c4c0e043e2065c43e0242ec08d7
da12cd82358691ab1986ab79b26a24141ec9a9a5
v1.0
instruct
Taco
Taco_58150_I
Given an integer N, determine if it can be expressed as the sum of two prime numbers. If it can, return any pair of such prime numbers. If not, return -1. -----Constraints----- - 4 ≦ N ≦ 10^6 -----Input----- The input is given from Standard Input in the following format: N -----Output----- If N can be expressed as t...
def sieve_of_eratosthenes(n): 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 is_prime[0] = is_prime[1] = False return is_prime def find_sum_of_primes(N): if N < 4: ...
from solution import find_sum_of_primes def test_small_prime_sum(): result = find_sum_of_primes(4) assert result == (2, 2) or result == (2, 2), "Test for N=4 failed." def test_valid_prime_sum_34(): result = find_sum_of_primes(34) valid_results = [(3, 31), (5, 29), (11, 23), (17, 17)] assert re...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_sum_of_primes(N):", "function_name": "find_sum_of_primes", "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_prime(num):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return Tru...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00058150", "row_id": 58150, "seed_ids": "[21399]" }
0.747949
Taco_58150
I
[ "sieve_of_eratosthenes", "find_sum_of_primes" ]
2
[ [ "find_sum_of_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f30f81e3bd3cc894c4438f767e99b1fac8a7536f
9b1669e93d7ac681c4647f5d924ec2421d21d7ad
v1.0
instruct
Taco
Taco_58157_I
In a small village, there is a need to build a water supply network that connects all the houses. The village consists of N houses numbered from 1 to N, and M possible pipe connections between them. Each pipe connection i connects houses a_i and b_i and has a construction cost of c_i. The village chief wants to minimiz...
def find(parent, i): # This function finds the parent of a node i if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): # This function unions the sets containing x and y rootX = find(parent, x) rootY = find...
from solution import min_cost_to_connect_houses def test_case_1(): N = 4 M = 5 connections = [ (1, 2, 10), (1, 3, 15), (2, 3, 5), (2, 4, 20), (3, 4, 10) ] assert min_cost_to_connect_houses(N, M, connections) == 25 def test_case_2(): N = 3 M = 1 c...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n # This function finds the parent of a node i\n if parent[i] == i:\n return i\n else:\n parent[i] = find(parent, paren...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00058157", "row_id": 58157, "seed_ids": "[10436]" }
0.68884
Taco_58157
I
[ "find", "union", "min_cost_to_connect_houses", "main" ]
4
[ [ "min_cost_to_connect_houses", "find" ], [ "min_cost_to_connect_houses", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
0fea9449ca9f671aba0310b23271e157d73f510c
e582c81317a072d35632309b64521e238ae08d2e
v1.0
instruct
Taco
Taco_58219_I
Write a function that takes a list of strings containing valid and invalid mathematical expressions involving integers, addition (+), and subtraction (-). The goal is to evaluate only the valid expressions and return a list with the results of those evaluations. A valid expression must: 1. Start and end with an intege...
def is_valid_expression(exp): """ Checks if the expression is valid according to the rules specified. """ tokens = exp.strip().split() if len(tokens) < 3: return False # Check if first and last tokens are integers. if not tokens[0].isdigit() or not tokens[-1].isdigit(): ...
from solution import is_valid_expression, evaluate_expressions def test_is_valid_expression(): assert is_valid_expression("3 + 5 - 2") == True assert is_valid_expression("3 + -5") == False assert is_valid_expression("10 + 15 - 5") == True assert is_valid_expression("3-5") == False assert is_valid_e...
[ { "docstring": "Checks if the expression is valid according to the rules specified.", "function_declaration": "def is_valid_expression(exp):", "function_name": "is_valid_expression", "parameter_list": "(exp)" }, { "docstring": "Evaluates valid mathematical expressions from the input list and...
[ 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_expressions(expressions):\n \"\"\"\n Evaluates only valid mathematical expressions involving integers, addition (+), and subtraction (-).\n A...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058219", "row_id": 58219, "seed_ids": "[5700]" }
0.673087
Taco_58219
I
[ "is_valid_expression", "evaluate_expressions" ]
2
[ [ "evaluate_expressions", "is_valid_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7c8bf59c5a87fba9716c8f68b6332a96c0c3ff1f
3841d7856a71a8aea32c474f9f8f6bb942417564
v1.0
instruct
Taco
Taco_58224_I
Alice is given a list of $N$ integers and a list of $Q$ queries. Each query consists of two integers $L$ and $R$ and asks for the product of all integers in the sublist from index $L$ to index $R$ (inclusive). Since the product can be very large, return the result modulo $(10^9+7)$. Can you help Alice efficiently answ...
MOD = 10**9 + 7 def compute_prefix_products(arr): prefix_products = [1] * (len(arr) + 1) for i in range(1, len(arr) + 1): prefix_products[i] = (prefix_products[i-1] * arr[i-1]) % MOD return prefix_products def range_product(L, R, prefix_products): return (prefix_products[R] * pow(prefix_produc...
from solution import process_queries def test_single_element(): assert process_queries(1, [5], 1, [(1, 1)]) == [5 % (10**9 + 7)] def test_entire_range(): assert process_queries(5, [1, 2, 3, 4, 5], 1, [(1, 5)]) == [120 % (10**9 + 7)] def test_partial_ranges(): assert process_queries(5, [1, 2, 3, 4, 5], 3,...
[ { "docstring": null, "function_declaration": "def compute_prefix_products(arr):", "function_name": "compute_prefix_products", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def range_product(L, R, prefix_products):", "function_name": "range_product", "...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef preprocess_product(arr):\n \"\"\"\n Preprocesses the input array to calculate prefix products modulo (10^9 + 7).\n \"\"\"\n n = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058224", "row_id": 58224, "seed_ids": "[3010]" }
0.703712
Taco_58224
I
[ "compute_prefix_products", "range_product", "process_queries" ]
3
[ [ "process_queries", "compute_prefix_products" ], [ "process_queries", "range_product" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
7b231b18e41249f8b20fe998c90ada8f6bde29ca
5035575a41ed948e769cb7ae9c643993030a16d8
v1.0
instruct
Taco
Taco_58244_I
In a grid of size `m x n` consisting of characters, word search is a challenge where a word can be constructed from the left-right, right-left, down-up, up-down, and diagonal directions. We are given a grid of characters and a word. The task is to determine if the word exists in the grid. A word can be constructed fro...
def exist(board, word): def dfs(board, word, i, j, m, n, index): if index == len(word): return True if i < 0 or i >= m or j < 0 or j >= n or board[i][j] != word[index]: return False # temporarily mark the board cell as visited to avoid revisiting temp, board[i...
def test_word_search_example_1(): grid = [ ['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ['A', 'D', 'E', 'E'] ] word = "ABCCED" assert word_search(3, 4, grid, word) == "YES" def test_word_search_example_2(): grid = [ ['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ...
[ { "docstring": null, "function_declaration": "def exist(board, word):", "function_name": "exist", "parameter_list": "(board, word)" }, { "docstring": null, "function_declaration": "def word_search(m, n, grid, word):", "function_name": "word_search", "parameter_list": "(m, n, grid...
[ 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 exist(board, word):\n def dfs(board, word, i, j, m, n, index):\n if index == len(word):\n return True\n if i < 0 or i >= m or j < 0...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00058244", "row_id": 58244, "seed_ids": "[7212]" }
0.697428
Taco_58244
I
[ "exist", "word_search" ]
2
[ [ "word_search", "exist" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d9aca814df1c7eb438bd7697364f1b9d6f739134
89440bb9cab17175b7adea025efe7424e25fd204
v1.0
instruct
Taco
Taco_58247_I
Given an array of integers, you are required to perform 'Q' queries of two types on it: 1. `update(x, y)`: Update the element at position 'x' of the array to 'y'. 2. `kth_one(l, r, k)`: Find the k-th smallest element in the subarray from index 'l' to 'r' inclusive. Implement a program to handle these queries efficien...
def update(array, x, y): """ Updates the element at position x in the array to y. """ array[x-1] = y def kth_one(array, l, r, k): """ Returns the k-th smallest element in the subarray from index l to r inclusive. """ subarray = array[l-1:r] subarray.sort() return subarray[k-1] ...
from solution import update, kth_one, process_queries def test_update(): array = [1, 5, 2, 6, 3, 4] update(array, 3, 7) assert array == [1, 5, 7, 6, 3, 4] def test_kth_one(): array = [1, 5, 7, 6, 3, 4] result = kth_one(array, 2, 5, 3) assert result == 6 result = kth_one(array, 1, 6, 4) ...
[ { "docstring": "Updates the element at position x in the array to y.", "function_declaration": "def update(array, x, y):", "function_name": "update", "parameter_list": "(array, x, y)" }, { "docstring": "Returns the k-th smallest element in the subarray from index l to r inclusive.", "fun...
[ 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": "class SegmentTree:\n def __init__(self, data):\n self.n = len(data)\n self.data = data[:]\n self.tree = [[] for _ in range(4 * self.n)]\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00058247", "row_id": 58247, "seed_ids": "[9706]" }
0.708653
Taco_58247
I
[ "update", "kth_one", "process_queries" ]
3
[ [ "process_queries", "kth_one" ], [ "process_queries", "update" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
e2cb02b940555c25e7a3a3dd91f9b460b674e172
7a76714c663de8e72735498b4a8230f557fdfb50
v1.0
instruct
Taco
Taco_58280_I
Given a series of integers that follow the rules of a Palindromic sequence, where each integer is a palindrome and is generated by reversing and adding the original integer (e.g., 23 becomes 23 + 32 = 55). The sequence continues until it becomes a palindrome. Write a program that takes a list of integers and determine...
def is_palindrome(n): return str(n) == str(n)[::-1] def steps_to_palindrome(n): step_count = 0 while step_count < 1000: if is_palindrome(n): return step_count n = n + int(str(n)[::-1]) step_count += 1 return "FAIL" def palindromic_sequence_steps(test_cases): res...
from solution import palindromic_sequence_steps def test_single_input(): assert palindromic_sequence_steps([23]) == [1] def test_multiple_input(): assert palindromic_sequence_steps([23, 87, 196]) == [1, 4, "FAIL"] def test_large_input(): assert palindromic_sequence_steps([89]) == [24] # Number of steps ...
[ { "docstring": null, "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def steps_to_palindrome(n):", "function_name": "steps_to_palindrome", "parameter_list": "(n)" }, { ...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Check if a given integer n is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef reverse_and_add(n):\n \...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00058280", "row_id": 58280, "seed_ids": "[9706]" }
0.770111
Taco_58280
I
[ "is_palindrome", "steps_to_palindrome", "palindromic_sequence_steps" ]
3
[ [ "palindromic_sequence_steps", "steps_to_palindrome" ], [ "steps_to_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
601668b3f027d2049e09674c02195e8440f43e2a
69af119a327cb4784028662be969d7d01fc9d750
v1.0
instruct
Taco
Taco_58320_I
You are given a grid of size N x M. Each cell in the grid can be either passable or blocked. You are also given a list of robot start positions and their respective end positions. Each robot can only move vertically or horizontally, one cell at a time, and cannot move into blocked cells. Determine the minimum steps re...
from collections import deque def bfs(grid, start, end, N, M): sx, sy = start ex, ey = end if grid[sx][sy] == '#' or grid[ex][ey] == '#': return -1 directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] visited = [[False] * M for _ in range(N)] queue = deque([(sx, sy, 0)]) # (row, col, steps...
from solution import min_steps_each_robot def test_min_steps_basic(): N, M = 5, 5 grid = [ ".....", ".###.", ".#.#.", ".###.", "....." ] robots = [(0, 0, 4, 4), (2, 2, 0, 0)] expected = [8, -1] assert min_steps_each_robot(N, M, grid, robots) == expected ...
[ { "docstring": null, "function_declaration": "def bfs(grid, start, end, N, M):", "function_name": "bfs", "parameter_list": "(grid, start, end, N, M)" }, { "docstring": null, "function_declaration": "def min_steps_each_robot(N, M, grid, robots):", "function_name": "min_steps_each_robo...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_steps_to_reach(grid, start, end):\n rows, cols = len(grid), len(grid[0])\n visited = [[False] * cols for _ in range(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058320", "row_id": 58320, "seed_ids": "[20174]" }
0.774001
Taco_58320
I
[ "bfs", "min_steps_each_robot" ]
2
[ [ "min_steps_each_robot", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e7a1d4b4d8a46b02c079f1d996ed5b8430590708
794fda25787a59e3c510ab8e4f1de6ad0bc1fa13
v1.0
instruct
Taco
Taco_58355_I
A group of scientists has discovered a new type of organism that exhibits interesting behavior in terms of movement. The organisms live on a 2D grid and can move from one grid cell to another based on specific movement rules. The grid is of size N x M, with each cell having a respective value representing the "energy" ...
def min_energy_path(grid): """ Returns the minimum energy required to move from the top-left to the bottom-right corner of the grid. """ N = len(grid) M = len(grid[0]) # Create a 2D dp array to store the minimum energy required to reach each cell dp = [[0]*M for _ in range(N)] ...
from solution import min_energy_required def test_min_energy_simple(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_energy_required(3, 3, grid) == 7 def test_min_energy_single_row(): grid = [ [1, 2, 3, 4] ] assert min_energy_required(1, 4, grid) == 10 ...
[ { "docstring": "Returns the minimum energy required to move from \nthe top-left to the bottom-right corner of the grid.", "function_declaration": "def min_energy_path(grid):", "function_name": "min_energy_path", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_energy(N, M, grid):\n \"\"\"\n Calculate the minimum energy required for the organism to reach the bottom-right corner of the grid.\n \n :param...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00058355", "row_id": 58355, "seed_ids": "[20870]" }
0.714219
Taco_58355
I
[ "min_energy_path", "min_energy_required" ]
2
[ [ "min_energy_required", "min_energy_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
278a99c601ac5a9ac82c9ae821ea912c8ff495f3
beea736c80468cdea5569f9df82dab4981f62159
v1.0
instruct
Taco
Taco_58398_I
You are given a 2D grid of dimensions n x m filled with non-negative integers. Your task is to handle q queries, each described by four integers x1, y1, x2, and y2 (1-based indices), which define a sub-grid. For each query, calculate the sum of all the elements within the specified sub-grid. To optimize the querying p...
def preprocess_grid(grid): """ Preprocess the grid to create a prefix sum matrix. """ n = len(grid) m = len(grid[0]) 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] = (grid[i-1][j-1] + ...
def test_preprocess_grid(): grid = [ [1, 2, 4], [8, 16, 32], [64, 128, 256] ] expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 7], [0, 9, 27, 63], [0, 73, 219, 511] ] assert preprocess_grid(grid) == expected_prefix_sum def test_query_sum(): ...
[ { "docstring": "Preprocess the grid to create a prefix sum matrix.", "function_declaration": "def preprocess_grid(grid):", "function_name": "preprocess_grid", "parameter_list": "(grid)" }, { "docstring": "Query the sum of the sub-grid defined by (x1, y1) to (x2, y2).\nAdjust indices to 1-bas...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_prefix_sum(grid):\n n = len(grid)\n m = len(grid[0])\n prefix_sum = [[0] * (m + 1) for _ in range(n + 1)]\n \n for i in range(1, n + ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00058398", "row_id": 58398, "seed_ids": "[13512]" }
0.672702
Taco_58398
I
[ "preprocess_grid", "query_sum", "handle_queries" ]
3
[ [ "handle_queries", "preprocess_grid" ], [ "handle_queries", "query_sum" ] ]
2
[ "handle_queries" ]
false
[]
false
pytest
false
[]
true
7242aeb6b13b5b598597cc43fcb51e123286f249
1c6ce032e6a0167ebf070cd0afff502546dfc238
v1.0
instruct
Taco
Taco_58419_I
In a country far away, there are N cities connected by M bidirectional roads. The government wants to improve transportation by adding new roads so that all cities are easily accessible from each other. They need your help to determine if the network of cities is already fully connected. If the cities are already ful...
def find(parent, i): if parent[i] == -1: return i else: return find(parent, parent[i]) def union(parent, x, y): x_set = find(parent, x) y_set = find(parent, y) if x_set != y_set: parent[x_set] = y_set def is_fully_connected(num_cities, roads): parent = [-1] * num_cities...
def test_check_fully_connected(): test_cases = [ (3, 3, [(1, 2), (2, 3), (3, 1)]), (4, 2, [(1, 2), (3, 4)]), (5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)]), (5, 3, [(1, 2), (2, 3), (3, 4)]), (6, 6, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 1)]), (1, 0, []), ] ex...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }, { "doc...
[ 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 check_fully_connected(T, test_cases):\n \"\"\"\n Returns whether the network of cities in each test case is fully connected or not.\n \"\"\"\n def ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058419", "row_id": 58419, "seed_ids": "[6504]" }
0.760697
Taco_58419
I
[ "find", "union", "is_fully_connected", "check_fully_connected" ]
4
[ [ "check_fully_connected", "is_fully_connected" ], [ "is_fully_connected", "find" ], [ "is_fully_connected", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
58ed982aa8ac9138a17af8ddc4240ab6db0b3411
d3947f023c9edf08911696a474a13a613e425688
v1.0
instruct
Taco
Taco_58470_I
Write a program that simulates the traversal of a knight in a chessboard and finds the minimum number of moves required to reach from a starting position to a target position. The 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 sq...
from collections import deque def is_valid(x, y, n=8): return 1 <= x <= n and 1 <= y <= n def knight_moves(start_x, start_y, target_x, target_y): if (start_x, start_y) == (target_x, target_y): return 0 directions = [ (2, 1), (2, -1), (-2, 1), (-2, -1), (1, 2), (1, -2), (-1, 2)...
from solution import knight_moves, solve_knight_moves def test_knight_moves_same_position(): assert knight_moves(1, 1, 1, 1) == 0 def test_knight_moves_basic(): assert knight_moves(1, 1, 8, 8) == 6 def test_knight_moves_short_distance(): assert knight_moves(1, 1, 2, 2) == 4 assert knight_moves(3, 3, ...
[ { "docstring": null, "function_declaration": "def is_valid(x, y, n=8):", "function_name": "is_valid", "parameter_list": "(x, y, n=8)" }, { "docstring": null, "function_declaration": "def knight_moves(start_x, start_y, target_x, target_y):", "function_name": "knight_moves", "param...
[ 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\n# Possible knight moves\nmoves = [(2, 1), (1, 2), (-1, 2), (-2, 1), \n (-2, -1), (-1, -2), (1, -2), (2, -1)]\n\ndef is_wit...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00058470", "row_id": 58470, "seed_ids": "[23577]" }
0.709093
Taco_58470
I
[ "is_valid", "knight_moves", "solve_knight_moves", "main" ]
4
[ [ "knight_moves", "is_valid" ], [ "solve_knight_moves", "knight_moves" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8d514fdc04e4be7b3aacf9ce16993c8960324990
5e1622fadb530ec1cc6cf17425973f422628add3
v1.0
instruct
Taco
Taco_58591_I
Write a function to check whether a given number is a 'Beautiful Number'. A number is considered beautiful if it satisfies the following conditions: 1. It is a positive integer. 2. Each digit of the number is a prime digit (2, 3, 5, or 7). 3. The number itself is a prime number. For example: - 23 is a beautiful number...
def is_prime(num): """ Helper function to check if a number is prime. """ 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: ...
def test_isBeautifulNumber_prime_beautiful(): assert isBeautifulNumber(23) == "Yes" assert isBeautifulNumber(37) == "Yes" assert isBeautifulNumber(53) == "Yes" assert isBeautifulNumber(73) == "Yes" def test_isBeautifulNumber_prime_but_not_beautiful(): assert isBeautifulNumber(31) == "No" assert...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Function to check if the given number is a beautiful number.", "function_declaration": "def isBeautiful...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def isBeautifulNumber(n):\n \"\"\"\n Checks if a given number is a 'Beautiful Number'.\n A beautiful number is a positive integer where each digit is a pr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058591", "row_id": 58591, "seed_ids": "[8239]" }
0.65356
Taco_58591
I
[ "is_prime", "isBeautifulNumber" ]
2
[ [ "isBeautifulNumber", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5cb64c5531799d2f5b6b88cb5543938a664b921f
b4ccc9cb176e031337c93f5a33e5d433b91b83fb
v1.0
instruct
Taco
Taco_58610_I
You've been tasked with creating a tool to help classify reviews by sentiment. Each review can either be positive, negative, or neutral. You must write a program that predicts the sentiment based on the text of the review. You'll receive a training set of reviews to develop your sentiment analysis model. The dataset w...
import os import string from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.naive_bayes import MultinomialNB from sklearn.pipeline import make_pipeline import joblib def load_training_data(training_path): texts, labels = [], [] for sentiment in ['positive', 'negative', 'neutral']: ...
import pytest import os from solution import train_model, load_model, predict_sentiment def setup_module(module): # Ensure the training directory exists and contains files if not os.path.exists('train_sent'): os.makedirs('train_sent/positive') os.makedirs('train_sent/negative') os.maked...
[ { "docstring": null, "function_declaration": "def load_training_data(training_path):", "function_name": "load_training_data", "parameter_list": "(training_path)" }, { "docstring": null, "function_declaration": "def train_model(training_path):", "function_name": "train_model", "pa...
[ 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 os\nimport string\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.naive_bayes import MultinomialNB\nfrom sklearn.pipeline import ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00058610", "row_id": 58610, "seed_ids": "[12009]" }
0.587046
Taco_58610
I
[ "load_training_data", "train_model", "load_model", "predict_sentiment", "main" ]
5
[ [ "train_model", "load_training_data" ] ]
1
[]
false
[]
false
pytest
true
[ "joblib", "sklearn" ]
false
8616aff78f4b6cb1e39eea7a33a06d1d9f078f60
a639bf38b664bf75773c2228553bf08cc0388dba
v1.0
instruct
Taco
Taco_58637_I
H: Mastermind / Code-breaker ### story Mastermind is a classic code-breaking game for two players. One player sets a secret code, and the other tries to guess it. The code-setter gives feedback on how many guesses are correct in both color and position and how many are correct in color but not in the correct position...
def feedback(secret, guess): """ Function to provide feedback on the guess based on the secret code. Returns a tuple (correct_position, correct_value). """ correct_position = 0 correct_value = 0 secret_used = [False] * len(secret) guess_used = [False] * len(guess) # First pass: coun...
def test_feedback_exact_match(): assert feedback("1234", "1234") == (4, 0) def test_feedback_no_match(): assert feedback("1234", "5678") == (0, 0) def test_feedback_partial_match(): assert feedback("1234", "1243") == (2, 2) def test_feedback_same_digits_different_positions(): assert feedback("1234", ...
[ { "docstring": "Function to provide feedback on the guess based on the secret code.\nReturns a tuple (correct_position, correct_value).", "function_declaration": "def feedback(secret, guess):", "function_name": "feedback", "parameter_list": "(secret, guess)" }, { "docstring": "Simulates the ...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def mastermind(L, K, C, guesses):\n \"\"\"\n Simulates the Mastermind game between the system and the guesser.\n \n L: length of the secret code\n K...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00058637", "row_id": 58637, "seed_ids": "[14083]" }
0.6326
Taco_58637
I
[ "feedback", "mastermind_game" ]
2
[ [ "mastermind_game", "feedback" ] ]
1
[]
false
[]
false
pytest
false
[]
true
be2a86dddbdc311a8c87ce11feece4e44967ef9e
1044496441ef1109f4df183a748ff6dc0fb3c05a
v1.0
instruct
Taco
Taco_58657_I
### Problem Description You are given an NxN grid filled with positive integers. Your task is to find the size of the largest sub-square which contains all unique values. A sub-square is defined as a square sub-grid within the NxN grid. ### Constraints * 1 \leq N \leq 100 * The values in the grid are positive integer...
def is_unique(grid, top, left, size): """ Check if sub-square starting at (top, left) of given size is unique """ seen = set() for i in range(top, top + size): for j in range(left, left + size): if grid[i][j] in seen: return False seen.add(grid[i][j]) retu...
def test_is_unique(): grid = [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16] ] assert is_unique(grid, 0, 0, 4) == True assert is_unique(grid, 0, 0, 2) == True assert is_unique(grid, 1, 1, 2) == True grid_with_duplicates = [ [1, 2, 3, 4], ...
[ { "docstring": "Check if sub-square starting at (top, left) of given size is unique ", "function_declaration": "def is_unique(grid, top, left, size):", "function_name": "is_unique", "parameter_list": "(grid, top, left, size)" }, { "docstring": "Return the size of the largest unique sub-squar...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_unique(grid, top, left, size):\n \"\"\" Check if sub-square starting at (top, left) of given size is unique \"\"\"\n seen = set()\n for i in range(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00058657", "row_id": 58657, "seed_ids": "[14171]" }
0.679465
Taco_58657
I
[ "is_unique", "largest_unique_subsquare" ]
2
[ [ "largest_unique_subsquare", "is_unique" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1ee9f062e3b0a21fefa233a607186df5b40e99d4
2b293155293b0ebc9a5f7d49572012abe4ef9fbb
v1.0
instruct
Taco
Taco_58702_I
There is a mysterious island where people speak a unique dialect. The dialect consists entirely of transformations of words based on specific rules. One of the local scholars has a fascination with creating and solving puzzles using this dialect. The scholar presents you with a challenge involving transformations of st...
def transform_string(s): """ Transforms each character in the string to the next character in the alphabet. The alphabet is considered cyclic, so 'z' becomes 'a'. """ transformed = [] for char in s: if char == 'z': transformed.append('a') else: transformed...
from solution import transform_string, transform_input def test_transform_string(): assert transform_string("abc") == "bcd" assert transform_string("xyz") == "yza" assert transform_string("hello") == "ifmmp" assert transform_string("z") == "a" assert transform_string("az") == "ba" assert transf...
[ { "docstring": "Transforms each character in the string to the next character in the alphabet.\nThe alphabet is considered cyclic, so 'z' becomes 'a'.", "function_declaration": "def transform_string(s):", "function_name": "transform_string", "parameter_list": "(s)" }, { "docstring": "Takes a...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def transform_string(s):\n \"\"\"\n Transforms a string where each character is replaced with the next character\n in the English alphabet. The alphabet i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058702", "row_id": 58702, "seed_ids": "[6894]" }
0.771485
Taco_58702
I
[ "transform_string", "transform_input" ]
2
[ [ "transform_input", "transform_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6ef3e6c905df170dc2113f9610fd6b0d49a2b001
47e6a6d59437588c415f59447671e9dee74d0f07
v1.0
instruct
Taco
Taco_58765_I
In a fantasy land called Gridlandia, the king has a peculiar interest in magic square matrices. A magic square matrix is a square grid filled with distinct positive integers such that the sum of the integers in each row, each column, and both main diagonals are the same. Given a 3x3 grid partially filled with integers...
def is_magic_square(matrix): """ Check whether a 3x3 matrix is a magic square. """ s = sum(matrix[0]) for i in range(3): if sum(matrix[i]) != s or sum(matrix[j][i] for j in range(3)) != s: return False if sum(matrix[i][i] for i in range(3)) != s or sum(matrix[i][2-i] for i in...
from solution import complete_grid def test_complete_grid_example(): input_grid = [ [8, 1, 6], [3, 0, 0], [0, 0, 0] ] output_grid = [ [8, 1, 6], [3, 5, 7], [4, 9, 2] ] assert complete_grid(input_grid) == output_grid def test_complete_grid_another(): ...
[ { "docstring": "Check whether a 3x3 matrix is a magic square.", "function_declaration": "def is_magic_square(matrix):", "function_name": "is_magic_square", "parameter_list": "(matrix)" }, { "docstring": "Try to complete the 3x3 grid to form a magic square.", "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_magic(square):\n # Check rows, columns and diagonals for equal sum\n target_sum = sum(square[0])\n for row in square:\n if sum(row) != targe...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00058765", "row_id": 58765, "seed_ids": "[4396]" }
0.621387
Taco_58765
I
[ "is_magic_square", "fill_grid", "complete_grid" ]
3
[ [ "complete_grid", "fill_grid" ], [ "fill_grid", "is_magic_square" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3e0b19b91afb6b2472c862398d3f35273bbd7a22
d9c52a247f65bb9827d8798651007a41c8fcf7a0
v1.0
instruct
Taco
Taco_58823_I
You are given a binary tree where each node has a value. Your task is to determine if the tree is a Binary Search Tree (BST). A Binary Search Tree is a tree in which for every node, the following properties hold: 1. The left subtree of a node contains only nodes with values less than the node's value. 2. The right su...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def create_tree(node_tuples): if not node_tuples: return None nodes = {} for val, left, right in node_tuples: if val not in nodes: nodes[val] = TreeNode(v...
from solution import check_if_bst def test_balanced_bst(): input_data = [(8, 3, 10), (3, 1, 6), (1, None, None), (6, 4, 7), (4, None, None), (7, None, None), (10, None, 14), (14, 13, None), (13, None, None)] assert check_if_bst(input_data) == "YES" def test_unbalanced_non_bst(): input_data = [(5, 1, 4), (...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value=0, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058823", "row_id": 58823, "seed_ids": "[9355]" }
0.633711
Taco_58823
I
[ "create_tree", "is_bst", "check_if_bst" ]
3
[ [ "check_if_bst", "create_tree" ], [ "check_if_bst", "is_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
7f7ab7c6f9a41d3cf8d5e119fb84e5b3ff40c760
4e8d38c90d02ba92837cbeae2d5caedb5b026788
v1.0
instruct
Taco
Taco_58863_I
Given a binary tree, write a function isSymmetric() that checks if the tree is symmetric around its center. A binary tree is symmetric if the left and right subtrees are mirror images of each other. Input Format: The input consists of a single integer T denoting the number of test cases. Each test case consists of mu...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def isSymmetric(root): def isMirror(t1, t2): if not t1 and not t2: return True if not t1 or not t2: return False return (t...
from solution import check_symmetry_of_trees def test_symmetric_trees(): assert check_symmetry_of_trees(["1 2 2 3 4 4 3"]) == ["Yes"] def test_asymmetric_trees(): assert check_symmetry_of_trees(["1 2 2 N 3 N 3"]) == ["No"] def test_multiple_cases(): test_cases = ["1 2 2 3 4 4 3", "1 2 2 N 3 N 3", "1 2 2"...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef isSymme...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058863", "row_id": 58863, "seed_ids": "[3298]" }
0.699159
Taco_58863
I
[ "isSymmetric", "buildTree", "check_symmetry_of_trees" ]
3
[ [ "check_symmetry_of_trees", "buildTree" ], [ "check_symmetry_of_trees", "isSymmetric" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
0a093f2bd31a6fb3a0d5b15cf7e71d05a52eda47
589ad3ea5f19e6d4ca96977b4bd9cad801465916
v1.0
instruct
Taco
Taco_58870_I
In a small village, there is a fascinating tradition where the villagers light lanterns during the festival, and each lantern is connected to every other lantern by a rope which has a certain length associated with it. However, due to the festival's popularity, the villagers want to minimize the total length of the rop...
import sys import heapq def prim_mst(n, dist_matrix): min_cost = [sys.maxsize] * n min_cost[0] = 0 visited = [False] * n pq = [(0, 0)] # (cost, vertex) total_cost = 0 while pq: cost, u = heapq.heappop(pq) if visited[u]: continue visited[u] = True ...
from solution import compute_minimum_rope_length def test_case1(): input_data = '3\n0 2 3\n2 0 1\n3 1 0\n0\n' expected_output = '3' assert compute_minimum_rope_length(input_data) == expected_output def test_case2(): input_data = '4\n0 5 9 4\n5 0 1 3\n9 1 0 2\n4 3 2 0\n0\n' expected_output = '7' ...
[ { "docstring": null, "function_declaration": "def prim_mst(n, dist_matrix):", "function_name": "prim_mst", "parameter_list": "(n, dist_matrix)" }, { "docstring": null, "function_declaration": "def minimal_rope_length(test_cases):", "function_name": "minimal_rope_length", "paramet...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef compute_min_rope_length(matrix):\n n = len(matrix)\n min_heap = [(0, 0)] # (cost, vertex)\n visited = [False] * n\n total_cost = 0...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058870", "row_id": 58870, "seed_ids": "[22097]" }
0.717978
Taco_58870
I
[ "prim_mst", "minimal_rope_length", "parse_input", "format_output", "compute_minimum_rope_length" ]
5
[ [ "compute_minimum_rope_length", "format_output" ], [ "compute_minimum_rope_length", "minimal_rope_length" ], [ "compute_minimum_rope_length", "parse_input" ], [ "minimal_rope_length", "prim_mst" ] ]
4
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
30858c1d9e31d3b08b4e010ce8c0a35808570119
3b45f2574d90d3a4882e763aabf3aaafa36d8f93
v1.0
instruct
Taco
Taco_58917_I
-----Problem----- A string is called beautiful if it can be partitioned into one or more contiguous substrings such that each substring is a palindrome. Given a string s, determine the minimum number of palindromic substrings it can be partitioned into to make it beautiful. -----Input----- The input consists of a si...
def is_palindrome(s): """ Check if the string s is a palindrome. """ return s == s[::-1] def min_palindromic_partitions(s): """ Returns the minimum number of palindromic substrings the string 's' can be partitioned into. """ n = len(s) dp = [0] * (n+1) for i in range(n-1, -1, -1...
from solution import min_palindromic_partitions def test_single_character(): assert min_palindromic_partitions("a") == 0 def test_two_characters_palindrome(): assert min_palindromic_partitions("aa") == 0 def test_two_characters_non_palindrome(): assert min_palindromic_partitions("ab") == 1 def test_thre...
[ { "docstring": "Check if the string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns the minimum number of palindromic substrings the string 's' can be partitioned into.", "function_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_palindrome_partitions(s):\n \"\"\"\n Returns the minimum number of palindromic substrings s can be partitioned into.\n \"\"\"\n\n n = len(s)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00058917", "row_id": 58917, "seed_ids": "[22197]" }
0.790978
Taco_58917
I
[ "is_palindrome", "min_palindromic_partitions" ]
2
[ [ "min_palindromic_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d008fa53a7ab45ce309f6c89d1d4e5cc54d4f8e7
7f99d1443db63b00b331382bba342bd5dfa9b1a7
v1.0
instruct
Taco
Taco_58952_I
Takahashi has an array of N integers. He will perform the following operation exactly M times: * Choose any two elements a and b from the array (not necessarily distinct), and replace both values with their greatest common divisor (GCD). * Note that multiple pairs of (a, b) can be chosen at different times, but each s...
from math import gcd from functools import reduce def calculate_gcd_of_array(arr): """ This function calculates the GCD of all elements in the array. """ return reduce(gcd, arr) def lexicographically_smallest_array_after_gcd_operations(N, M, array): """ Given an array of N elements and M opera...
import pytest from solution import lexicographically_smallest_array_after_gcd_operations def test_example_1(): N = 5 M = 1 array = [12, 15, 9, 18, 24] expected_output = [3, 3, 3, 3, 3] assert lexicographically_smallest_array_after_gcd_operations(N, M, array) == expected_output def test_example_2()...
[ { "docstring": "This function calculates the GCD of all elements in the array.", "function_declaration": "def calculate_gcd_of_array(arr):", "function_name": "calculate_gcd_of_array", "parameter_list": "(arr)" }, { "docstring": "Given an array of N elements and M operations, this function re...
[ 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 math import gcd\nfrom functools import reduce\n\ndef smallest_array_after_operations(N, M, A):\n overall_gcd = reduce(gcd, A)\n \n if M >= N - 1:\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00058952", "row_id": 58952, "seed_ids": "[13459]" }
0.678526
Taco_58952
I
[ "calculate_gcd_of_array", "lexicographically_smallest_array_after_gcd_operations" ]
2
[ [ "lexicographically_smallest_array_after_gcd_operations", "calculate_gcd_of_array" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bf0f3b24704755867083b6ce2aaad20d64833629
b899d33b747ba8ef3272ff859b1cdff7de3413fd
v1.0
instruct
Taco
Taco_58985_I
On a strange rectangular grid (NxM), each cell contains either a positive integer or zero. You are given Q queries and your task is to find the sum of the elements in a specified submatrix for each query. A submatrix is defined by its top-left and bottom-right corners. **Input:** The first line contains three integers...
def get_prefix_sum_matrix(matrix, n, m): """ Helper function to compute prefix sum matrix for efficient submatrix sum queries """ 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...
from solution import submatrix_sum def test_single_submatrix(): n, m, q = 3, 3, 1 matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] queries = [(1, 1, 3, 3)] assert submatrix_sum(n, m, q, matrix, queries) == [45] def test_multiple_submatrices(): n, m, q = 3, 3, 3 matrix =...
[ { "docstring": "Helper function to compute prefix sum matrix for efficient submatrix sum queries ", "function_declaration": "def get_prefix_sum_matrix(matrix, n, m):", "function_name": "get_prefix_sum_matrix", "parameter_list": "(matrix, n, m)" }, { "docstring": "Main function to handle mult...
[ 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 get_prefix_sum_matrix(matrix, n, m):\n \"\"\" Helper function to compute prefix sum matrix for efficient submatrix sum queries \"\"\"\n prefix_sum = [[0]...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00058985", "row_id": 58985, "seed_ids": "[4821]" }
0.612232
Taco_58985
I
[ "get_prefix_sum_matrix", "submatrix_sum" ]
2
[ [ "submatrix_sum", "get_prefix_sum_matrix" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0db41c30dc6f8da60952329e28feb239acff4d35
fb348bbfe726cdf055bf51f7068df52eb02c221e
v1.0
instruct
Taco
Taco_58994_I
Nested Palindrome Alice is fascinated by palindromes. She defines a string \( S \) as a "nested palindrome" if every palindrome within \( S \) can be decomposed into smaller palindromes, including single-character palindromes. Given a string \( S \) of length \( N \), determine if it is a nested palindrome. A palind...
def is_palindrome(s): """ Check if a string s is a palindrome. """ return s == s[::-1] def is_nested_palindrome(s): """ Check if a string s is a nested palindrome. """ if not is_palindrome(s): return False n = len(s) # Base case for single character or empty string....
from solution import check_nested_palindromes def test_check_nested_palindromes(): assert check_nested_palindromes(3, ["abba", "abcba", "xyz"]) == ["YES", "YES", "NO"] assert check_nested_palindromes(2, ["aaa", "abc"]) == ["YES", "NO"] assert check_nested_palindromes(1, ["a"]) == ["YES"] assert check_n...
[ { "docstring": "Check if a string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Check if a string s is a nested palindrome.", "function_declaration": "def is_nested_palindrome(s):", "...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Check if a string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef is_nested_palindro...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00058994", "row_id": 58994, "seed_ids": "[11048]" }
0.76515
Taco_58994
I
[ "is_palindrome", "is_nested_palindrome", "check_nested_palindromes" ]
3
[ [ "check_nested_palindromes", "is_nested_palindrome" ], [ "is_nested_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4ae5c06b297e3ecd16d58bb05452f944e24f2b61
6a3e82ddb27c4df2511b8e044c9d4254327bbdf4
v1.0
instruct
Taco
Taco_59105_I
Given an integer `n`, return an array representing the first `n` terms of the look-and-say sequence. The look-and-say sequence is a sequence of integers starting with 1, where each term is generated by describing the digits of the previous term. The first few terms are: 1. 1 2. 11 (one `1`) 3. 21 (two `1`s) 4. 1211 (...
def get_next_sequence(term): """ Generate the next term in the look-and-say sequence from the given term. """ result = [] i = 0 while i < len(term): count = 1 while i + 1 < len(term) and term[i] == term[i + 1]: i += 1 count += 1 result.append(f"{co...
def test_lookAndSaySequence(): # Test for 1 term assert lookAndSaySequence(1) == ["1"] # Test for 2 terms assert lookAndSaySequence(2) == ["1", "11"] # Test for 3 terms assert lookAndSaySequence(3) == ["1", "11", "21"] # Test for 4 terms assert lookAndSaySequence(4) == ["1...
[ { "docstring": "Generate the next term in the look-and-say sequence from the given term.", "function_declaration": "def get_next_sequence(term):", "function_name": "get_next_sequence", "parameter_list": "(term)" }, { "docstring": "Returns the first n terms of the look-and-say sequence.", ...
[ 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 look_and_say_sequence(n):\n \"\"\"\n Returns the first n terms of the look-and-say sequence, starting with \"1\".\n \"\"\"\n if n < 1:\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059105", "row_id": 59105, "seed_ids": "[8108]" }
0.59695
Taco_59105
I
[ "get_next_sequence", "lookAndSaySequence" ]
2
[ [ "lookAndSaySequence", "get_next_sequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c93607ae762e726c733f583e23888a58069121b7
32d692bce36bdba1fce1f33850eb48cadc235c07
v1.0
instruct
Taco
Taco_59121_I
You are given a sequence of $n$ integers and a number $k$. You need to determine if there exists a subsequence of at least $k$ consecutive increasing numbers in the sequence. -----Input----- The first line contains two integers $n$ and $k$ ($1 \le n, k \le 1000$). The second line contains $n$ integers $a_1, a_2, ......
def has_k_consecutive_increasing(nums, k): if k == 1: return "YES" if len(nums) > 0 else "NO" n = len(nums) count = 1 for i in range(1, n): if nums[i] > nums[i - 1]: count += 1 if count >= k: return "YES" else: count = 1 re...
from solution import k_consecutive_increasing_subsequence_exists def test_example_1(): assert k_consecutive_increasing_subsequence_exists(10, 3, [1, 2, 2, 3, 4, 5, 1, 1, 1, 6]) == "YES" def test_example_2(): assert k_consecutive_increasing_subsequence_exists(5, 4, [5, 2, 4, 6, 1]) == "NO" def test_k_is_1(): ...
[ { "docstring": null, "function_declaration": "def has_k_consecutive_increasing(nums, k):", "function_name": "has_k_consecutive_increasing", "parameter_list": "(nums, k)" }, { "docstring": null, "function_declaration": "def k_consecutive_increasing_subsequence_exists(n, k, sequence):", ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def has_k_consecutive_increasing(n, k, sequence):\n \"\"\"\n Check if there exists a subsequence of at least k consecutive increasing numbers in the sequence...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00059121", "row_id": 59121, "seed_ids": "[17008]" }
0.690572
Taco_59121
I
[ "has_k_consecutive_increasing", "k_consecutive_increasing_subsequence_exists" ]
2
[ [ "k_consecutive_increasing_subsequence_exists", "has_k_consecutive_increasing" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f5567c66c529292a0070219056c5909d6a813f92
f3e579559cbfe6e58ee9e669cbd678b94a1bd324
v1.0
instruct
Taco
Taco_59143_I
Design a function `prime_ranges(n)` that generates a list of tuples representing ranges of consecutive prime numbers less than or equal to `n`. A range (tuple) is defined as the largest contiguous sequence of prime numbers where each prime number in the range is separated from the next prime number by exactly 2. In oth...
def is_prime(n): """Check if a number is a prime number.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True ...
from solution import prime_ranges def test_prime_ranges_basic(): assert prime_ranges(13) == [(3, 5, 7), (11, 13)] def test_prime_ranges_up_to_20(): assert prime_ranges(20) == [(3, 5, 7), (11, 13), (17, 19)] def test_prime_ranges_up_to_30(): assert prime_ranges(30) == [(3, 5, 7), (11, 13), (17, 19), (29,)...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of tuples representing ranges of consecutive primes less than or equal to n,\nwhere each prime number in t...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Check if a number is a prime number.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059143", "row_id": 59143, "seed_ids": "[19256]" }
0.677442
Taco_59143
I
[ "is_prime", "prime_ranges" ]
2
[ [ "prime_ranges", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d271ce89a8ebb2d084b5deb9e0682baf846e2355
6c765c47265464dca75c9d1c25d94903e5581450
v1.0
instruct
Taco
Taco_59188_I
Alice loves numbers and she recently discovered a very interesting property about some special numbers. She calls a number 'Twisted Prime' if reversing its digits also results in a prime number. Note that the reversed number must be different from the original number to be considered 'Twisted Prime'. For example, 13 i...
def is_prime(n): """Helper function to check if a number is a prime.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import twisted_primes def test_twisted_primes_range_10_to_100(): assert twisted_primes(10, 100) == [13, 17, 31, 37, 71, 73, 79, 97] def test_twisted_primes_range_200_to_300(): assert twisted_primes(200, 300) == [-1] def test_twisted_primes_range_prime_reversal(): # Range with primes that re...
[ { "docstring": "Helper function to check if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all 'Twisted Primes' in the range [L, R].", "function_declaration": "def twisted_primes...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is a prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059188", "row_id": 59188, "seed_ids": "[24889]" }
0.555932
Taco_59188
I
[ "is_prime", "twisted_primes" ]
2
[ [ "twisted_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1cf14d66869b15831bbc12439877cc9e7763ee60
7e1e15f983d4db7f6bddb2fd31a02362da2a85f2
v1.0
instruct
Taco
Taco_59261_I
You are given a list of integers. You need to determine for each integer whether it is a prime number or not. A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself. If a number is prime, print "Prime"; otherwise, print "Not Prime". -----Constraints----- - The...
def is_prime(n): """ Returns True if n is a prime number, otherwise returns False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False sq_root = int(n**0.5) + 1 for i in range(3, sq_root, 2): if n % i == 0: return Fal...
from solution import is_prime, check_primes def test_is_prime(): # Testing known prime numbers assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(11) == True assert is_prime(13) == True # Testing known non-prime numbers assert is_prime(1) =...
[ { "docstring": "Returns True if n is a prime number, otherwise returns False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "For each number in 'numbers' list, determine if it is prime,\nand return a list of strings \"Pri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise returns False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00059261", "row_id": 59261, "seed_ids": "[23197]" }
0.744524
Taco_59261
I
[ "is_prime", "check_primes" ]
2
[ [ "check_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f8c7ac9393a227572291cd7ac42271a706d1cf61
00813bd92d5fb03919818fc511f82b062f8f6bcb
v1.0
instruct
Taco
Taco_59268_I
Given a two-dimensional array filled with integers, your task is to find a submatrix with the maximum possible sum of its elements. The submatrix can be of any size greater than or equal to 1x1. The function should return the maximum sum found. Function Description Complete the `maxSumSubmatrix` function in the edi...
def maxSumSubmatrix(matrix): R = len(matrix) C = len(matrix[0]) if R > 0 else 0 if R == 0 or C == 0: return 0 max_sum = float('-inf') for left in range(C): temp = [0] * R for right in range(left, C): for i in range(R): temp[i] += matrix[i][r...
def test_maxSumSubmatrix(): matrix = [ [1, 2, -1, -4, -20], [-8, -3, 4, 2, 1], [3, 8, 10, 1, 3], [-4, -1, 1, 7, -6] ] assert maxSumSubmatrix(matrix) == 29 def test_empty_matrix(): assert maxSumSubmatrix([]) == 0 def test_single_element_matrix(): assert maxSumSubmatr...
[ { "docstring": null, "function_declaration": "def maxSumSubmatrix(matrix):", "function_name": "maxSumSubmatrix", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def kadane(arr):", "function_name": "kadane", "parameter_list": "(arr)" } ]
[ 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 maxSumSubmatrix(matrix):\n R = len(matrix)\n C = len(matrix[0]) if R > 0 else 0\n \n if R == 0 or C == 0:\n return 0\n\n max_sum = float(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00059268", "row_id": 59268, "seed_ids": "[20254]" }
0.679753
Taco_59268
I
[ "maxSumSubmatrix", "kadane" ]
2
[ [ "maxSumSubmatrix", "kadane" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4120e0cc9bb6408333d37d9e47f3476dc7cf812d
0f97a08338c2994cc7572fb278ec61cb915418f5
v1.0
instruct
Taco
Taco_59283_I
Design a function named `optimize_route` that takes in a list of points representing locations on a 2D plane and returns the optimal path for visiting all points exactly once and returning to the starting point, employing a naive approach algorithm. ### Input A list of tuples, where each tuple contains two integers re...
from typing import List, Tuple from itertools import permutations def euclidean_distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float: """ Returns the Euclidean distance between two points in 2D plane. """ return ((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) ** 0.5 def to...
from solution import optimize_route def test_optimize_route_four_points(): assert optimize_route([(0, 0), (1, 1), (1, 0), (0, 1)]) == [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)] or \ optimize_route([(0, 0), (1, 1), (1, 0), (0, 1)]) == [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)] def test_optimize_route_two_po...
[ { "docstring": "Returns the Euclidean distance between two points in 2D plane.", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Returns the total distance of the given route, in...
[ 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 itertools\nfrom typing import List, Tuple\n\ndef calculate_distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float:\n \"\"\"\n Calculates the Eucl...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00059283", "row_id": 59283, "seed_ids": "[22013]" }
0.669815
Taco_59283
I
[ "euclidean_distance", "total_route_distance", "optimize_route" ]
3
[ [ "optimize_route", "total_route_distance" ], [ "total_route_distance", "euclidean_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
738447f30536f6b6d0e6be976d14e6652fb410db
575262cba2507bc77049e1698592394d75f1b584