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_1106_I
You are given a grid consisting of $N$ rows and $M$ columns. Each cell in the grid contains either a '0' or a '1'. Your task is to find the size of the largest rectangle containing only '1's and return the number of such largest rectangles that can be found in the grid. ------ Input ------ The first line of the input...
def find_largest_rectangle(grid): """ This function takes a grid of '0's and '1's and returns the size of the largest rectangle containing only '1's and the number of such largest rectangles. """ n = len(grid) m = len(grid[0]) if n > 0 else 0 if not n or not m: return 0, 0 ...
def test_find_largest_rectangle(): grid1 = [ "10101", "11100", "11111", "10010" ] assert find_largest_rectangle(grid1) == (6, 1) grid2 = [ "101010", "010101", "101010", "010101", "101010", "010101" ] assert find_lar...
[ { "docstring": "This function takes a grid of '0's and '1's and returns the size of the largest rectangle containing only '1's\nand the number of such largest rectangles.", "function_declaration": "def find_largest_rectangle(grid):", "function_name": "find_largest_rectangle", "parameter_list": "(gri...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_rectangle(T, test_cases):\n def maximal_rectangle(matrix):\n if not matrix:\n return 0, 0\n \n n = len(matrix)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001106", "row_id": 1106, "seed_ids": "[7049]" }
0.709202
Taco_1106
I
[ "find_largest_rectangle", "process_test_cases", "parse_input", "solve" ]
4
[ [ "process_test_cases", "find_largest_rectangle" ], [ "solve", "parse_input" ], [ "solve", "process_test_cases" ] ]
3
[ "process_test_cases", "parse_input" ]
false
[]
false
pytest
false
[]
true
81bf9b36d91215f6b6900ac170705c80a5002cc0
4030d5b34844f2443ef07d4cb9c9251235deb466
v1.0
instruct
Taco
Taco_1228_I
There is a special number sequence defined as follows: - The sequence starts with the first number as 1. - For any number `n(i)` in the sequence, the next number `n(i+1)` is generated by summing the cubes of the digits of `n(i)`. For example, starting with 1: 1. 1 --> 1^3 = 1 (Next number is 1) 2. 1 --> 1^3 = 1 (Nex...
def sum_of_cubes_of_digits(n): """ Returns the sum of the cubes of the digits of the number n. """ return sum(int(digit)**3 for digit in str(n)) def kth_number_in_sequence(start, k): """ Returns the k-th number in the special sequence starting from 'start'. """ current = start for _...
from solution import sum_of_cubes_of_digits, kth_number_in_sequence, process_multiple_cases # Testing sum_of_cubes_of_digits def test_sum_of_cubes_of_digits(): assert sum_of_cubes_of_digits(1) == 1 assert sum_of_cubes_of_digits(12) == 9 assert sum_of_cubes_of_digits(123) == 1**3 + 2**3 + 3**3 == 36 ass...
[ { "docstring": "Returns the sum of the cubes of the digits of the number n.", "function_declaration": "def sum_of_cubes_of_digits(n):", "function_name": "sum_of_cubes_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the k-th number in the special sequence starting from 'start'....
[ 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 next_number(n):\n return sum(int(digit) ** 3 for digit in str(n))\n\ndef kth_number(n, k):\n current = n\n for _ in range(k - 1):\n current = n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001228", "row_id": 1228, "seed_ids": "[18794]" }
0.695342
Taco_1228
I
[ "sum_of_cubes_of_digits", "kth_number_in_sequence", "process_multiple_cases" ]
3
[ [ "kth_number_in_sequence", "sum_of_cubes_of_digits" ], [ "process_multiple_cases", "kth_number_in_sequence" ] ]
2
[ "process_multiple_cases" ]
false
[]
false
pytest
true
[]
true
bc7551d118205cb323ac05271b5e228e2d14d143
c5fc980a4d586c16bf4ab5f57f737dd99e16d517
v1.0
instruct
Taco
Taco_1283_I
Given a list of words, your task is to find the number of pairs of indices (i, j) where 0 ≤ i < j < len(words) such that the concatenation of words[i] and words[j] forms a palindrome. Example 1: Input: ["bat", "tab", "cat"] Output: 1 Explanation: The only palindromic pair is ("bat", "tab") -> "battab". Example 2: ...
def is_palindrome(s): return s == s[::-1] def count_palindromic_pairs(words): count = 0 for i in range(len(words)): for j in range(i + 1, len(words)): if is_palindrome(words[i] + words[j]): count += 1 return count
from solution import count_palindromic_pairs def test_example_1(): assert count_palindromic_pairs(["bat", "tab", "cat"]) == 1 def test_example_2(): assert count_palindromic_pairs(["abcd", "dcba", "lls", "s", "sssll"]) == 2 def test_no_pairs(): assert count_palindromic_pairs(["abc", "def", "ghi"]) == 0 d...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def count_palindromic_pairs(words):", "function_name": "count_palindromic_pairs", "parameter_list": "(w...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(word):\n \"\"\"\n Helper function to check if a given word is a palindrome.\n \"\"\"\n return word == word[::-1]\n\ndef count_palindr...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00001283", "row_id": 1283, "seed_ids": "[15597]" }
0.787533
Taco_1283
I
[ "is_palindrome", "count_palindromic_pairs" ]
2
[ [ "count_palindromic_pairs", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d41ae9d339fc53f80904fa98c929546c7eabbe77
0b39a1f682ad8862665f9bcfde011c38b80ca96c
v1.0
instruct
Taco
Taco_1290_I
Given a list of integers, return a new list with only the prime numbers from the original list. The returned list should be sorted in ascending order. Consider that a prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. In case of duplicates, only one instance of each p...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False elif n == 2: return True elif n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True de...
from solution import is_prime, filter_and_sort_primes 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 assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a new list with only the prime numbers \nfrom the original list, sorted in ascending order and wi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001290", "row_id": 1290, "seed_ids": "[7437]" }
0.642997
Taco_1290
I
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a10e7027576f04c713ef5243ece34f087bc3f14
61f4becc651e5b9cde12f24f5fb01025ecac6ef7
v1.0
instruct
Taco
Taco_1402_I
In a forest, there are multiple trees represented as an undirected graph where each node is a vertex and each edge connects two vertices. Each vertex has an integer value associated with it, and each edge has an integer weight. The forest is initially fragmented and can be connected into a single tree by adding some e...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot]...
from solution import maximum_tree_value def test_case_1(): n = 4 values = [1, 2, 3, 4] edges = [ (1, 2, 1), (2, 3, 2), (3, 4, 1) ] assert maximum_tree_value(n, values, edges) == 10 def test_case_2(): n = 5 values = [5, 3, 6, 1, 4] edges = [ (1, 2, 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, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001402", "row_id": 1402, "seed_ids": "[23363]" }
0.716647
Taco_1402
I
[ "find", "union", "maximum_tree_value" ]
3
[ [ "maximum_tree_value", "find" ], [ "maximum_tree_value", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e37f81ec012bc792d9a1f0d897fd3330c8a98dc6
9b5751f2766ea62d6ab94c50e01ef6ca80ddfc63
v1.0
instruct
Taco
Taco_1534_I
You are given a list of integers representing the heights of buildings along a street. You have to calculate the maximum area of a rectangle formed by any contiguous buildings. Each entry in the list represents the height of a building of unit width. Input The first line contains an integer n (1 ≤ n ≤ 10^5) — the num...
def largestRectangleArea(heights): """ Calculates the maximum area of a rectangle formed by any contiguous buildings. Uses a stack to keep track of building heights. """ stack = [] max_area = 0 index = 0 while index < len(heights): if not stack or heights[index] >= heights[s...
from solution import maximum_rectangle_area_in_histogram def test_single_building(): assert maximum_rectangle_area_in_histogram([4]) == 4 def test_increasing_height_buildings(): assert maximum_rectangle_area_in_histogram([1, 2, 3, 4, 5]) == 9 def test_decreasing_height_buildings(): assert maximum_rectang...
[ { "docstring": "Calculates the maximum area of a rectangle formed by any contiguous buildings.\nUses a stack to keep track of building heights.", "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "parameter_list": "(heights)" }, { "docstri...
[ 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 max_rectangle_area_in_histogram(heights):\n \"\"\"\n Calculate the maximum rectangle area in a histogram represented by a list of building heights.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001534", "row_id": 1534, "seed_ids": "[767]" }
0.726217
Taco_1534
I
[ "largestRectangleArea", "maximum_rectangle_area_in_histogram" ]
2
[ [ "maximum_rectangle_area_in_histogram", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eaa64b563ccf4d6e851850bc7608183255c63805
19de773065a1db5730dbefe11c2a7ed2546cabed
v1.0
instruct
Taco
Taco_1558_I
**Objective:** Implement a function to find the nearest palindrome number to a given number `n`. **Description:** A palindrome number is a number that reads the same backwards as forwards. The task is to find the smallest nearest palindrome number to a given integer `n`. If there are two palindrome numbers equally c...
def is_palindrome(num): """ Helper function to check if a number is a palindrome. """ return str(num) == str(num)[::-1] def nearest_palindrome(n: int) -> int: """ Finds the smallest nearest palindrome number to the given number n. """ if is_palindrome(n): return n lower, up...
from solution import nearest_palindrome def test_nearest_palindrome_simple(): assert nearest_palindrome(123) == 121 assert nearest_palindrome(100) == 99 assert nearest_palindrome(787) == 787 assert nearest_palindrome(12345) == 12321 def test_nearest_palindrome_tie_cases(): assert nearest_palindrom...
[ { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Finds the smallest nearest palindrome number to the given number n.", "function_declar...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n: int) -> bool:\n return str(n) == str(n)[::-1]\n\ndef nearest_palindrome(n: int) -> int:\n if is_palindrome(n):\n return n\n \n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001558", "row_id": 1558, "seed_ids": "[17013]" }
0.797643
Taco_1558
I
[ "is_palindrome", "nearest_palindrome" ]
2
[ [ "nearest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
887eac734c414d5e273c499089040feff4b52c33
9e83ab8443a858ffe1d4b6a2af088a75253c887f
v1.0
instruct
Taco
Taco_1599_I
A group of students is playing a card game during their break. The deck of cards consists of N cards numbered from 1 to N. The cards are initially placed in random order. The goal is to sort the cards in ascending order. However, the students can only perform a specific type of operation: they select any two cards adja...
def count_inversions(arr): # Merge sort based function to count inversions if len(arr) < 2: return arr, 0 mid = len(arr) // 2 left, left_inv = count_inversions(arr[:mid]) right, right_inv = count_inversions(arr[mid:]) merged, split_inv = merge_and_count(left, right) return merged, le...
def test_count_inversions(): assert count_inversions([4, 3, 2, 1])[1] == 6 assert count_inversions([1, 2, 3, 4, 5])[1] == 0 assert count_inversions([3, 1, 2])[1] == 2 def test_minimum_swaps_to_sort(): assert minimum_swaps_to_sort([4, 3, 2, 1]) == 6 assert minimum_swaps_to_sort([1, 2, 3, 4, 5]) == 0...
[ { "docstring": null, "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge_and_count(left, right):", "function_name": "merge_and_count", "parameter_list": "(l...
[ 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 minimum_adjacent_swaps(arr):\n \"\"\"\n Returns the minimum number of adjacent swaps required to sort the array.\n \"\"\"\n arr = [(val, idx) for i...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00001599", "row_id": 1599, "seed_ids": "[21594]" }
0.762458
Taco_1599
I
[ "count_inversions", "merge_and_count", "minimum_swaps_to_sort", "process_test_cases", "read_input", "main" ]
6
[ [ "count_inversions", "merge_and_count" ], [ "minimum_swaps_to_sort", "count_inversions" ], [ "process_test_cases", "minimum_swaps_to_sort" ] ]
3
[ "process_test_cases", "read_input" ]
false
[]
false
pytest
false
[]
true
089c7f9e8fa3a5a1a17562cdeef3363da25140ca
0b8b991d9fa4328c035e6ecfef9d3bed9fc592d1
v1.0
instruct
Taco
Taco_1648_I
Given a number N. Check if it is a Pythagorean prime. A Pythagorean prime is a prime number that can be expressed in the form 4k + 1. For a given number N, return 1 if it is a Pythagorean prime, otherwise return 0. Example 1: Input: N = 5 Output: 1 Explanation: 5 is a prime number and can be expressed in the form 4k ...
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 isPythagoreanPrime(N): ...
def test_isPythagoreanPrime(): assert isPythagoreanPrime(5) == 1 # Pythagorean prime assert isPythagoreanPrime(7) == 0 # Prime, but not Pythagorean prime assert isPythagoreanPrime(10) == 0 # Not a prime assert isPythagoreanPrime(13) == 1 # Pythagorean prime assert isPythagoreanPrime(1) == 0 # N...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def isPythagoreanPrime(N):", "function_name": "isPythagoreanPrime", "parameter_list": "(N)" } ]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001648", "row_id": 1648, "seed_ids": "[9469]" }
0.630642
Taco_1648
I
[ "is_prime", "isPythagoreanPrime" ]
2
[ [ "isPythagoreanPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1bd5df7857fe00b728c3018db63588e38e28afb1
a4ec18ab19a2ec4ca962767dfb26cffd0138ce25
v1.0
instruct
Taco
Taco_1650_I
You are tasked with developing an online music store's service for recommending songs to users. The recommendation algorithm is based on a simple version of collaborative filtering. To start, you need to write a function that finds the users with the closest music tastes to a given user based on their song ratings. Ea...
import math def euclidean_distance(ratings1, ratings2): """ Computes the Euclidean distance between two rating vectors. """ distance = 0 for r1, r2 in zip(ratings1, ratings2): distance += (r1 - r2) ** 2 return math.sqrt(distance) def find_closest_users(users_ratings, target_user_id): ...
def test_recommend_all_three(): input_data = """5 1 1 2 3 -1 2 1 3 2 -1 3 5 4 3 -1 4 1 2 3 -1 5 5 5 5 -1 1""" assert recommend_songs(input_data) == "2 3 4" def test_recommend_two_users(): input_data = """3 10 5 5 5 -1 20 1 1 1 -1 30 3 3 3 -1 30""" assert recommend_songs(input_data) == "10 20" def test...
[ { "docstring": "Computes the Euclidean distance between two rating vectors.", "function_declaration": "def euclidean_distance(ratings1, ratings2):", "function_name": "euclidean_distance", "parameter_list": "(ratings1, ratings2)" }, { "docstring": "Finds the user IDs of the three most similar...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef find_closest_users(data, target_user_id):\n # Parse the input data\n n = int(data[0])\n users = {}\n target_user_ratings = []\n\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00001650", "row_id": 1650, "seed_ids": "[23564]" }
0.53954
Taco_1650
I
[ "euclidean_distance", "find_closest_users", "recommend_songs" ]
3
[ [ "find_closest_users", "euclidean_distance" ], [ "recommend_songs", "find_closest_users" ] ]
2
[]
false
[]
false
pytest
false
[]
true
4fa42324060ac490a5c943df9b5f139d690e1f2e
b5f66ad0dad5b59015e1f9948a3bcd40323f1cf5
v1.0
instruct
Taco
Taco_1744_I
You are tasked with designing a park consisting of N trails. Each trail is represented by a line segment in a 2D plane from coordinate (x1, y1) to (x2, y2). Your goal is to ensure the park is walkable, meaning it's possible to walk from any point on one trail to any point on another trail without leaving the network of...
def is_walkable(trails): from collections import defaultdict, deque def find_common_point(trail1, trail2): return (set(trail1[:2]) & set(trail2[:2])) or (set(trail1[2:]) & set(trail2[2:])) or \ (set(trail1[:2]) & set(trail2[2:])) or (set(trail1[2:]) & set(trail2[:2])) graph = de...
from solution import walkable_park, parse_input def test_case_1(): input_str = "2\n3\n0 0 1 1\n1 1 2 2\n2 2 3 3\n2\n0 0 1 1\n2 2 3 3\n" test_cases = parse_input(input_str) result = walkable_park(test_cases) assert result == ["Case #1: YES", "Case #2: NO"] def test_case_2(): input_str = "1\n4\n0 0 ...
[ { "docstring": null, "function_declaration": "def is_walkable(trails):", "function_name": "is_walkable", "parameter_list": "(trails)" }, { "docstring": null, "function_declaration": "def walkable_park(test_cases):", "function_name": "walkable_park", "parameter_list": "(test_cases...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n \"\"\"\n A function to find the parent of element i\n \"\"\"\n if parent[i] == i:\n return i\n else:\n parent[i...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00001744", "row_id": 1744, "seed_ids": "[20579]" }
0.663048
Taco_1744
I
[ "is_walkable", "walkable_park", "parse_input" ]
3
[ [ "walkable_park", "is_walkable" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
7c88ff05e858a02264af446629e8cdbe9265a4b6
bd3ed6dbb8a642431241d7f06dd44fe06b4cb6e1
v1.0
instruct
Taco
Taco_1750_I
In a coding assessment, your task is to determine the minimum number of operations to remove all the "bad" pairs from a sequence. A pair (i, j) is considered "bad" if i < j and A[i] > A[j]. You are allowed the following operation any number of times (possibly 0): - Select any subarray A[l...r] (1 ≤ l ≤ r ≤ N) and reve...
def min_operations_to_sort(T, test_cases): """ Determines the minimum number of operations to sort each test case by reversing subarrays. Parameters: T (int): Number of test cases. test_cases (list of tuples): Each tuple contains (N, A), where N is the length of A and A is the list of i...
def test_min_operations_to_sort(): test_cases = [ (4, [1, 3, 6, 7]), (3, [10, 1, 4]), (6, [3, 1, 3, 3, 4, 3]), (4, [4, 3, 2, 1]), # requires 1 operation (entire reversal) (5, [5, 4, 3, 2, 1]) # requires 1 operation (entire reversal) ] expected = [0, 1, 1, 1, 1] ...
[ { "docstring": "Determines the minimum number of operations to sort each test case by reversing subarrays.\n\nParameters:\n T (int): Number of test cases.\n test_cases (list of tuples): Each tuple contains (N, A), where N is the length of A and A is the list of integers.\n\nReturns:\n list of int: Mini...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_operations_to_sort(arr):\n \"\"\"\n Returns the minimum number of operations to sort the array `arr` in non-descending order by reversing subarrays.\...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00001750", "row_id": 1750, "seed_ids": "[14201]" }
0.711781
Taco_1750
I
[ "min_operations_to_sort", "handle_user_input" ]
2
[ [ "handle_user_input", "min_operations_to_sort" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1137106636f7608eeb8e30de8db7d37168660612
ecd200a4af988fa6f705937a4fba074d4fefe1f7
v1.0
instruct
Taco
Taco_1825_I
A travel agency is offering a special tour package that includes visits to several cities. The agency has hired you to help them plan the itineraries. Each city is represented as a node in a graph, and the roads between the cities are the edges. Each road has a travel cost associated with it. Your task is to determin...
import heapq def minimum_travel_cost(n, m, s, t, roads): graph = {i: [] for i in range(1, n + 1)} for u, v, w in roads: graph[u].append((v, w)) graph[v].append((u, w)) pq = [(0, s)] distances = {i: float('inf') for i in range(1, n + 1)} distances[s] = 0 visited = set() ...
from solution import travel_agency_min_cost def test_minimum_travel_cost_example1(): n = 5 m = 6 s, t = 1, 5 roads = [ (1, 2, 2), (1, 3, 5), (2, 3, 1), (2, 4, 2), (3, 4, 3), (4, 5, 1) ] assert travel_agency_min_cost(n, m, s, t, roads) == 5 def te...
[ { "docstring": null, "function_declaration": "def minimum_travel_cost(n, m, s, t, roads):", "function_name": "minimum_travel_cost", "parameter_list": "(n, m, s, t, roads)" }, { "docstring": null, "function_declaration": "def travel_agency_min_cost(n, m, s, t, roads):", "function_name...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef minimum_travel_cost(n, m, s, t, roads):\n graph = {i: [] for i in range(1, n + 1)}\n for u, v, w in roads:\n graph[u].append((v, w...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001825", "row_id": 1825, "seed_ids": "[15141]" }
0.783715
Taco_1825
I
[ "minimum_travel_cost", "travel_agency_min_cost" ]
2
[ [ "travel_agency_min_cost", "minimum_travel_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e939c7c66cbb9661197a5d2ea4aa923a241c0a04
fb0a11b89851bc40cd6d95b3e5c1816e3fffc5c1
v1.0
instruct
Taco
Taco_1874_I
Aly is an enthusiastic programmer who loves solving algorithms-based puzzles. Recently, he came across a number puzzle related to prime numbers. The puzzle is as follows: Given an integer N, determine if N can be expressed as the sum of two prime numbers (not necessarily distinct) or not. In case there are multiple pa...
def sieve_of_eratosthenes(limit): """ Generates a list of prime numbers up to a given limit using the Sieve of Eratosthenes algorithm. """ is_prime = [True] * (limit + 1) is_prime[0] = is_prime[1] = False for start in range(2, int(limit ** 0.5) + 1): if is_prime[start]: for m...
from solution import solve_prime_sum_problem def test_example_cases(): T = 3 cases = [4, 5, 8] assert solve_prime_sum_problem(T, cases) == ["YES", "YES", "YES"] def test_single_prime_pair(): T = 1 cases = [4] assert solve_prime_sum_problem(T, cases) == ["YES"] def test_non_expressible_number(...
[ { "docstring": "Generates a list of prime numbers up to a given limit using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": "Determines if a number can ...
[ 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(num):\n \"\"\" Check if the given number is a prime number. \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00001874", "row_id": 1874, "seed_ids": "[16656]" }
0.741837
Taco_1874
I
[ "sieve_of_eratosthenes", "can_be_expressed_as_sum_of_primes", "solve_prime_sum_problem" ]
3
[ [ "solve_prime_sum_problem", "can_be_expressed_as_sum_of_primes" ], [ "solve_prime_sum_problem", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f57892f7c68d7faf5950b8007ccf1e7a898a3b28
b071411227d7fdf08811b6ebe1a8f92218eeb35a
v1.0
instruct
Taco
Taco_1879_I
Sam is learning about different data structures and how to manipulate them. He recently came across the concept of Fenwick Trees (Binary Indexed Trees) and Segment Trees, which can be used to efficiently answer range queries and update values in arrays. Sam wants to apply this knowledge to a problem but needs your help...
MOD = 1000000007 def update_fenwick_tree(fenwick_tree, index, value, mod): while index < len(fenwick_tree): fenwick_tree[index] = (fenwick_tree[index] * value) % mod index += index & -index def query_fenwick_tree(fenwick_tree, index, mod): result = 1 while index > 0: result = (resu...
def test_process_queries(): n = 5 values = [1, 2, 3, 4, 5] queries = [ [2, 1, 3], # Product from index 1 to 3: 2*3*4 = 24 [1, 2, 10], # Update index 2 to 10: [1, 2, 10, 4, 5] [2, 1, 3] # Product from index 1 to 3: 2*10*4 = 80 ] expected_output = [24, 80] assert p...
[ { "docstring": null, "function_declaration": "def update_fenwick_tree(fenwick_tree, index, value, mod):", "function_name": "update_fenwick_tree", "parameter_list": "(fenwick_tree, index, value, mod)" }, { "docstring": null, "function_declaration": "def query_fenwick_tree(fenwick_tree, 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": "MOD = 1000000007\n\nclass FenwickTree:\n def __init__(self, n):\n self.n = n\n self.tree = [1] * (n + 1)\n\n def _update(self, index, value):\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001879", "row_id": 1879, "seed_ids": "[22080]" }
0.495916
Taco_1879
I
[ "update_fenwick_tree", "query_fenwick_tree", "range_product", "process_queries" ]
4
[ [ "process_queries", "range_product" ], [ "process_queries", "update_fenwick_tree" ], [ "range_product", "query_fenwick_tree" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
c8ef00d6aa9e109a91450b2f1418406114625464
dff800ca34abcae892e439d130c4c7a6cac7b32e
v1.0
instruct
Taco
Taco_1888_I
In a city, there are N houses, and there is exactly one unidirectional road from each house to another house. The houses are numbered from 0 to N-1. Alice can travel from house `i` to house `j` if there is a direct road from `i` to `j`. Unfortunately, some of the roads are riddled with potholes, making travel through...
import heapq def dijkstra(N, t): """Function to calculate the minimum travel time using Dijkstra's algorithm.""" # Initialize a priority queue pq = [(0, 0)] # (current_weight, node) distances = {i: float('inf') for i in range(N)} distances[0] = 0 visited = set() while pq: ...
def test_sample_case(): t = [ [0, 3, -1, 7], [8, 0, 2, -1], [5, -1, 0, 1], [2, -1, -1, 0] ] assert min_travel_time(4, t) == 6 def test_case_no_route(): t = [ [0, 3, -1, -1], [8, 0, 2, -1], [5, -1, 0, -1], [-1, -1, -1, 0] ] assert m...
[ { "docstring": "Function to calculate the minimum travel time using Dijkstra's algorithm.", "function_declaration": "def dijkstra(N, t):", "function_name": "dijkstra", "parameter_list": "(N, t)" }, { "docstring": "Determines the shortest possible travel time from house 0 to house N-1.\n\n:pa...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef min_travel_time(N, t):\n \"\"\"\n Determine the shortest possible time to travel from house 0 to house N-1.\n Uses Dijkstra's algorith...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001888", "row_id": 1888, "seed_ids": "[12690]" }
0.793579
Taco_1888
I
[ "dijkstra", "min_travel_time" ]
2
[ [ "min_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
221f24bd3c88b074a28cc368b36e9fc058d62439
56510537de072659a7c2f75146053da5d88161e1
v1.0
instruct
Taco
Taco_1934_I
A large company is setting up a new email system for its employees. Each employee is assigned a unique ID, starting from 1 up to n. Sometimes, employees have to forward emails to one another. Your task is to determine if an email can be forwarded from one employee to another, directly or indirectly. An email is consid...
from collections import deque def min_forwards(n, m, relationships, q, queries): # Initialize adjacency list for the graph graph = {i: [] for i in range(1, n+1)} for a, b in relationships: graph[a].append(b) def bfs(start, end): if start == end: return 0 queue = deq...
import pytest from solution import min_forwards_from_string def test_min_forwards_sample_input(): input_str = "4\n3\n1 2\n2 3\n3 4\n3\n1 3\n1 4\n4 1\n" expected_output = [2, 3, -1] assert min_forwards_from_string(input_str) == expected_output def test_min_forwards_no_path(): input_str = "4\n2\n1 2\n3 ...
[ { "docstring": null, "function_declaration": "def min_forwards(n, m, relationships, q, queries):", "function_name": "min_forwards", "parameter_list": "(n, m, relationships, q, queries)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name":...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_forwards(n, m, relationships, q, queries):\n # Initialize adjacency list for the graph\n gr...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001934", "row_id": 1934, "seed_ids": "[3541]" }
0.593259
Taco_1934
I
[ "min_forwards", "parse_input", "min_forwards_from_string" ]
3
[ [ "min_forwards_from_string", "min_forwards" ], [ "min_forwards_from_string", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
d2b0c36e0400b5dd95fb9dc5750823045fce438f
e1e7855a0230024cb3845204aff1ae9661fc88db
v1.0
instruct
Taco
Taco_1954_I
A large warehouse is organized in a systematic way where shelves are aligned in a grid formation. Each shelf can be identified with coordinates (i, j) where 'i' is the row number and 'j' is the column number starting from (1, 1) at the top-left corner. Each shelf has a certain number of identical items stored on it. Wa...
def preprocess_grid(n, m, grid): # Create a prefix sum array 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] + prefix_sum[i-1][j] + prefix_sum[i][j-1] - prefix_sum[i-1][j-1] return pref...
def test_preprocess_grid(): n, m = 3, 3 grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] prefix_sum = preprocess_grid(n, m, grid) expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] assert prefix_sum == expec...
[ { "docstring": null, "function_declaration": "def preprocess_grid(n, m, grid):", "function_name": "preprocess_grid", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def query_sum(prefix_sum, r1, c1, r2, c2):", "function_name": "query_sum", "param...
[ 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 preprocess_grid(grid):\n n = len(grid)\n m = len(grid[0])\n prefix_sum = [[0 for _ in range(m + 1)] for _ in range(n + 1)]\n \n for i in range(1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001954", "row_id": 1954, "seed_ids": "[21521]" }
0.649188
Taco_1954
I
[ "preprocess_grid", "query_sum", "total_items_in_subgrid" ]
3
[ [ "total_items_in_subgrid", "preprocess_grid" ], [ "total_items_in_subgrid", "query_sum" ] ]
2
[]
false
[]
false
pytest
false
[]
true
22ea7aa62c70370b3031595a41633783109cdb58
f2a1209ad433513c3585844954f374c21146fccc
v1.0
instruct
Taco
Taco_1984_I
**Treasure Hunt in the Grid** You are given an n x m grid consisting of empty cells (denoted by '.'), obstacles (denoted by '#'), and treasure chests (denoted by 'T'). Your task is to help a treasure hunter find the maximum number of treasure chests he can collect starting from a given starting position in the grid. T...
def max_treasures(grid, start_x, start_y): n = len(grid) m = len(grid[0]) # Valid moves: up, down, left, right moves = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Convert 1-indexed to 0-indexed start_x -= 1 start_y -= 1 def is_valid(x, y): return 0 <= x < n and 0 <= y < m...
def test_example1(): grid = [ ".....", ".T.#.", ".....", "##...", "###T." ] assert treasure_hunt(5, 5, grid, 3, 1) == 2 def test_example2(): grid = [ ".T.", ".#.", ".T." ] assert treasure_hunt(3, 3, grid, 1, 1) == 2 def test_examp...
[ { "docstring": null, "function_declaration": "def max_treasures(grid, start_x, start_y):", "function_name": "max_treasures", "parameter_list": "(grid, start_x, start_y)" }, { "docstring": null, "function_declaration": "def treasure_hunt(n, m, grid, x, y):", "function_name": "treasure...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_treasure(grid, start_pos):\n n, m = len(grid), len(grid[0])\n x, y = start_pos\n x, y = x - 1, y - 1 # Convert to 0-indexed\n\n # Directions f...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001984", "row_id": 1984, "seed_ids": "[1030]" }
0.654724
Taco_1984
I
[ "max_treasures", "treasure_hunt" ]
2
[ [ "treasure_hunt", "max_treasures" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7da4fd1cca33f32d132dbe09068de2da25a87ba3
2a311ec41f56c61931d744f9d4f445951a8ef498
v1.0
instruct
Taco
Taco_2053_I
The inhabitants of the fictional country AlgoLand love prime numbers. To celebrate their love for primes, they decided to organize a **Prime Number Game**. In this game, each player is given a positive integer n, and their task is to find the smallest prime number k, where k is greater than or equal to n. Write a prog...
def is_prime(num): """ Check if a number is prime. """ if num < 2: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def smallest_prime_greate...
import pytest from solution import is_prime, smallest_prime_greater_than_or_equal_to, process_test_cases def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(29) assert not is_prime(99) def test_smallest...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number greater than or equal to the given number n.", "function_declaration": "def smallest_pri...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num < 2:\n return False\n if num == 2:\n return True\n if n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002053", "row_id": 2053, "seed_ids": "[25049]" }
0.610245
Taco_2053
I
[ "is_prime", "smallest_prime_greater_than_or_equal_to", "process_test_cases" ]
3
[ [ "process_test_cases", "smallest_prime_greater_than_or_equal_to" ], [ "smallest_prime_greater_than_or_equal_to", "is_prime" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
b5255f6a5886cd5af77bf701420f64ab73f8a337
1b64bf252a28e20c90bacd1a410d89f67e7c74d5
v1.0
instruct
Taco
Taco_2100_I
Given a list of integers, you need to partition the list into contiguous subarrays such that the sum of each subarray is an integer power of 2. You need to determine if it's possible to do so. For example, the integer powers of 2 are 1 (2^0), 2 (2^1), 4 (2^2), 8 (2^3), etc. Input The first line of the input contain...
def is_power_of_two(x): """ Checks if x is a power of 2. """ return (x & (x - 1)) == 0 and x != 0 def can_partition_to_powers_of_two(n, arr): """ Determines if it is possible to partition the array into contiguous subarrays such that the sum of each subarray is a power of 2. """ i =...
from solution import can_partition_to_powers_of_two def test_example1(): assert can_partition_to_powers_of_two(6, [2, 3, 1, 1, 4, 8]) == "Yes" def test_example2(): assert can_partition_to_powers_of_two(4, [2, 4, 1, 3]) == "No" def test_example3(): assert can_partition_to_powers_of_two(1, [16]) == "Yes" ...
[ { "docstring": "Checks if x is a power of 2.", "function_declaration": "def is_power_of_two(x):", "function_name": "is_power_of_two", "parameter_list": "(x)" }, { "docstring": "Determines if it is possible to partition the array into contiguous subarrays\nsuch that the sum of each subarray i...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_power_of_two(n):\n \"\"\"\n Returns True if n is an integer power of 2, otherwise False.\n \"\"\"\n return (n & (n - 1)) == 0 and n != 0\n\ndef ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002100", "row_id": 2100, "seed_ids": "[20674]" }
0.708979
Taco_2100
I
[ "is_power_of_two", "can_partition_to_powers_of_two" ]
2
[ [ "can_partition_to_powers_of_two", "is_power_of_two" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc026d478a1764d493e8bfc00e147a23f52c03fb
d094d958f06f916cc2fce642d3d2d39e0b03d2a7
v1.0
instruct
Taco
Taco_2115_I
A subsequence of characters in a string is a string derived by deleting some or no characters without changing the order of the remaining characters. For example, "abc", "def", and "abcdef" are subsequences of "abcdef", but "bdca" and "aefc" are not. Given a string `s` and a list of strings `l`, write a program to det...
def is_subsequence(s, sub): """ Returns True if 'sub' is a subsequence of 's', otherwise False. """ iter_s = iter(s) return all(char in iter_s for char in sub) def count_subsequences(s, l): """ Returns the number of strings in `l` that are subsequences of string `s`. """ return sum(...
from solution import is_subsequence, count_subsequences def test_is_subsequence(): assert is_subsequence('abcde', 'a') == True assert is_subsequence('abcde', 'bb') == False assert is_subsequence('abcde', 'acd') == True assert is_subsequence('abcde', 'ace') == True assert is_subsequence('abcde', 'bd...
[ { "docstring": "Returns True if 'sub' is a subsequence of 's', otherwise False.", "function_declaration": "def is_subsequence(s, sub):", "function_name": "is_subsequence", "parameter_list": "(s, sub)" }, { "docstring": "Returns the number of strings in `l` that are subsequences of string `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 is_subsequence(s, sub):\n \"\"\"\n Returns True if 'sub' is a subsequence of 's', otherwise False.\n \"\"\"\n iter_s = iter(s)\n return all(char...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002115", "row_id": 2115, "seed_ids": "[17572]" }
0.759259
Taco_2115
I
[ "is_subsequence", "count_subsequences", "main" ]
3
[ [ "count_subsequences", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bbab37148c98878e1b1af755ff96213d2c7d3f9b
15e4a649b17e5fbafa12744dee4d7a553fc59045
v1.0
instruct
Taco
Taco_2170_I
**Problem** A group of adventurers are exploring a mystical forest and have encountered a series of enchanted gates, each guarded by a magical creature. Each gate will only open if the adventurers present a specific combination of magical keys. Each key has a certain level of magic power, and the goal is to open as ma...
def can_open_gate(gate, key_counts, key_powers, total_power): used = [0] * len(key_counts) power = 0 for key in gate: if key_counts[key - 1] <= 0: return False if power + key_powers[key - 1] > total_power: return False power += key_powers[key - 1] used...
from solution import solve def test_example_case(): adventure_data = [ (3, 100), (5, 20), (4, 15), (3, 10), (2,), (2, 1, 2), (1, 3), (4, 90), (3, 10), (2, 20), (1, 30), (1, 15), (1,), (3, 2, 3, 4), ] assert solve(adventure_data) == [2, 1] def...
[ { "docstring": null, "function_declaration": "def can_open_gate(gate, key_counts, key_powers, total_power):", "function_name": "can_open_gate", "parameter_list": "(gate, key_counts, key_powers, total_power)" }, { "docstring": null, "function_declaration": "def max_gates_opened(keys, max_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom itertools import combinations\n\ndef max_gates(n, m, keys, gates):\n def gate_power(gate):\n return sum(keys[key-1][1] for key in gate)\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002170", "row_id": 2170, "seed_ids": "[10681]" }
0.63263
Taco_2170
I
[ "can_open_gate", "max_gates_opened", "solve" ]
3
[ [ "max_gates_opened", "can_open_gate" ], [ "solve", "max_gates_opened" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a4284ae55c35b2a5587288b3f2e4a09be0e5e233
84f85cf303b0e5fc01b398204d46a5e6b34d4d63
v1.0
instruct
Taco
Taco_2172_I
Teja is developing an interest in matrix manipulations. Utkarsh decides to challenge him with matrix rotations. Given a square matrix, he needs to rotate it 90 degrees clockwise a specific number of times. Given an integer K, Teja needs to rotate the matrix K times in clockwise direction. If K is larger than or equal ...
def rotate_matrix_90_clockwise(matrix): """ Rotates a square matrix 90 degrees clockwise. """ n = len(matrix) rotated = [[0] * n for _ in range(n)] for i in range(n): for j in range(n): rotated[j][n - i - 1] = matrix[i][j] return rotated def rotate_matrix_k_tim...
def test_rotate_1(): input_data = "1\n3\n1 2 3\n4 5 6\n7 8 9\n1" expected_output = "7 4 1\n8 5 2\n9 6 3" assert solve(input_data) == expected_output def test_rotate_2(): input_data = "1\n3\n1 2 3\n4 5 6\n7 8 9\n2" expected_output = "9 8 7\n6 5 4\n3 2 1" assert solve(input_data) == expected_outp...
[ { "docstring": "Rotates a square matrix 90 degrees clockwise.", "function_declaration": "def rotate_matrix_90_clockwise(matrix):", "function_name": "rotate_matrix_90_clockwise", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def rotate_matrix_k_times(matrix...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_matrix_90_clockwise(matrix):\n \"\"\"\n Rotates a square matrix 90 degrees clockwise.\n \"\"\"\n n = len(matrix)\n rotated = [[0] * n for...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002172", "row_id": 2172, "seed_ids": "[24670]" }
0.603644
Taco_2172
I
[ "rotate_matrix_90_clockwise", "rotate_matrix_k_times", "process_input", "format_output", "solve" ]
5
[ [ "process_input", "rotate_matrix_k_times" ], [ "rotate_matrix_k_times", "rotate_matrix_90_clockwise" ], [ "solve", "format_output" ], [ "solve", "process_input" ] ]
4
[ "process_input", "format_output" ]
false
[]
false
pytest
false
[]
true
8d5020096c523e7c58e8f4c20c3c9e6c31b13746
8e7fbccdc4349ad6950bc0cbb057ab12056d3540
v1.0
instruct
Taco
Taco_2176_I
A construction company has developed a new traffic management system for a city that aims to minimize the total time taken for people to travel between various points in the city. The system needs a module to calculate the shortest possible path between any two points in the city, taking into account that some streets ...
import heapq import sys def dijkstra(N, edges, S, T): # Create adjacency list graph = {i: [] for i in range(1, N+1)} for U, V, W in edges: graph[U].append((V, W)) # Distance array to track shortest paths dist = {i: sys.maxsize for i in range(1, N+1)} dist[S] = 0 # Priority queue t...
def test_dijkstra(): inputs = """2 4 4 1 2 4 1 3 2 2 3 5 3 4 1 1 4 5 7 1 2 3 1 3 2 1 4 7 2 3 1 2 5 6 3 4 2 4 5 1 1 5""" expected_output = [3, 5] assert compute_shortest_paths(inputs) == expected_output def test_no_path(): inputs = """1 3 2 1 2 1 2 3 1 3 1""" expected_output = ["NO PATH"] assert...
[ { "docstring": null, "function_declaration": "def dijkstra(N, edges, S, T):", "function_name": "dijkstra", "parameter_list": "(N, edges, S, T)" }, { "docstring": null, "function_declaration": "def get_shortest_paths(test_cases):", "function_name": "get_shortest_paths", "parameter...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef shortest_path(T, test_cases):\n results = []\n \n def dijkstra(n, graph, start, target):\n pq = [(0, start)]\n distances...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002176", "row_id": 2176, "seed_ids": "[4878]" }
0.766969
Taco_2176
I
[ "dijkstra", "get_shortest_paths", "compute_shortest_paths" ]
3
[ [ "compute_shortest_paths", "get_shortest_paths" ], [ "get_shortest_paths", "dijkstra" ] ]
2
[]
false
[]
false
pytest
false
[]
true
16cbbd69152b5c73d87f4bea6dfff7ab483ade8b
37197f21fc77ace29c0bc0797249a8dcc6606dc7
v1.0
instruct
Taco
Taco_2178_I
Bob is playing a game where he needs to move a token on a 2D grid from the top-left corner (1, 1) to the bottom-right corner (N, M). He can only move the token one cell either to the right or downward. However, some cells in the grid are blocked and he cannot move the token into those cells. Bob wants to know how many ...
def unique_paths_with_obstacles(n, m, blocked_cells): # Create a 2D dp table initialized to 0 dp = [[0] * (m + 1) for _ in range(n + 1)] # Start position dp[1][1] = 1 if (1, 1) not in blocked_cells else 0 # Fill the dp table for i in range(1, n + 1): for j in range(1, m + 1): ...
from solution import solve, parse_input def test_example(): input_str = '2\n3 3\n1\n2 2\n4 4\n0\n' t, test_cases = parse_input(input_str) result = solve(t, test_cases) assert result == [2, 20] def test_no_blocked_cells(): input_str = '1\n2 2\n0\n' t, test_cases = parse_input(input_str) res...
[ { "docstring": null, "function_declaration": "def unique_paths_with_obstacles(n, m, blocked_cells):", "function_name": "unique_paths_with_obstacles", "parameter_list": "(n, m, blocked_cells)" }, { "docstring": null, "function_declaration": "def solve(t, test_cases):", "function_name"...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def unique_paths_with_obstacles(n, m, blocked_cells):\n # Create a 2D dp table initialized to 0\n dp = [[0] * (m + 1) for _ in range(n + 1)]\n \n # Sta...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002178", "row_id": 2178, "seed_ids": "[19338]" }
0.73429
Taco_2178
I
[ "unique_paths_with_obstacles", "solve", "parse_input" ]
3
[ [ "solve", "unique_paths_with_obstacles" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
603a9a4da144eb14ac538d3167fa0992454530cf
7bb6c5f1cc6910c7a0befb298c7f577082c8b77c
v1.0
instruct
Taco
Taco_2275_I
Chef has recently taken an interest in computational geometry, particularly in the topic of convex hulls. Chef has a set of points (x, y) on a 2D plane and he wants to construct the convex hull out of these points. The convex hull is the smallest convex polygon that can enclose all of the given points. Chef has asked f...
import math from functools import cmp_to_key def distance(p1, p2): return math.sqrt((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) def cross_product(o, a, b): return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) def convex_hull(points): points = sorted(points) lower = [] for p ...
from solution import solve def test_example_cases(): T = 2 test_cases = [ (4, [(0, 0), (0, 1), (1, 0), (1, 1)]), (3, [(2, 3), (4, 5), (6, 7)]) ] expected = ["4.00", "11.31"] assert solve(T, test_cases) == expected def test_single_test_case_square(): T = 1 test_cases = [(4,...
[ { "docstring": null, "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def cross_product(o, a, b):", "function_name": "cross_product", "parameter_list": "(o, a, b)" }, { ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_distance(p1, p2):\n \"\"\"\n Calculate the distance between two points p1 and p2.\n \"\"\"\n return math.sqrt((p2[0] - p1[...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00002275", "row_id": 2275, "seed_ids": "[8321]" }
0.54717
Taco_2275
I
[ "distance", "cross_product", "convex_hull", "perimeter_of_convex_hull", "format_output", "solve", "main" ]
7
[ [ "convex_hull", "cross_product" ], [ "perimeter_of_convex_hull", "convex_hull" ], [ "perimeter_of_convex_hull", "distance" ], [ "solve", "format_output" ], [ "solve", "perimeter_of_convex_hull" ] ]
5
[ "format_output" ]
false
[]
false
pytest
true
[]
true
2179eca6b35e5b941b0389df7de665ae63033ee3
bb07ed9e13c62193d4ecdfe694da2d17dcbf9210
v1.0
instruct
Taco
Taco_2319_I
Determine the smallest integer N such that when divided by each integer from 1 to K (inclusive), the remainder is always a multiple of that integer. If no such N exists within the range of 1 to 10^9, print -1. ### Constraints - 1 ≤ K ≤ 20 - K is an integer. ### Input Input is given from Standard Input in the followin...
import math from functools import reduce def lcm(x, y): return x * y // math.gcd(x, y) def smallest_int_divisible(K): if K < 1 or K > 20: return -1 smallest_multiple = reduce(lcm, range(1, K + 1)) # Check if the result is within the limit of 10^9 if smallest_multiple > 10**9:...
from solution import smallest_int_divisible def test_smallest_int_divisible(): assert smallest_int_divisible(1) == 1 assert smallest_int_divisible(2) == 2 assert smallest_int_divisible(3) == 6 assert smallest_int_divisible(4) == 12 assert smallest_int_divisible(5) == 60 assert smallest_int_divi...
[ { "docstring": null, "function_declaration": "def lcm(x, y):", "function_name": "lcm", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def smallest_int_divisible(K):", "function_name": "smallest_int_divisible", "parameter_list": "(K)" } ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef smallest_integer(K):\n \"\"\"\n Determines the smallest integer N such that when divided by each integer from 1 to K \n (inclusive), th...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00002319", "row_id": 2319, "seed_ids": "[3157]" }
0.770342
Taco_2319
I
[ "lcm", "smallest_int_divisible" ]
2
[ [ "smallest_int_divisible", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9bc281a06c504c3df385029e4ce452ebc5a1d8a8
ca0526a2ee9495129a6032fa9b0f1bc6a2bf3cbe
v1.0
instruct
Taco
Taco_2346_I
A number is said to be **palindromic** if it reads the same backward as forward. For example, 121 is palindromic while 123 is not. Given an integer $n$, find the smallest integer $x \ge n$ such that $x$ is palindromic. -----Input----- The first line of input contains one integer $t$ $(1 \le t \le 10^4)$ — the number...
def is_palindrome(x): """Check if a number is a palindrome""" return str(x) == str(x)[::-1] def next_palindrome(n): """Finds the smallest palindrome greater than or equal to n""" while not is_palindrome(n): n += 1 return n def find_smallest_palindromes(test_cases): """Find the smallest...
from solution import is_palindrome, next_palindrome, find_smallest_palindromes def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True assert is_palindrome(12321) == True def test_next_palin...
[ { "docstring": "Check if a number is a palindrome", "function_declaration": "def is_palindrome(x):", "function_name": "is_palindrome", "parameter_list": "(x)" }, { "docstring": "Finds the smallest palindrome greater than or equal to n", "function_declaration": "def next_palindrome(n):", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindromic(x):\n \"\"\"\n Function to check if a number is palindromic.\n \"\"\"\n return str(x) == str(x)[::-1]\n\ndef find_smallest_palindrom...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002346", "row_id": 2346, "seed_ids": "[10418]" }
0.816889
Taco_2346
I
[ "is_palindrome", "next_palindrome", "find_smallest_palindromes" ]
3
[ [ "find_smallest_palindromes", "next_palindrome" ], [ "next_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7acb7990b2cd0be8257d674dbc0ea5a46ca05555
4b5787d2772e97b4a0563dc5df72c7e5f30b95f1
v1.0
instruct
Taco
Taco_2372_I
Anna has a list of integers and she wants to know how many special integers it contains. An integer is considered special if its digits can be arranged to form a palindrome. By definition, a palindrome is a number that reads the same backward as forward. Write a program that takes an input list of n integers (1 <= n <...
def is_special(n: int) -> bool: """ Determines if the digits of an integer can be arranged to form a palindrome. """ from collections import Counter # Convert integer to string to get its digits digits = str(n) # Count occurrences of each digit count = Counter(digits) # A number...
def test_is_special(): assert is_special(121) == True assert is_special(131) == True assert is_special(123) == False assert is_special(787) == True assert is_special(12) == False assert is_special(222) == True assert is_special(12321) == True assert is_special(445) == True def test_coun...
[ { "docstring": "Determines if the digits of an integer can be arranged to form a palindrome.", "function_declaration": "def is_special(n):", "function_name": "is_special", "parameter_list": "(n)" }, { "docstring": "Counts how many integers in the list are special.", "function_declaration...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_special_integer(x):\n \"\"\"\n Returns True if the digits of integer x can be rearranged to form a palindrome. \n Otherwise, returns False.\n \"...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00002372", "row_id": 2372, "seed_ids": "[8371]" }
0.707213
Taco_2372
I
[ "is_special", "count_special_integers" ]
2
[ [ "count_special_integers", "is_special" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6d2837b8b741ec5ed4459bd0c0e481048904eafd
da80713f205a0ba228deafeb7366000416b09922
v1.0
instruct
Taco
Taco_2465_I
In a distant world, a network of towns is connected by an intricate series of one-way roads. Each road has a specific travel time associated with it, and every town can be reached from any other town. However, some roads have a peculiar characteristic: they are devoid of any traffic. These roads are called "silent path...
import heapq import sys def dijkstra(graph, start, n): distances = [float('inf')] * n distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) if current_distance > distances[current_node]: ...
import sys from io import StringIO from solution import main def test_example_1(): input_data = """4 4 2 0 1 10 1 2 5 2 3 2 0 3 100 0 3 1 3""" expected_output = "17\n7\n" old_stdout = sys.stdout sys.stdout = StringIO() main(input_data) output = sys.stdout.getvalue() sys.stdout = old_st...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, start, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, n)" }, { "docstring": null, "function_declaration": "def find_shortest_times(n, edges, queries):", "function_name": "find_shortest_times", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\n\ndef dijkstra(graph, start, n):\n distances = [float('inf')] * n\n distances[start] = 0\n priority_queue = [(0, start)]\n \n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00002465", "row_id": 2465, "seed_ids": "[23170]" }
0.728495
Taco_2465
I
[ "dijkstra", "find_shortest_times", "process_input", "main" ]
4
[ [ "find_shortest_times", "dijkstra" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
1f84514004fb709f8bae99169ba13bf0bf54a1ba
3a9159229219021f6594eb4a8d3cb0dd37d7983f
v1.0
instruct
Taco
Taco_2619_I
You are given a grid of characters and a dictionary of words. Your task is to find all valid words from the dictionary that can be formed by sequentially adjacent letters in the grid. "Adjacent" letters are those horizontally or vertically neighboring. Words must be constructed from letters of sequentially adjacent cel...
def exist(board, word): if not board: return False rows, cols = len(board), len(board[0]) def dfs(r, c, index): if index == len(word): return True if not (0 <= r < rows) or not (0 <= c < cols) or board[r][c] != word[index]: return False ...
def test_find_words_in_grid(): grid = [ "abcd", "efgh", "ijkl" ] words = ["abc", "abcd", "abcfh", "ijkl", "efg"] expected_output = ["YES", "YES", "NO", "YES", "YES"] assert find_words_in_grid(grid, words) == expected_output def test_empty_grid(): grid = [] words...
[ { "docstring": null, "function_declaration": "def exist(board, word):", "function_name": "exist", "parameter_list": "(board, word)" }, { "docstring": null, "function_declaration": "def find_words_in_grid(grid, words):", "function_name": "find_words_in_grid", "parameter_list": "(g...
[ 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_words_in_grid(grid, words):\n R, C = len(grid), len(grid[0])\n \n def is_valid(x, y):\n return 0 <= x < R and 0 <= y < C\n\n def search...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002619", "row_id": 2619, "seed_ids": "[19775]" }
0.749131
Taco_2619
I
[ "exist", "find_words_in_grid" ]
2
[ [ "find_words_in_grid", "exist" ] ]
1
[]
false
[]
false
pytest
false
[]
true
088eabfc6748d6ae4d63c03a3fc20f080b2ecb8b
654139bc3cdc04fa317c6eda110338d66ff98478
v1.0
instruct
Taco
Taco_2623_I
Anna has a sequence of $n$ integers $b_1, b_2, \ldots, b_n$. She can perform exactly one of the following operations on the sequence: 1. **Swap**: Choose two elements in the sequence and swap their positions. 2. **Replace**: Choose one element in the sequence and replace it with any other integer. Anna wants to modif...
def can_be_non_decreasing(t, test_cases): results = [] for n, arr in test_cases: if is_non_decreasing(arr): results.append("YES") continue possible = False for i in range(n): for j in range(i + 1, n): # Try swapping i and j ...
from solution import can_be_non_decreasing def test_single_case_yes(): assert can_be_non_decreasing(1, [(4, [1, 5, 3, 2])]) == ["YES"] def test_single_case_no(): assert can_be_non_decreasing(1, [(5, [5, 4, 3, 2, 1])]) == ["NO"] def test_multiple_cases(): test_cases = [ (4, [1, 5, 3, 2]), ...
[ { "docstring": null, "function_declaration": "def can_be_non_decreasing(t, test_cases):", "function_name": "can_be_non_decreasing", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def is_non_decreasing(arr):", "function_name": "is_non_decreasing",...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_non_decreasing_by_one_operation(t, test_cases):\n results = []\n for case in test_cases:\n n, seq = case\n if n == 2:\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002623", "row_id": 2623, "seed_ids": "[15505]" }
0.84125
Taco_2623
I
[ "can_be_non_decreasing", "is_non_decreasing" ]
2
[ [ "can_be_non_decreasing", "is_non_decreasing" ] ]
1
[]
false
[]
false
pytest
true
[]
true
32cf644d284504447e4383aaa7ef4bc960d8cedd
423aee431e0c776001ac793ca69e97010654ccb7
v1.0
instruct
Taco
Taco_2639_I
Diana is traveling through a magical forest to find a rare herb. The forest is represented by an `n x n` grid where each cell contains an integer representing the height of the terrain. Diana can move to an adjacent cell if the height difference between the current cell and the target cell is at most `h`. Your task is...
def can_travel(grid, n, h): from collections import deque directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] def bfs(height_diff): queue = deque([(0, 0)]) visited = set((0, 0)) while queue: x, y = queue.popleft() if (x, y) == (n-1,...
from solution import find_min_height_diff def test_example_case(): grid = [ [1, 2, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 2, 3, 5], [1, 1, 2, 1, 4], [1, 1, 1, 1, 0] ] assert find_min_height_diff(5, 3, grid) == 1 def test_single_cell(): grid = [[1]] assert find_mi...
[ { "docstring": null, "function_declaration": "def can_travel(grid, n, h):", "function_name": "can_travel", "parameter_list": "(grid, n, h)" }, { "docstring": null, "function_declaration": "def find_min_height_diff(n, m, grid):", "function_name": "find_min_height_diff", "parameter...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_height_difference(grid, n, m):\n from heapq import heappop, heappush\n\n def valid(x, y):\n return 0 <= x < n and 0 <= y < n\n\n def bfs(ma...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00002639", "row_id": 2639, "seed_ids": "[8796]" }
0.67806
Taco_2639
I
[ "can_travel", "find_min_height_diff" ]
2
[ [ "find_min_height_diff", "can_travel" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2d99b75072400c2623e323d1ef6b59dd4da66e6f
b68dad42c1924e1ae76ed5f916d50f3d7dcb691a
v1.0
instruct
Taco
Taco_2661_I
In the land of Pylogia, there's a network of cities connected by a complex system of roads. Each road in Pylogia has a capacity limit on the number of vehicles that can traverse it simultaneously. During peak hours, people often face delays due to traffic congestion. The king of Pylogia wants to alleviate this problem...
from collections import deque def bfs_capacity(graph, source, sink, parent): visited = [False] * (len(graph)) queue = deque([source]) visited[source] = True while queue: u = queue.popleft() for ind, val in enumerate(graph[u]): if visited[ind] == False and val > 0: ...
def test_case_1(): assert max_flow(4, 5, [(1, 2, 100), (2, 3, 50), (1, 3, 100), (3, 4, 100), (2, 4, 50)]) == 150 def test_case_2(): assert max_flow(3, 3, [(1, 2, 10), (1, 3, 15), (2, 3, 20)]) == 25 def test_case_3(): assert max_flow(2, 1, [(1, 2, 5)]) == 5 def test_case_4(): assert max_flow(5, 7, [(1...
[ { "docstring": null, "function_declaration": "def bfs_capacity(graph, source, sink, parent):", "function_name": "bfs_capacity", "parameter_list": "(graph, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(graph, source, sink):", "function_name":...
[ 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, defaultdict\n\ndef bfs(capacity, source, sink, parent):\n visited = [False] * len(capacity)\n queue = deque([source])\n vis...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00002661", "row_id": 2661, "seed_ids": "[21092]" }
0.726
Taco_2661
I
[ "bfs_capacity", "edmonds_karp", "max_flow" ]
3
[ [ "edmonds_karp", "bfs_capacity" ], [ "max_flow", "edmonds_karp" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3621622bee86d99fd600e6cca4b94291458a8fcf
bb11f2c1b99e6e8a638856a16b0a60de207155c6
v1.0
instruct
Taco
Taco_2692_I
In a faraway land, there are x number of castles and y roads connecting them. Each road has a toll tax associated with it. A toll tax is required to use certain roads that exist between these castles. The King has just passed a new decree which states that the maximum amount of toll that can be collected for a single t...
import heapq def find_min_toll(x, y, roads, L): graph = {i: [] for i in range(1, x+1)} for u, v, t in roads: graph[u].append((t, v)) graph[v].append((t, u)) def dijkstra(source): pq = [(0, source)] min_cost = {i: float('inf') for i in range(1, x+1)} min_cost[sou...
import pytest from solution import solution def test_example(): data = "3 3\n1 2 4\n2 3 6\n1 3 8\n10\n4 4\n1 2 5\n2 3 7\n3 4 3\n4 1 6\n12\n0 0\n" result = solution(data) assert result == "Possible 4\nPossible 3" def test_not_possible(): data = "3 3\n1 2 4\n2 3 6\n1 3 8\n5\n0 0\n" result = solution...
[ { "docstring": null, "function_declaration": "def find_min_toll(x, y, roads, L):", "function_name": "find_min_toll", "parameter_list": "(x, y, roads, L)" }, { "docstring": null, "function_declaration": "def process_input(data):", "function_name": "process_input", "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 find_minimum_toll(x, y, roads, L):\n def dfs(graph, src, visited):\n visited[src] = True\n for neighbor, toll in graph[src]:\n if n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002692", "row_id": 2692, "seed_ids": "[7428]" }
0.726322
Taco_2692
I
[ "find_min_toll", "process_input", "solution" ]
3
[ [ "process_input", "find_min_toll" ], [ "solution", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
c72c8561b3de6d4896ad9960777e39b5660be2a3
acbeff185b5810287d387d8cf19b8a55e8651f1a
v1.0
instruct
Taco
Taco_2721_I
In a town called Primeville, the residents celebrate an annual festival with grand parades over several days. The parade consists of a sequence of floats, each float represented by a number. A float is said to be 'lucky' if its number is a prime number. Given the list of floats for each day of the festival, determine ...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def count_lucky_floats(days): results = []...
from solution import is_prime, count_lucky_floats 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 assert is_prime(23) == True assert is_prime(1) == False def test_count_lucky_flo...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_lucky_floats(days):", "function_name": "count_lucky_floats", "parameter_list": "(days)" } ]
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Returns True if n is a prime number, else False.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002721", "row_id": 2721, "seed_ids": "[23142]" }
0.630813
Taco_2721
I
[ "is_prime", "count_lucky_floats" ]
2
[ [ "count_lucky_floats", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b62520b65aebffd7090d9ba64a9a175a102b277
6418b9b578fa4c164e9807412e7a4d0feabe5ed6
v1.0
instruct
Taco
Taco_2852_I
In the kingdom of Arithmancia, the royal library contains numerous ancient manuscripts, each containing spells represented as pairs of numbers (a, b). The spells are powerful only when 'a' is a prime number and 'b' is a perfect square. The grand wizard wants to sift through the library and identify all powerful spells....
def is_prime(n): """ Check if n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return Tr...
import pytest from solution import identify_powerful_spells, is_prime, is_perfect_square def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False def test_is_perfect_square(): assert is_perfect...
[ { "docstring": "Check if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if x is a perfect square.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_squa...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00002852", "row_id": 2852, "seed_ids": "[2214]" }
0.574431
Taco_2852
I
[ "is_prime", "is_perfect_square", "identify_powerful_spells" ]
3
[ [ "identify_powerful_spells", "is_perfect_square" ], [ "identify_powerful_spells", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ea452b7f232018d19f5d1057dc8cca1b55f15e2f
b6b2448cb54ef1001155337cf72281e41549e045
v1.0
instruct
Taco
Taco_2901_I
Given a list of numbers, each number can be a positive or a negative integer. You need to find the sum of the elements that are prime numbers and their respective frequencies in the list. Prime numbers in the context of this problem are numbers greater than 1 that have no divisors other than 1 and themselves. Input: ...
def is_prime(num): """ Helper function to determine if a number is a prime number. """ if num < 2: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False retu...
from solution import is_prime, sum_and_frequency_of_primes 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 assert is_prime(0) == False assert is_prime(-1) == False def test_sum_a...
[ { "docstring": "Helper function to determine if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Given a list of integers, return the sum of the elements that are prime numbers\nand their res...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return False\n max_divisor = in...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00002901", "row_id": 2901, "seed_ids": "[18836]" }
0.628046
Taco_2901
I
[ "is_prime", "sum_and_frequency_of_primes" ]
2
[ [ "sum_and_frequency_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
947774565265b5be2e88e9e1edf9bb5dda27c370
c435bd645797d32b56c3e71962f24ed7ad34a6e7
v1.0
instruct
Taco
Taco_2931_I
Write a program that processes log data and extracts specific information about user activities. The program should read the log data and, for each user, calculate the total amount of time they were active. The log data is provided in a specific format and may span multiple days. Each user can have multiple login and l...
from datetime import datetime, timedelta from collections import defaultdict def parse_log_entry(entry): parts = entry.split() timestamp = datetime.strptime(parts[0] + ' ' + parts[1], '%Y-%m-%d %H:%M:%S') user_id = parts[2] event = parts[3] return timestamp, user_id, event def process_logs(log_dat...
from solution import main, process_logs, parse_log_entry, format_active_time from datetime import datetime, timedelta def test_parse_log_entry(): entry = "2023-09-01 09:00:00 user1 LOGIN" expected_timestamp = datetime(2023, 9, 1, 9, 0, 0) expected_user_id = "user1" expected_event = "LOGIN" assert p...
[ { "docstring": null, "function_declaration": "def parse_log_entry(entry):", "function_name": "parse_log_entry", "parameter_list": "(entry)" }, { "docstring": null, "function_declaration": "def process_logs(log_data):", "function_name": "process_logs", "parameter_list": "(log_data...
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime, timedelta\nfrom collections import defaultdict\n\ndef process_log_data(logs):\n user_activities = defaultdict(list)\n user_act...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00002931", "row_id": 2931, "seed_ids": "[9830]" }
0.588544
Taco_2931
I
[ "parse_log_entry", "process_logs", "format_active_time", "main" ]
4
[ [ "process_logs", "parse_log_entry" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b7ae73c84a4bb94c8bc2d305439ed4340b7bfcb9
3fe89ff8f8bdf8d50e388bf76ace7ab4dd8696f3
v1.0
instruct
Taco
Taco_3028_I
A company is conducting interviews for Software Development Engineer positions, and the hiring team wants to test the candidates on their algorithmic and problem-solving skills. One of the challenges they have prepared involves understanding how well candidates can handle nested data structures and compute specific kin...
def calculate_total_score(employee, hierarchy): """ This function calculates the total performance score of a specified employee and all their subordinates recursively. :param employee: The name of the employee to calculate the score for. :param hierarchy: The nested dictionary representing the hie...
from solution import solution def test_case_1(): N = 3 input_list = [ 'Alice 95 Bob 90', 'Bob 90 Charlie 80', 'Charlie 80' ] queries = ['Alice', 'Bob', 'Charlie'] assert solution(N, input_list, queries) == [265, 170, 80] def test_case_2(): N = 2 input_list = [ ...
[ { "docstring": "This function calculates the total performance score of a specified employee and all their subordinates recursively.\n\n:param employee: The name of the employee to calculate the score for.\n:param hierarchy: The nested dictionary representing the hierarchy structure.\n:return: The total perform...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_total_score(employee, hierarchy):\n \"\"\"\n This function calculates the total performance score of a specified employee and all their subordi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00003028", "row_id": 3028, "seed_ids": "[19715]" }
0.627312
Taco_3028
I
[ "calculate_total_score", "build_hierarchy", "solution" ]
3
[ [ "solution", "build_hierarchy" ], [ "solution", "calculate_total_score" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6efa0ed176e929495176469bfbbae642bd678021
fda801f9951543c7b10c10757e2e3e32c27b0c5f
v1.0
instruct
Taco
Taco_3049_I
You are given an array of positive integers. Your task is to reorder the array such that the sum of the product of adjacent elements is minimized. If multiple orderings yield the same minimum sum, any of them is acceptable. If the array contains only one element, return the array as-is. ------ Input Format ------ - ...
def min_adjacent_product_sum(arr): """ Given an array of positive integers, reorder the array such that the sum of the product of adjacent elements is minimized. """ arr.sort() return arr def reorder_arrays(test_cases): """ Processes multiple test cases of reordering arrays to minimize...
def test_min_adjacent_product_sum(): assert min_adjacent_product_sum([4, 2, 1]) == [1, 2, 4] assert min_adjacent_product_sum([1, 3, 2, 4]) == [1, 2, 3, 4] assert min_adjacent_product_sum([10, 1, 100, 2]) == [1, 2, 10, 100] assert min_adjacent_product_sum([2, 2, 2, 2]) == [2, 2, 2, 2] def test_reorder_a...
[ { "docstring": "Given an array of positive integers, reorder the array such that the sum of \nthe product of adjacent elements is minimized.", "function_declaration": "def min_adjacent_product_sum(arr):", "function_name": "min_adjacent_product_sum", "parameter_list": "(arr)" }, { "docstring"...
[ 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 reorder_array_min_sum_product(adjacent_arr):\n \"\"\"\n This function reorders an array of positive integers such that the sum of the product \n of ad...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003049", "row_id": 3049, "seed_ids": "[10202]" }
0.709134
Taco_3049
I
[ "min_adjacent_product_sum", "reorder_arrays", "process_input", "format_output", "main" ]
5
[ [ "reorder_arrays", "min_adjacent_product_sum" ] ]
1
[ "process_input", "format_output" ]
false
[]
false
pytest
false
[]
true
c8535b59ca5ce5a87383e99f6ac823200bd9dea7
bf26bee80b8ba015bbce2092dcfdd6b54696b055
v1.0
instruct
Taco
Taco_3085_I
Sarah loves solving puzzles and playing with numbers. One day, she encountered an interesting problem and decided to share it with her friends. Given an array of positive integers, the *fairness score* of the array is the difference between the sum of elements at even indices and the sum of elements at odd indices. F...
def fairness_score(arr): """ Computes the fairness score of the array. The fairness score is the difference between the sum of elements at even indices and the sum of elements at odd indices. """ even_sum = sum(arr[i] for i in range(0, len(arr), 2)) odd_sum = sum(arr[i] for i in range(1, len...
import pytest from solution import fairness_score, compute_fairness_scores, parse_input def test_fairness_score(): assert fairness_score([10, 20, 30, 40, 50]) == 30 assert fairness_score([5, 15, 25, 35]) == -20 assert fairness_score([1, 2, 3]) == 2 def test_compute_fairness_scores(): test_cases = [ ...
[ { "docstring": "Computes the fairness score of the array.\nThe fairness score is the difference between the sum of elements\nat even indices and the sum of elements at odd indices.", "function_declaration": "def fairness_score(arr):", "function_name": "fairness_score", "parameter_list": "(arr)" },...
[ 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 fairness_score_for_multiple_arrays(test_cases):\n \"\"\"\n Given multiple test cases, calculate the fairness score for each array.\n \n :param test...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003085", "row_id": 3085, "seed_ids": "[2356]" }
0.665084
Taco_3085
I
[ "fairness_score", "compute_fairness_scores", "parse_input" ]
3
[ [ "compute_fairness_scores", "fairness_score" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
cb464662452d16482c76fc83ac5c703182f7c196
ad707aa60420b27006636cf2758441a7a7e7cf6a
v1.0
instruct
Taco
Taco_3090_I
Alex is fond of prime numbers and he loves to test his friends with interesting problems related to them. Today, he has come up with a new problem. He gives his friends a sequence of numbers and asks them to find the sum of all prime numbers in that sequence. Input The first line of the input contains an integer T de...
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(17) == True assert is_prime(18) == False def test_sum_of_primes_in_sequences(): a...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of sums of prime numbers for each sequence in sequences.", "function_declaratio...
[ 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 Checks if the number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003090", "row_id": 3090, "seed_ids": "[9820]" }
0.603059
Taco_3090
I
[ "is_prime", "sum_of_primes_in_sequences", "process_input" ]
3
[ [ "process_input", "sum_of_primes_in_sequences" ], [ "sum_of_primes_in_sequences", "is_prime" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
9dd908a895db6eb8327714f373f50b2b1586e9f8
95507b5c527e235830e1ae4fab7cd6058ed13375
v1.0
instruct
Taco
Taco_3106_I
A logistics company manages a fleet of delivery vans. Each van starts its route from a central depot and delivers packages to various locations in the city. The company wants to optimize the routes such that the total distance covered by all the vans is minimized, and every package is delivered to its destination. Eac...
def optimize_van_routes(n, k, c, depot, destinations): def calculate_distance(p1, p2): return ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5 destinations.sort(key=lambda d: calculate_distance(depot, d)) routes = [] used_packages = 0 while used_packages < n: route_pac...
def test_optimize_van_routes(): n, k, c = 6, 2, 3 depot = (0, 0) destinations = [(1, 2), (-2, 3), (4, 5), (1, 1), (-1, -3), (2, -1)] num_vans, routes = optimize_van_routes(n, k, c, depot, destinations) assert num_vans == 2 assert len(routes) == 2 assert len(routes[0]) == 3 assert le...
[ { "docstring": null, "function_declaration": "def optimize_van_routes(n, k, c, depot, destinations):", "function_name": "optimize_van_routes", "parameter_list": "(n, k, c, depot, destinations)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef calculate_distance(p1, p2):\n \"\"\"\n Calculates Euclidean distance between two points.\n \"\"\"\n return ((...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00003106", "row_id": 3106, "seed_ids": "[15474]" }
0.733749
Taco_3106
I
[ "optimize_van_routes", "solve" ]
2
[ [ "solve", "optimize_van_routes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1f6d049022973b1b2c7d94abd1cfa7e62be12538
eb6cf1081b51b44e4bb4350dbf7a51f0e3e2442b
v1.0
instruct
Taco
Taco_3119_I
You are given $n$ integers arranged in an array. You want to split the array into as many subarrays as possible such that each subarray contains at least one prime number. A prime number is a number greater than 1 that has no divisors other than 1 and itself. Determine the maximum number of subarrays that you can spl...
import math 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 max_subarra...
from solution import is_prime, max_subarrays_with_prime def test_is_prime(): assert is_prime(2) assert not is_prime(1) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(101) def test_max_subarrays_with_prime(): assert max_subarrays_with...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def max_subarrays_with_prime(t, test_cases):", "function_name": "max_subarrays_with_prime", "parameter_list":...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00003119", "row_id": 3119, "seed_ids": "[9582]" }
0.672159
Taco_3119
I
[ "is_prime", "max_subarrays_with_prime" ]
2
[ [ "max_subarrays_with_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
54adb0c34774a0e545d3046e7cc4d84578a85f0b
80d1e03ec6bc492bbbbf42e078ce7957833ec4c1
v1.0
instruct
Taco
Taco_3173_I
You are given a grid with obstacles and targets. Your task is to find the minimal number of steps required to reach a target from a given starting point, avoiding obstacles. If it is not possible to reach any target, return `-1`. The allowed movements are up (`U`), down (`D`), left (`L`), and right (`R`). -----Constra...
from collections import deque def min_steps(grid): m = len(grid) n = len(grid[0]) # Find the starting point start = None for i in range(m): for j in range(n): if grid[i][j] == 'S': start = (i, j) break if start: break ...
from solution import min_steps def test_no_obstacles_minimal_path(): grid = [ ['S', '.', '.', '.'], ['.', '.', '.', 'T'], ] assert min_steps(grid) == 4 def test_with_obstacles_possible(): grid = [ ['S', '.', '.', '.'], ['.', '#', '#', '.'], ['.', '.', '.', 'T'],...
[ { "docstring": null, "function_declaration": "def min_steps(grid):", "function_name": "min_steps", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solution():", "function_name": "solution", "parameter_list": "()" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef minimal_steps_to_target(m, n, grid):\n \"\"\"\n Returns the minimal number of steps required to reach a target from the ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00003173", "row_id": 3173, "seed_ids": "[23304]" }
0.755797
Taco_3173
I
[ "min_steps", "solution" ]
2
[ [ "solution", "min_steps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d9962cfbda480e5353ea77035955d062f39dab49
62f3c90c47e3de3f03db840edfb87c194a7b4f98
v1.0
instruct
Taco
Taco_3200_I
A social media platform tracks users and their connections. Your task is to determine if two users are indirectly connected through mutual friends. When users are directly connected, they have a mutual friend path length of 1. If they are connected through exactly one mutual friend, the path length is 2, and so on. Tw...
def find_parent(parent, x): if parent[x] != x: parent[x] = find_parent(parent, parent[x]) return parent[x] def union_parent(parent, rank, a, b): rootA = find_parent(parent, a) rootB = find_parent(parent, b) if rootA != rootB: if rank[rootA] > rank[rootB]: parent[rootB] ...
from solution import are_indirectly_connected def test_example_case(): n = 5 m = 4 connections = [(1, 2), (2, 3), (3, 4), (4, 5)] q = 3 queries = [(1, 5), (1, 4), (2, 5)] expected = ["YES", "YES", "YES"] assert are_indirectly_connected(n, m, connections, q, queries) == expected def test_no...
[ { "docstring": null, "function_declaration": "def find_parent(parent, x):", "function_name": "find_parent", "parameter_list": "(parent, x)" }, { "docstring": null, "function_declaration": "def union_parent(parent, rank, a, b):", "function_name": "union_parent", "parameter_list": ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef build_graph(n, connections):\n graph = defaultdict(list)\n for u, v in connections:\n graph[u].appen...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00003200", "row_id": 3200, "seed_ids": "[12255]" }
0.697556
Taco_3200
I
[ "find_parent", "union_parent", "are_indirectly_connected" ]
3
[ [ "are_indirectly_connected", "find_parent" ], [ "are_indirectly_connected", "union_parent" ], [ "union_parent", "find_parent" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8ce1c6d695fa61e107beeffe1ac24d236789ff5f
5731da8fdf269bd585cf7a1ceeacb39745737027
v1.0
instruct
Taco
Taco_3315_I
Maria has started learning about prime numbers and she is particularly fascinated by the twin primes. Twin primes are pairs of prime numbers that have a difference of 2. For example, (3, 5) and (11, 13) are twin primes. Now Maria wants to find all the twin prime pairs up to a number n but she needs your help to write ...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def find_twin_primes(n): t...
from solution import find_twin_primes, twin_prime_output def test_twin_prime_output_example_1(): assert twin_prime_output(20) == "3 5\n5 7\n11 13\n17 19" def test_twin_prime_output_example_2(): assert twin_prime_output(10) == "3 5\n5 7" def test_twin_prime_output_example_3(): assert twin_prime_output(2) ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def find_twin_primes(n):", "function_name": "find_twin_primes", "parameter_list": "(n)" }, { "docstri...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00003315", "row_id": 3315, "seed_ids": "[16153]" }
0.746118
Taco_3315
I
[ "is_prime", "find_twin_primes", "twin_prime_output" ]
3
[ [ "find_twin_primes", "is_prime" ], [ "twin_prime_output", "find_twin_primes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b6068e728f2290970d8eb9cd3dd4eb5723d0c8f5
48a38c7b36e9fe8567be344e6239cc9ebb85d82c
v1.0
instruct
Taco
Taco_3343_I
John is planning to build a small network of computers in his office. The computers will be connected with network cables, where each cable connects two computers directly. Because of physical space limitations, John cannot use more than `m` cables. Furthermore, due to potential security risks, John wants to ensure tha...
def find_network_connections(n, m, connections): def find(parent, x): if parent[x] != x: parent[x] = find(parent, parent[x]) return parent[x] def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank...
def test_network_example_1(): n = 4 m = 4 connections = [(1, 2), (1, 3), (2, 3), (3, 4)] expected_output = "3\n1 2\n1 3\n3 4" assert network(n, m, connections) == expected_output def test_network_example_2(): n = 5 m = 10 connections = [(1, 2), (2, 3), (3, 4), (4, 5), (1, 5), (2, 4), (3...
[ { "docstring": null, "function_declaration": "def find_network_connections(n, m, connections):", "function_name": "find_network_connections", "parameter_list": "(n, m, connections)" }, { "docstring": null, "function_declaration": "def network(n, m, connections):", "function_name": "n...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def build_network(n, m, connections):\n from collections import defaultdict\n \n if m < n - 1:\n return -1\n \n adj_list = defaultdict(set)\n...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00003343", "row_id": 3343, "seed_ids": "[19979]" }
0.638105
Taco_3343
I
[ "find_network_connections", "network" ]
2
[ [ "network", "find_network_connections" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5a3adc32636ca5fca64872960f122921cefb9ff4
fec1cebe727c8dd8d0cc1d55d715c6c17c423f76
v1.0
instruct
Taco
Taco_3355_I
Tina is learning to work with binary search trees (BST). She has created a BST that contains unique values. She wants to find the k-th smallest element in the BST. Your task is to help Tina write a program to find the k-th smallest element in a given BST. ----Input---- - The first line contains an integer n (1 ≤ n ≤...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_into_bst(root, val): if root is None: return TreeNode(val) if val < root.val: root.left = insert_into_bst(root.left, val) else: root.right = insert_into_bst(...
def test_case_1(): assert find_kth_smallest(7, [15, 10, 20, 8, 12, 17, 25], 3) == 12 def test_case_2(): assert find_kth_smallest(5, [5, 3, 7, 2, 4], 4) == 5 def test_case_3(): assert find_kth_smallest(6, [1, 2, 3, 4, 5, 6], 6) == 6 def test_case_4(): assert find_kth_smallest(3, [3, 1, 2], 2) == 2 de...
[]
[ 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": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef insert_into_bst(root, val):\n if r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00003355", "row_id": 3355, "seed_ids": "[16525]" }
0.515436
Taco_3355
I
[ "insert_into_bst", "build_bst_from_preorder", "inorder_traverse", "kth_smallest", "find_kth_smallest" ]
5
[ [ "build_bst_from_preorder", "insert_into_bst" ], [ "find_kth_smallest", "build_bst_from_preorder" ], [ "find_kth_smallest", "kth_smallest" ], [ "kth_smallest", "inorder_traverse" ] ]
4
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
836021c5f1d8ecf3ccfcce9413ca8ddc45179784
3f6e2f2cdf978b550326f247a2422a410d617b6f
v1.0
instruct
Taco
Taco_3459_I
You are given a collection of n distinct positive integers. Your task is to determine if you can select exactly k integers from this collection such that the sum of these k integers is a prime number. If it is possible, print "YES", otherwise print "NO". Input: The first line contains two integers n (1 ≤ n ≤ 50) and ...
from itertools import combinations from math import isqrt def is_prime(number): if number < 2: return False for i in range(2, isqrt(number) + 1): if number % i == 0: return False return True def can_sum_be_prime(n, k, arr): possible_combinations = combinations(arr, k) ...
from solution import can_sum_be_prime def test_example_1(): assert can_sum_be_prime(5, 3, [2, 5, 9, 13, 15]) == "YES" def test_example_2(): assert can_sum_be_prime(4, 2, [6, 8, 10, 12]) == "NO" def test_single_element(): assert can_sum_be_prime(1, 1, [2]) == "YES" assert can_sum_be_prime(1, 1, [1]) =...
[ { "docstring": null, "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def can_sum_be_prime(n, k, arr):", "function_name": "can_sum_be_prime", "parameter_list": "(n, k, arr)"...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef is_prime(num):\n \"\"\"Check if a number is prime.\"\"\"\n if num <= 1:\n return False\n for i in range(2...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00003459", "row_id": 3459, "seed_ids": "[6687]" }
0.564857
Taco_3459
I
[ "is_prime", "can_sum_be_prime" ]
2
[ [ "can_sum_be_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3369d222c8e17c1ca914af4019a31b69fbf74570
f61128f53b77810713d31cb62c3a0af349a73f75
v1.0
instruct
Taco
Taco_3471_I
Sara is participating in a coding competition where she needs to solve a problem related to arranging sequences. The task involves arranging multiple subsequences into a single sequence while following specific constraints. The problem setup is as follows: There are N subsequences, each containing a unique set of num...
def can_merge_subsequences(T, test_cases): def can_satisfy_queries(ordering, queries): position = {val: idx for idx, val in enumerate(ordering)} return all(position[a] < position[b] for a, b in queries) results = [] for case in test_cases: N, subsequences, Q, queries = case ...
def test_positive_case(): raw_input = "2\n2\n3 1 2 3\n3 4 5 6\n2\n1 5\n2 4\n3\n2 1 2\n2 3 4\n2 5 6\n4\n1 3\n2 4\n5 1\n3 6" expected_output = ["Yes", "No"] assert solve_problem(raw_input) == expected_output def test_single_subsequence(): raw_input = "1\n1\n3 1 2 3\n1\n1 3" expected_output = ["Y...
[ { "docstring": null, "function_declaration": "def can_merge_subsequences(T, test_cases):", "function_name": "can_merge_subsequences", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(raw_input):", "function_name": "parse_input", ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef can_merge_subsequences(test_cases):\n def topological_sort(graph, in_degree):\n \"\"\"\n Helper ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00003471", "row_id": 3471, "seed_ids": "[9349]" }
0.744319
Taco_3471
I
[ "can_merge_subsequences", "parse_input", "solve_problem" ]
3
[ [ "solve_problem", "can_merge_subsequences" ], [ "solve_problem", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
c3856391d7e23e40ec6ea9d8a8adc0fc663e3f4e
d03fc88845a71d8ca932184604e53dbe7a3949b7
v1.0
instruct
Taco
Taco_3507_I
A spaceship must travel from Earth to a distant planet in another solar system. The spaceship can only travel in straight lines between waypoints in space, and it has a maximum travel capacity per journey due to limited fuel. Your task is to determine if the spaceship can reach the destination planet while respecting i...
import math from collections import deque def can_reach_destination(x1, y1, z1, x2, y2, z2, m, waypoints): def euclidean_distance(p1, p2): return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2 + (p1[2] - p2[2]) ** 2) start = (x1, y1, z1) destination = (x2, y2, z2) waypoints.ins...
import pytest from solution import can_reach_destination def test_single_direct_jump(): assert can_reach_destination(0, 0, 0, 10, 10, 10, 20, []) == "YES" def test_simple_traverse_with_waypoints(): assert can_reach_destination(0, 0, 0, 10, 10, 10, 12, [(6, 6, 6), (8, 8, 8), (15, 15, 15)]) == "YES" def test_i...
[ { "docstring": null, "function_declaration": "def can_reach_destination(x1, y1, z1, x2, y2, z2, m, waypoints):", "function_name": "can_reach_destination", "parameter_list": "(x1, y1, z1, x2, y2, z2, m, waypoints)" }, { "docstring": null, "function_declaration": "def travel_between_waypoi...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef can_reach_destination(coords):\n start, destination, max_distance, additional_waypoints = coords\n x1, y1, z1 = start\n x2, y2, z2 = de...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003507", "row_id": 3507, "seed_ids": "[2225]" }
0.677167
Taco_3507
I
[ "can_reach_destination", "travel_between_waypoints" ]
2
[ [ "travel_between_waypoints", "can_reach_destination" ] ]
1
[]
false
[]
false
pytest
true
[]
true
205a83f9eaff2f6622a04f101393d850aa9556dc
a454a1744cae4da8f967503ed621b23fa38697d4
v1.0
instruct
Taco
Taco_3534_I
Consider a country that consists of several cities connected by bidirectional roads. Each road has a time required to travel, given in hours. A person wants to drive from city 1 to city n. The government has decided to implement a policy where each city is closed for a day on a different day of the week to reduce conge...
import heapq def dijkstra(start, closed_days, adj_list, n): # Initializing distances as infinity for all cities except the start city inf = float('inf') distances = [inf] * (n + 1) distances[start] = 0 # Priority queue to explore the cities pq = [(0, start)] # (time, city) heapq.heapi...
def test_example_case_1(): assert earliest_arrival_time( 5, 6, [1, 2, 3, 4, 5], [(1, 2, 5), (2, 3, 5), (3, 4, 5), (4, 5, 5), (1, 3, 15), (2, 4, 15)] ) == 20 def test_example_case_2(): assert earliest_arrival_time( 3, 2, [1, 7, 7], [(1, 2, 12), (2, 3, 12)]...
[ { "docstring": null, "function_declaration": "def dijkstra(start, closed_days, adj_list, n):", "function_name": "dijkstra", "parameter_list": "(start, closed_days, adj_list, n)" }, { "docstring": null, "function_declaration": "def earliest_arrival_time(n, m, closed_days, roads):", "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 heapq import heappop, heappush\nfrom collections import defaultdict\nimport sys\n\ndef earliest_arrival_time(n, m, closures, roads):\n def next_open(city, ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003534", "row_id": 3534, "seed_ids": "[9760]" }
0.790668
Taco_3534
I
[ "dijkstra", "earliest_arrival_time" ]
2
[ [ "earliest_arrival_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a12c7cd5ba71dfc806eaa5494db3c286eb628cb5
a8cb88cf0cc84ae4709f1ed7c63579aa4705f099
v1.0
instruct
Taco
Taco_3607_I
You are given a directed, weighted graph with `N` nodes and `M` edges. Each node is identified by a unique number from 1 to N. Some nodes are special nodes that you have to travel through exactly once. Your task is to find the shortest path from the starting node to the ending node, traveling exactly once through each ...
import heapq from itertools import permutations def dijkstra(graph, start): """ Applies Dijkstra's algorithm to find the shortest paths from the start node to all other nodes in the given graph. """ N = len(graph) distances = [float('inf')] * N distances[start] = 0 priority_queue = [(0,...
def test_shortest_path_with_special_nodes(): N, M, S = 6, 7, 2 special_nodes = [2, 5] edges = [ (1, 2, 2), (1, 3, 3), (2, 3, 1), (3, 4, 4), (4, 5, 2), (5, 6, 1), (2, 6, 5) ] assert shortest_path_with_special_nodes(N, M, S, special_nodes, edges)...
[ { "docstring": "Applies Dijkstra's algorithm to find the shortest paths from the start\nnode to all other nodes in the given graph.", "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": "Finds the shortest p...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom itertools import permutations\n\ndef shortest_path_through_special_nodes(N, M, S, special_nodes, edges):\n # Create adjacency list for the gr...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00003607", "row_id": 3607, "seed_ids": "[23504]" }
0.808921
Taco_3607
I
[ "dijkstra", "shortest_path_with_special_nodes" ]
2
[ [ "shortest_path_with_special_nodes", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3ffa445ad7e3ecb447125a93768c2d58b66b153a
40f72fdea9d5961724fd7b9c7afd0e9c0cca8706
v1.0
instruct
Taco
Taco_3609_I
Mira and her friend Sam are developing a program for a game competition. As part of the game mechanics, they need to generate a sequence based on certain rules. Specifically, they need to generate a sequence of integers of the form: f(n) = a1 * f(n-1) + a2 * f(n-2) + ... + ak * f(n-k) Where a1, a2, ..., ak are consta...
def matrix_mult(A, B, mod): """Multiplies two matrices A and B under modulo mod.""" return [[sum(x * y for x, y in zip(A_row, B_col)) % mod for B_col in zip(*B)] for A_row in A] def matrix_pow(M, power, mod): """Computes power of a square matrix M under modulo mod.""" size = len(M) # Identity matri...
from solution import nth_term_of_sequence def test_case_1(): assert nth_term_of_sequence(2, 5, [1, 1], [1, 1]) == 5 def test_case_2(): assert nth_term_of_sequence(3, 6, [1, -1, 1], [1, 2, 3]) == 2 def test_case_3(): assert nth_term_of_sequence(1, 4, [2], [3]) == 24 def test_case_4(): assert nth_term...
[ { "docstring": "Multiplies two matrices A and B under modulo mod.", "function_declaration": "def matrix_mult(A, B, mod):", "function_name": "matrix_mult", "parameter_list": "(A, B, mod)" }, { "docstring": "Computes power of a square matrix M under modulo mod.", "function_declaration": "d...
[ 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 matrix_mult(A, B, mod):\n \"\"\"Multiplies two matrices A and B under modulo mod.\"\"\"\n return [[sum(x * y for x, y in zip(A_row, B_col)) % mod for B_c...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00003609", "row_id": 3609, "seed_ids": "[18845]" }
0.721187
Taco_3609
I
[ "matrix_mult", "matrix_pow", "nth_term_of_sequence", "main" ]
4
[ [ "matrix_pow", "matrix_mult" ], [ "nth_term_of_sequence", "matrix_pow" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7269fe272407917654a170b84ad75367b37a2f76
8398dd8756c8d74e1beb0b6b65136548aede439b
v1.0
instruct
Taco
Taco_3639_I
You are given an integer N and a matrix of size N x N with integers, M_ij where 1 ≤ i, j ≤ N. You are required to find the number of distinct magic squares within the given matrix. A magic square is a 3x3 grid in which the sum of every row, column, and both main diagonals is the same. -----Notes----- A magic square is...
def is_magic_square(grid): """ Check if a 3x3 grid is a magic square. """ target_sum = sum(grid[0]) # Sum of the first row as reference # Check rows and columns for i in range(3): if sum(grid[i]) != target_sum: # Check row return False if sum(grid[j][i] for j in ra...
from solution import count_magic_squares, is_magic_square def test_is_magic_square(): # Test a valid magic square grid = [ [4, 3, 8], [9, 5, 1], [2, 7, 6] ] assert is_magic_square(grid) == True # Test an invalid magic square grid = [ [4, 3, 8], [9, 5...
[ { "docstring": "Check if a 3x3 grid is a magic square.", "function_declaration": "def is_magic_square(grid):", "function_name": "is_magic_square", "parameter_list": "(grid)" }, { "docstring": "Count the number of distinct 3x3 magic squares in the given N x N matrix.", "function_declarati...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_magic_square(grid):\n \"\"\"Validate if the given 3x3 grid is a magic square.\"\"\"\n expected_sum = sum(grid[0])\n \n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00003639", "row_id": 3639, "seed_ids": "[23258]" }
0.682984
Taco_3639
I
[ "is_magic_square", "count_magic_squares", "main" ]
3
[ [ "count_magic_squares", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
950ebe8a548e6bf93704162a297218e3bd6ec97b
7704b64c2773fbd467f4163556085c121b892747
v1.0
instruct
Taco
Taco_3663_I
Petya found some meat recipes and decided to cook several dishes. Each dish requires a specific amount of meat, and Petya wants to prepare exactly the quantity that is required for each dish. Moreover, Petya has various pieces of meat, and each piece is labeled with its weight in grams. Petya now wonders if it's possi...
def can_prepare_dishes(required_meat, available_meat): from collections import Counter available_meat_counter = Counter(available_meat) required_meat_counter = Counter(required_meat) for weight, count in required_meat_counter.items(): if available_meat_counter[weight] < count: ...
from solution import check_dishes def test_example_1(): assert check_dishes(3, [300, 500, 700], 5, [200, 100, 500, 300, 700]) == "YES" def test_example_2(): assert check_dishes(2, [400, 500], 3, [100, 200, 300]) == "NO" def test_exact_match(): assert check_dishes(1, [100], 1, [100]) == "YES" def tes...
[ { "docstring": null, "function_declaration": "def can_prepare_dishes(required_meat, available_meat):", "function_name": "can_prepare_dishes", "parameter_list": "(required_meat, available_meat)" }, { "docstring": null, "function_declaration": "def check_dishes(n, dish_requirements, m, mea...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_prepare_all_dishes(dish_requirements, meat_pieces):\n # Sort dish requirements in decreasing order\n dish_requirements.sort(reverse=True)\n # Sort...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00003663", "row_id": 3663, "seed_ids": "[16312]" }
0.743364
Taco_3663
I
[ "can_prepare_dishes", "check_dishes" ]
2
[ [ "check_dishes", "can_prepare_dishes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed02db035ab6feee71d93a1976e6963190061a3b
0ec2dca71ed8a1ba4503b50226551ba5b538db88
v1.0
instruct
Taco
Taco_3669_I
Write a function that takes a list of integers as input and returns a list of the integers that are prime numbers. The function should preserve the original order of the numbers in the input list. A prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. For example, give...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n ** 0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False ...
from solution import filter_primes def test_filter_primes_example_case_1(): assert filter_primes([2, 4, 6, 7, 10, 11, 13]) == [2, 7, 11, 13] def test_filter_primes_example_case_2(): assert filter_primes([1, 3, 5, 6, 8, 9, 10]) == [3, 5] def test_filter_primes_example_case_3(): assert filter_primes([16, 2...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list while preserving the order.", "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 Determine if a number is prime.\n\n Parameters:\n n (int): The number to check.\n\n Returns:\n bool: True if the numb...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003669", "row_id": 3669, "seed_ids": "[5492]" }
0.67937
Taco_3669
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
636eabb2d3e710dc1985c416ba04e8e89291815d
268c0544735ea06761f6d00d490efd1354df0295
v1.0
instruct
Taco
Taco_3670_I
You are given a list of n integers representing the heights of n plants arranged in a row from left to right. One day, the gardener decides to trim some of the plants to make them look symmetrical. You are required to find the minimum height such that the plants can be trimmed to look like a symmetrically increasing se...
def min_height_to_trim(plants): def is_symmetric_with_peak(peak): left = plants[:peak + 1] right = plants[peak:] return left == right[::-1] n = len(plants) max_height = max(plants) for peak in range(n): if is_symmetric_with_peak(peak): return plants[peak]...
from solution import solve def test_example_1(): assert solve(6, [1, 2, 3, 4, 3, 2, 1]) == 4 def test_example_2(): assert solve(6, [1, 5, 4, 3, 2, 1]) == 5 def test_example_3(): assert solve(7, [1, 2, 3, 2, 1, 2, 3]) == 3 def test_single_plant(): assert solve(1, [1]) == 1 def test_two_plants_same_h...
[ { "docstring": null, "function_declaration": "def min_height_to_trim(plants):", "function_name": "min_height_to_trim", "parameter_list": "(plants)" }, { "docstring": null, "function_declaration": "def solve(n, plant_heights):", "function_name": "solve", "parameter_list": "(n, pla...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_peak_height(n, heights):\n \"\"\"\n Returns the minimum height for the plants to form a symmetrically increasing\n and then decreasing sequence.\n...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00003670", "row_id": 3670, "seed_ids": "[11539]" }
0.617509
Taco_3670
I
[ "min_height_to_trim", "solve" ]
2
[ [ "solve", "min_height_to_trim" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8782d3ebd3c14b5427fda7bfb6798f3fbc9f2d8
5755a5c4e1e3a04ed94060c5167a394525524004
v1.0
instruct
Taco
Taco_3698_I
In a certain kingdom, there are several cities connected by a network of bidirectional roads. Each road has an associated cost. The king wants to minimize the travel cost between any two cities. For this, he considers building direct high-speed routes between various cities, which will have zero cost. However, building...
def find_min_high_speed_routes(num_cities, num_roads, roads): from heapq import heappop, heappush from collections import defaultdict def prims_mst(start, adj): mst_edges = [] total_cost = 0 visited = [False] * (num_cities + 1) min_heap = [(0, start, None)] ...
def test_with_example_input(): N = 5 M = 6 roads = [ (1, 2, 10), (1, 3, 20), (2, 3, 5), (2, 4, 15), (3, 5, 25), (4, 5, 10) ] expected = "4\n1 2\n2 3\n2 4\n4 5" assert minimize_travel_cost(N, M, roads) == expected def test_no_roads(): N = 2 ...
[ { "docstring": null, "function_declaration": "def find_min_high_speed_routes(num_cities, num_roads, roads):", "function_name": "find_min_high_speed_routes", "parameter_list": "(num_cities, num_roads, roads)" }, { "docstring": null, "function_declaration": "def format_output(high_speed_ro...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_min_high_speed_routes(num_cities, num_roads, roads):\n from heapq import heappop, heappush\n from collections import defaultdict\n \n def prim...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00003698", "row_id": 3698, "seed_ids": "[23995]" }
0.760295
Taco_3698
I
[ "find_min_high_speed_routes", "format_output", "minimize_travel_cost" ]
3
[ [ "minimize_travel_cost", "find_min_high_speed_routes" ], [ "minimize_travel_cost", "format_output" ] ]
2
[ "format_output" ]
false
[]
false
pytest
false
[]
true
4b6a4140f6b94847d78aa0857bee814cb49c2a35
65a0954a3c666f2309ea8d60feeb4bea5db79e26
v1.0
instruct
Taco
Taco_3794_I
You are given an integer N representing the number of ranges. Each range is defined by two integers, L and R (1 ≤ L ≤ R ≤ 10^9). For each range, print the sum of all prime numbers that lie within that range. Input The first line of input contains a single integer N denoting the number of ranges. Each of the following ...
def sum_of_primes_in_range(L, R): """ Returns the sum of all prime numbers in the range [L, R]. """ def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n...
from solution import sum_of_primes_in_range, sum_of_primes_for_multiple_ranges def test_sum_of_primes_in_range(): assert sum_of_primes_in_range(1, 10) == 17 assert sum_of_primes_in_range(10, 20) == 60 assert sum_of_primes_in_range(22, 29) == 52 # primes are 23, 29 assert sum_of_primes_in_range(30, 30)...
[ { "docstring": "Returns the sum of all prime numbers in the range [L, R].", "function_declaration": "def sum_of_primes_in_range(L, R):", "function_name": "sum_of_primes_in_range", "parameter_list": "(L, R)" }, { "docstring": null, "function_declaration": "def sum_of_primes_for_multiple_r...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef sieve_of_eratosthenes(limit):\n \"\"\"\n Generate list of primes up to limit using the sieve of Eratosthenes.\n \"\"\"\n is_prime = ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00003794", "row_id": 3794, "seed_ids": "[9269]" }
0.626554
Taco_3794
I
[ "sum_of_primes_in_range", "sum_of_primes_for_multiple_ranges" ]
2
[ [ "sum_of_primes_for_multiple_ranges", "sum_of_primes_in_range" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f6abb58dec5f84e4841829eee13ca7b54877bd01
23bc86116b5154374a420ca2cc27426ae426c272
v1.0
instruct
Taco
Taco_3801_I
You are given an array of integers `arr = [a_1, a_2, ..., a_n]`. A subarray is defined as a contiguous segment of the array. The sum of a subarray is defined as the sum of its elements. Your task is to find the sum of the maximum subarray and the sum of the minimum subarray for each test case. For example: * For array...
def max_subarray_sum(arr): """ Finds the maximum subarray sum using Kadane's algorithm. """ max_sum = cur_sum = arr[0] for num in arr[1:]: cur_sum = max(num, cur_sum + num) max_sum = max(max_sum, cur_sum) return max_sum def min_subarray_sum(arr): """ Finds the minimum su...
import pytest from solution import max_subarray_sum, min_subarray_sum, process_test_cases def test_max_subarray_sum(): assert max_subarray_sum([1, -2, 3, 4, -5]) == 7 assert max_subarray_sum([-3, -2, -5, -1]) == -1 assert max_subarray_sum([4, -1, 2, 1, -5, 4]) == 6 def test_min_subarray_sum(): assert ...
[ { "docstring": "Finds the maximum subarray sum using Kadane's algorithm.", "function_declaration": "def max_subarray_sum(arr):", "function_name": "max_subarray_sum", "parameter_list": "(arr)" }, { "docstring": "Finds the minimum subarray sum using a modified version of Kadane's algorithm.", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Returns the sum of the maximum subarray using Kadane's algorithm\n \"\"\"\n max_ending_here = max_so_far = arr[0]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003801", "row_id": 3801, "seed_ids": "[11597]" }
0.827918
Taco_3801
I
[ "max_subarray_sum", "min_subarray_sum", "process_test_cases" ]
3
[ [ "process_test_cases", "max_subarray_sum" ], [ "process_test_cases", "min_subarray_sum" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
13ef6d07972f03f6f235331044924e5de3c7dc88
7e1cdae67fb19e5f690456ac72624428d2bd3cbc
v1.0
instruct
Taco
Taco_3881_I
Baby Ehab loves prime numbers and palindromes. He has an array $a$ of length $n$, and he wants to transform it into a "prime-palindrome array". An array is called prime-palindrome if every element in the array is a prime number and a palindrome. A number is called a palindrome if it reads the same backward as forward,...
def is_prime(num): """Check if a number is a prime.""" if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 ret...
import pytest from solution import min_changes_to_prime_palindrome_array def test_example_1(): n = 5 a = [6, 313, 5, 10, 101] changes, indices = min_changes_to_prime_palindrome_array(n, a) assert changes == 2 assert indices == [1, 4] def test_example_2(): n = 3 a = [2, 3, 7] changes, i...
[ { "docstring": "Check if a number is a prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindr...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Check if a number is a prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 ==...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00003881", "row_id": 3881, "seed_ids": "[17474]" }
0.772256
Taco_3881
I
[ "is_prime", "is_palindrome", "min_changes_to_prime_palindrome_array" ]
3
[ [ "min_changes_to_prime_palindrome_array", "is_palindrome" ], [ "min_changes_to_prime_palindrome_array", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
97f9cee9e11f54d1a17df65bb3428f11be4aff70
57bd94c7ce54a5ef9ffd923f41c332f3aedf195a
v1.0
instruct
Taco
Taco_3930_I
Alex loves investigating prime numbers. One day, he became interested in exploring subsequences of prime numbers in a list. A subsequence is derived from a list by deleting some or no elements without changing the order of the remaining elements. He wants to find the length of the longest subsequence of prime numbers...
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 longest_prime_subsequence_...
from solution import is_prime, longest_prime_subsequence_length def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(17) == True def test_longest_prime_subsequence_length()...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def longest_prime_subsequence_length(nums):", "function_name": "longest_prime_subsequence_length", "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_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00003930", "row_id": 3930, "seed_ids": "[21467]" }
0.678926
Taco_3930
I
[ "is_prime", "longest_prime_subsequence_length" ]
2
[ [ "longest_prime_subsequence_length", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81f2d521a72275c2451fe01ced2159f060dcacfa
439d13d4183d6bedb3590043208915e82f9467fe
v1.0
instruct
Taco
Taco_3935_I
You are given an undirected weighted graph with n vertices and m edges. The graph may contain self-loops and multiple edges between the same pair of vertices. You need to find the minimum spanning tree (MST) of this graph. However, instead of outputting the total weight of the MST, you need to output the edges of the ...
class UnionFind: def __init__(self, n): self.parent = list(range(n)) self.rank = [1] * n def find(self, u): if u != self.parent[u]: self.parent[u] = self.find(self.parent[u]) return self.parent[u] def union(self, u, v): root_u = self.find(u) root...
def test_find_mst_disconnected_graph(): n = 4 m = 2 edges = [ (1, 2, 1), (3, 4, 2) ] assert find_mst(n, m, edges) == "no MST" def test_find_mst_simple_case(): n = 4 m = 5 edges = [ (1, 2, 1), (2, 3, 2), (3, 4, 3), (4, 1, 4), (1, 3,...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [1] * n\n\n def find(self, u):\n if u != self.par...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00003935", "row_id": 3935, "seed_ids": "[22597]" }
0.829921
Taco_3935
I
[ "kruskal_mst", "find_mst" ]
2
[ [ "find_mst", "kruskal_mst" ] ]
1
[]
false
[ "UnionFind" ]
true
pytest
false
[]
true
b3fb724dd97c59bea512a358121081bbe9df4eb6
4e0d42cd90135e0438d61310a74675af2514f4d1
v1.0
instruct
Taco
Taco_3940_I
Given a number N, check whether N is a Circular Prime number or not. Note: A number is called a Circular Prime if all rotations of its digits are prime. Example 1: Input: N = 197 Output: 1 Explanation: 197, 971, and 719 are all prime numbers. Thus, 197 is a Circular Prime and the answer is 1. Example 2: Input: N = 23 O...
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 rotate_number(num): """ Helper function to generate all rotations of the dig...
def test_is_prime(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(4) is False assert is_prime(17) is True assert is_prime(18) is False def test_rotate_number(): assert rotate_number(197) == [197, 971, 719] assert rotate_number(23) == [23, 32] assert rotate_numbe...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Helper function to generate all rotations of the digits of a number.", "function_declaration": "def rot...
[ 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 Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00003940", "row_id": 3940, "seed_ids": "[2544]" }
0.611673
Taco_3940
I
[ "is_prime", "rotate_number", "is_circular_prime" ]
3
[ [ "is_circular_prime", "is_prime" ], [ "is_circular_prime", "rotate_number" ] ]
2
[]
false
[]
false
pytest
false
[]
true
b20c7dd1514f5d871935f3fb456f75c24808eec0
2689b42d639db080e41790e74f169eb4d17decf8
v1.0
instruct
Taco
Taco_4094_I
Given an array of integers, write a program to find the subarray (containing at least one number) which has the largest sum and return the sum. A subarray is a contiguous part of an array. Input: - First line contains an integer number \( t \) (1 ≤ \( t \) ≤ 10), the number of test cases. - Each test case starts with ...
def max_subarray_sum(arr): """ This function takes an array of integers and returns the largest sum of the subarray. Uses Kadane's Algorithm. """ max_ending_here = max_so_far = arr[0] for num in arr[1:]: max_ending_here = max(num, max_ending_here + num) max_so_far = max(max_...
from solution import find_max_subarray_sums, parse_input def test_max_subarray_sum_case1(): input_data = "2\n5\n1 2 -1 2 -3\n4\n-1 -2 -3 -4" test_cases = parse_input(input_data) result = find_max_subarray_sums(test_cases) assert result == [4, -1] def test_max_subarray_sum_case2(): input_data = "1\...
[ { "docstring": "This function takes an array of integers and returns the largest sum of the subarray.\nUses Kadane's Algorithm.", "function_declaration": "def max_subarray_sum(arr):", "function_name": "max_subarray_sum", "parameter_list": "(arr)" }, { "docstring": "This function processes mu...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_subarray_sum(array):\n \"\"\"\n Finds the sum of the subarray with the largest sum.\n \"\"\"\n # Kadane's algorithm to find the maximum subarra...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004094", "row_id": 4094, "seed_ids": "[21370]" }
0.783554
Taco_4094
I
[ "max_subarray_sum", "find_max_subarray_sums", "parse_input" ]
3
[ [ "find_max_subarray_sums", "max_subarray_sum" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
79b2e3d15ff13ca47c1a7b390b3c11b1a951f8a5
3383680be0704fa6593e2037560ffffec875b4b9
v1.0
instruct
Taco
Taco_4111_I
You are working with a collection of words and need to group these words into sets of synonyms. Each set of synonyms will merge all words that can be reached through a direct or indirect connection of synonym pairs. For example, if the pairs are: ("beautiful", "pretty"), ("pretty", "attractive"), ("attractive", "gorge...
from collections import defaultdict 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 xroot != yroot: if rank[xroot] < rank[yroot]: parent[...
from solution import count_synonym_groups def test_example_cases(): assert count_synonym_groups(2, [ (4, [("happy", "cheerful"), ("cheerful", "joyful"), ("sad", "unhappy"), ("unhappy", "downcast")], 5, ["happy", "sad", "joyful", "melancholy", "cheerful"]), (2, [("learn", "teach"), ("teach", "educat...
[ { "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": "from collections import defaultdict\n\ndef find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef uni...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00004111", "row_id": 4111, "seed_ids": "[15846]" }
0.570923
Taco_4111
I
[ "find", "union", "count_synonym_groups" ]
3
[ [ "count_synonym_groups", "find" ], [ "count_synonym_groups", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
3ac1e07d895d7411388beea035da2c8f2d129da7
61221662aa9be6bb271254c678f35c066b658d51
v1.0
instruct
Taco
Taco_4126_I
You are participating in an online coding competition and have been given the following task. The competition system will provide you with a series of strings, and your job is to find out their cumulative special value. A string's special value is calculated by summing up the arithmetic differences between adjacent ch...
def calculate_special_value(s): """ Calculates the special value of a string s. """ special_value = 0 for i in range(len(s) - 1): special_value += abs(ord(s[i+1]) - ord(s[i])) return special_value def cumulative_special_value(n, strings): """ Calculates the cumulative special va...
from solution import calculate_special_value, cumulative_special_value def test_calculate_special_value(): assert calculate_special_value("abc") == 2 assert calculate_special_value("def") == 2 assert calculate_special_value("hij") == 2 assert calculate_special_value("aaa") == 0 assert calculate_spe...
[ { "docstring": "Calculates the special value of a string s.", "function_declaration": "def calculate_special_value(s):", "function_name": "calculate_special_value", "parameter_list": "(s)" }, { "docstring": "Calculates the cumulative special value for a list of n strings.", "function_dec...
[ 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 compute_special_value(strings):\n \"\"\"\n Computes the cumulative special value for a list of strings.\n \n Args:\n - strings: list of strings ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00004126", "row_id": 4126, "seed_ids": "[17154]" }
0.694412
Taco_4126
I
[ "calculate_special_value", "cumulative_special_value" ]
2
[ [ "cumulative_special_value", "calculate_special_value" ] ]
1
[]
false
[]
false
pytest
true
[]
true
408e5c9d6dcfdadaec42f48fb370e56365d77921
865a35576c6abc0d708dc604f92f04d103735fe7
v1.0
instruct
Taco
Taco_4149_I
Alice is trying to create a password for her new online account. She has a list of n lowercase words, where each word consists of alphabetical characters only and has a length between 1 and 10 characters inclusive. She wants to generate a password by concatenating several (at least two) of these words together. However...
from itertools import combinations def is_valid(password): vowels = set("aeiou") has_vowel = any(char in vowels for char in password) has_consonant = any(char not in vowels for char in password) return has_vowel and has_consonant def generate_password(words, k): n = len(words) for length in ra...
def test_generate_password_example1(): assert generate_password(["hello", "world", "otto"], 10) != "-1" def test_generate_password_example2(): assert generate_password(["apple", "banana", "orange", "grape"], 8) != "-1" def test_generate_password_example3(): assert generate_password(["aaaaaa", "bbbbbb"], 2...
[ { "docstring": null, "function_declaration": "def is_valid(password):", "function_name": "is_valid", "parameter_list": "(password)" }, { "docstring": null, "function_declaration": "def generate_password(words, k):", "function_name": "generate_password", "parameter_list": "(words,...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef has_vowel(word):\n vowels = set('aeiou')\n return any(char in vowels for char in word)\n\ndef has_consonant(word):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00004149", "row_id": 4149, "seed_ids": "[19000]" }
0.65078
Taco_4149
I
[ "is_valid", "generate_password" ]
2
[ [ "generate_password", "is_valid" ] ]
1
[]
false
[]
false
pytest
false
[]
true
62bcd31d8794119fa026f71dea8dd1734f66d719
da356008e22c09d6c5b943a41082052c32305ea5
v1.0
instruct
Taco
Taco_4237_I
You are given an array B of N positive integers. You can perform a series of operations on the array - each operation consists of choosing an adjacent pair of elements and reducing the larger number in the pair by the smaller number. This operation is repeated until one of the elements in the pair becomes zero. The rem...
import math from functools import reduce def gcd(a, b): """ Returns the greatest common divisor of a and b. """ while b: a, b = b, a % b return a def gcd_of_array(arr): """ Returns the greatest common divisor of an array of numbers. """ return reduce(gcd, arr) def min_poss...
from solution import min_possible_final_array_sum def test_example_1(): assert min_possible_final_array_sum([6, 10, 15]) == 1 def test_example_2(): assert min_possible_final_array_sum([12, 24, 36]) == 12 def test_example_3(): assert min_possible_final_array_sum([7, 14, 28]) == 7 def test_single_element(...
[ { "docstring": "Returns the greatest common divisor of a and b.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Returns the greatest common divisor of an array of numbers.", "function_declaration": "def gcd_of_array(arr):"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef find_minimum_sum(B):\n \"\"\"\n Finds the minimum possible final array sum after minimizing adjacent pair op...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00004237", "row_id": 4237, "seed_ids": "[4961]" }
0.753424
Taco_4237
I
[ "gcd", "gcd_of_array", "min_possible_final_array_sum" ]
3
[ [ "gcd_of_array", "gcd" ], [ "min_possible_final_array_sum", "gcd_of_array" ] ]
2
[]
false
[]
false
pytest
true
[]
true
797cafba0171faf89b7a4ae8241871dfebe51f5e
aed1b69f5f39edc454c46fffcd0f21bab65d6d98
v1.0
instruct
Taco
Taco_4241_I
You are a software developer tasked with creating an efficient navigation system for a massive library. The library is uniquely arranged in a grid format with rows and columns, each cell holding a unique book. Each cell is identified with its row and column coordinates. A user can traverse the library grid by moving up...
from collections import deque def shortest_path_to_book(grid, start, target, rows, cols): # Directions for Up, Down, Left, Right movements directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # BFS initialization queue = deque([(start[0], start[1], 0)]) # (row, col, distance) visited = set() visit...
def test_shortest_path_to_book(): input_text = """5 5 S.... ..### ..#.T ..... ..... 4 4 S#.T .#.. .#.. .T#S 0 0""" expected_output = """8 -1""" assert library_navigation_system(input_text) == expected_output def test_path_with_no_obstacles(): input_text = """3 3 S.. ... ..T 0 0""" expected_ou...
[ { "docstring": null, "function_declaration": "def shortest_path_to_book(grid, start, target, rows, cols):", "function_name": "shortest_path_to_book", "parameter_list": "(grid, start, target, rows, cols)" }, { "docstring": null, "function_declaration": "def find_start_and_target(grid, row...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_moves_to_target(r, c, grid):\n \"\"\"\n Returns the minimum number of moves required to reach the target book in \n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004241", "row_id": 4241, "seed_ids": "[22432]" }
0.706083
Taco_4241
I
[ "shortest_path_to_book", "find_start_and_target", "process_grids", "library_navigation_system" ]
4
[ [ "library_navigation_system", "process_grids" ], [ "process_grids", "find_start_and_target" ], [ "process_grids", "shortest_path_to_book" ] ]
3
[]
false
[]
false
pytest
false
[]
true
688223a087302c846b953e712a88b76020ec27ce
6e0acde91428663e0da82da907f8d9d9ca380606
v1.0
instruct
Taco
Taco_4255_I
One day, Leha was interested in symmetric strings. A string is considered symmetric if it reads the same forwards and backwards, ignoring spaces, punctuation, and case. For instance, "A man, a plan, a canal, Panama!" and "No 'x' in Nixon" are both considered symmetric strings. Help Leha write a function that determine...
def is_symmetric_string(s): """ Determines if a given string s is symmetric, i.e., reads the same forwards and backwards ignoring spaces, punctuation, and case. """ filtered_chars = [char.lower() for char in s if char.isalnum()] return filtered_chars == filtered_chars[::-1] def symmetric_...
from solution import is_symmetric_string, symmetric_strings def test_is_symmetric_string(): assert is_symmetric_string("A man, a plan, a canal, Panama!") == True assert is_symmetric_string("race a car") == False assert is_symmetric_string("No 'x' in Nixon") == True assert is_symmetric_string("Was it a ...
[ { "docstring": "Determines if a given string s is symmetric, i.e., \nreads the same forwards and backwards ignoring spaces, \npunctuation, and case.", "function_declaration": "def is_symmetric_string(s):", "function_name": "is_symmetric_string", "parameter_list": "(s)" }, { "docstring": "For...
[ 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_symmetric(s):\n \"\"\"\n Returns 'YES' if the string s is symmetric, otherwise 'NO'.\n The string is considered symmetric if it reads the same\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00004255", "row_id": 4255, "seed_ids": "[16300]" }
0.644205
Taco_4255
I
[ "is_symmetric_string", "symmetric_strings" ]
2
[ [ "symmetric_strings", "is_symmetric_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
060cfc592b21835dc1319474971deb4990fffbfc
0d37df0fee1eb31f134a0f7565d4b547fba2200e
v1.0
instruct
Taco
Taco_4257_I
You have been given a list of students and their respective grades. Your task is to find out the average grade for each student, and then assign them to different tiers based on their average grade. Each student has several grades corresponding to different subjects. The average grade of a student is the sum of all th...
def calculate_average_grade(grades): return round(sum(grades) / len(grades)) def determine_tier(average_grade): if average_grade >= 90: return 1 elif average_grade >= 80: return 2 elif average_grade >= 70: return 3 else: return 4 def process_student_grades(n, studen...
from solution import process_student_grades def test_single_student_tier_1(): result = process_student_grades(1, ["Charlie 95 93"]) assert result == ["Charlie: 94 (Tier 1)"] def test_single_student_tier_2(): result = process_student_grades(1, ["Alice 85 90 78"]) assert result == ["Alice: 84 (Tier 2)"]...
[ { "docstring": null, "function_declaration": "def calculate_average_grade(grades):", "function_name": "calculate_average_grade", "parameter_list": "(grades)" }, { "docstring": null, "function_declaration": "def determine_tier(average_grade):", "function_name": "determine_tier", "...
[ 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 calculate_tier(average_grade):\n \"\"\"\n Determines the tier based on the average grade.\n \"\"\"\n if average_grade >= 90:\n return 'Tier ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004257", "row_id": 4257, "seed_ids": "[7046]" }
0.667056
Taco_4257
I
[ "calculate_average_grade", "determine_tier", "process_student_grades" ]
3
[ [ "process_student_grades", "calculate_average_grade" ], [ "process_student_grades", "determine_tier" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ef33e80c0577593095f30969fbcde67462eadb61
0330f937fc7ceb3ecca69c88b21e16443b270b86
v1.0
instruct
Taco
Taco_4421_I
You are given a 2D grid representing a map. Each cell in the grid can either be land (represented by '1') or water (represented by '0'). Your task is to count the number of distinct islands on this map. An island is a group of adjacent lands connected horizontally or vertically only. You may assume that all four edges ...
def num_islands(grid): if not grid: return 0 def dfs(grid, i, j): if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]) or grid[i][j] == '0': return grid[i][j] = '0' # mark as visited dfs(grid, i + 1, j) # down dfs(grid, i - 1, j) # up dfs(grid,...
def test_sample_input_1(): input_str = "3\n4 5\n11000\n11000\n00100\n00011\n4 5\n11010\n11000\n00001\n00001\n3 3\n111\n010\n111\n" expected_output = "3\n3\n1" assert solution(input_str) == expected_output def test_single_cell_land(): input_str = "1\n1 1\n1\n" expected_output = "1" assert soluti...
[ { "docstring": null, "function_declaration": "def num_islands(grid):", "function_name": "num_islands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def count_islands(test_cases):", "function_name": "count_islands", "parameter_list": "(test_cases)" ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def num_islands(grid):\n if not grid:\n return 0\n\n def dfs(grid, i, j):\n if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[0]) or grid[i]...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00004421", "row_id": 4421, "seed_ids": "[18581]" }
0.667521
Taco_4421
I
[ "num_islands", "count_islands", "parse_input", "solution" ]
4
[ [ "count_islands", "num_islands" ], [ "solution", "count_islands" ], [ "solution", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
f5c58b6c14063632cdb7fdb470c5179bc1a022aa
d03cd97b1b784eb56c4ac359940ece34330df023
v1.0
instruct
Taco
Taco_4426_I
You are to design a robotic lawn mower that can navigate a rectangular grid garden. The garden is represented as an MxN grid where each cell can either be passable (denoted by a 1) or impassable (denoted by a 0). The mower can start at any cell in the grid and can move only to adjacent cells either horizontally or vert...
def can_visit_all_passable_cells(grid, visited, x, y, M, N): moves = [(0,1),(1,0),(0,-1),(-1,0)] # right, down, left, up stack = [(x, y)] while stack: cx, cy = stack.pop() if not (0 <= cx < M and 0 <= cy < N) or visited[cx][cy] or grid[cx][cy] == 0: continue visited[cx][c...
from solution import robotic_lawn_mower def test_sample_cases(): input_data = [ (3, 3, [ [1, 1, 1], [1, 0, 1], [1, 1, 1] ]), (4, 4, [ [1, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 1], [0, 1, 1, 1] ]) ] ...
[ { "docstring": null, "function_declaration": "def can_visit_all_passable_cells(grid, visited, x, y, M, N):", "function_name": "can_visit_all_passable_cells", "parameter_list": "(grid, visited, x, y, M, N)" }, { "docstring": null, "function_declaration": "def check_all_cells_visited(visit...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_cover_all_cells(grid, M, N, start_row, start_col):\n visited = [[False for _ in range(N)] for _ in range(M)]\n queue = [(start_row, start_col)]\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004426", "row_id": 4426, "seed_ids": "[7690]" }
0.63953
Taco_4426
I
[ "can_visit_all_passable_cells", "check_all_cells_visited", "find_starting_position", "robotic_lawn_mower" ]
4
[ [ "find_starting_position", "can_visit_all_passable_cells" ], [ "find_starting_position", "check_all_cells_visited" ], [ "robotic_lawn_mower", "find_starting_position" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c68575d6e10a5a98beb3b4c594a03652d517ed18
a0955aa3ddf9e9f1c6fc1bf4f5365f075652ba07
v1.0
instruct
Taco
Taco_4640_I
Tom, a computer science enthusiast, is fascinated by the Fibonacci sequence and Pascal’s triangle. He decides to create a game that combines both concepts. In his game, each number in Pascal’s triangle must be replaced by the corresponding Fibonacci number in the sequence. The Fibonacci sequence is defined as: - F(0) ...
def fibonacci(n, fib_cache): """ Calculate Fibonacci number with memoization and modulo 10^9 + 9 """ MOD = 1000000009 if n not in fib_cache: fib_cache[n] = (fibonacci(n - 1, fib_cache) + fibonacci(n - 2, fib_cache)) % MOD return fib_cache[n] def generate_pascals_triangle(n): """ ...
from solution import modified_pascals_triangle, format_output def test_case_1(): results = modified_pascals_triangle(1, [1]) expected_output = "1" assert format_output(results) == expected_output def test_case_2(): results = modified_pascals_triangle(1, [2]) expected_output = "1\n1 1" assert f...
[ { "docstring": "Calculate Fibonacci number with memoization and modulo 10^9 + 9", "function_declaration": "def fibonacci(n, fib_cache):", "function_name": "fibonacci", "parameter_list": "(n, fib_cache)" }, { "docstring": "Generate Pascal's triangle up to the nth row.", "function_declarat...
[ 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 generate_pascals_triangle(num_rows):\n \"\"\"\n Generates the first num_rows of Pascal's triangle.\n \"\"\"\n triangle = []\n for n in range(num...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00004640", "row_id": 4640, "seed_ids": "[11648]" }
0.557776
Taco_4640
I
[ "fibonacci", "generate_pascals_triangle", "modified_pascals_triangle", "format_output" ]
4
[ [ "modified_pascals_triangle", "fibonacci" ], [ "modified_pascals_triangle", "generate_pascals_triangle" ] ]
2
[ "format_output" ]
false
[]
false
pytest
true
[]
true
626d3bf941e709f24ad6eb1ebb3690d36665ebcf
9fb45eec9913c2c3bcc547804abd6b673a0482f3
v1.0
instruct
Taco
Taco_4645_I
In this task, you are required to write a program to generate all possible unique subsets of an input set of integers. A subset of a set is any collection of elements from the set, including the empty set and the set itself. The subsets of a set should be listed in increasing order of length and, for subsets of the sa...
from itertools import combinations def get_unique_subsets(nums): """ Returns all unique subsets of given list of integers in specified order. """ nums = sorted(nums) result = set() for r in range(len(nums) + 1): for comb in combinations(nums, r): result.add(comb) ...
from solution import get_unique_subsets def test_empty_input(): assert get_unique_subsets([]) == [[]] def test_single_element(): assert get_unique_subsets([1]) == [[], [1]] def test_two_elements(): assert get_unique_subsets([1, 2]) == [[], [1], [2], [1, 2]] def test_duplicates(): assert get_unique_s...
[ { "docstring": "Returns all unique subsets of given list of integers in specified order.", "function_declaration": "def get_unique_subsets(nums):", "function_name": "get_unique_subsets", "parameter_list": "(nums)" }, { "docstring": "Prints all unique subsets of the given input set.", "fu...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef unique_subsets(input_set):\n \"\"\"\n Generates all possible unique subsets of an input set of integers.\n The s...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00004645", "row_id": 4645, "seed_ids": "[6607]" }
0.589173
Taco_4645
I
[ "get_unique_subsets", "unique_subsets" ]
2
[ [ "unique_subsets", "get_unique_subsets" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8194b946c559adde70930cbf8d17e6bd5cc4b1d
cb8de260a70c2713d97ba88252c84cd5e62c82d4
v1.0
instruct
Taco
Taco_4674_I
You are invited to a coding competition where one of the challenges involves finding lucky numbers in a given range. A lucky number is defined as a number that is a multiple of 3 or contains the digit '3' at least once. Write a code that takes two integers, `start` and `end`, and returns a list of all lucky numbers be...
def is_lucky_number(num): """ Check if a number is a lucky number. A lucky number is either a multiple of 3 or contains the digit '3'. """ return num % 3 == 0 or '3' in str(num) def lucky_numbers_in_range(start, end): """ Returns a list of all lucky numbers between `start` and `end` (inclus...
from solution import is_lucky_number, lucky_numbers_in_range def test_is_lucky_number(): assert is_lucky_number(3) == True assert is_lucky_number(6) == True assert is_lucky_number(13) == True assert is_lucky_number(21) == True assert is_lucky_number(22) == False def test_lucky_numbers_in_range_sma...
[ { "docstring": "Check if a number is a lucky number.\nA lucky number is either a multiple of 3 or contains the digit '3'.", "function_declaration": "def is_lucky_number(num):", "function_name": "is_lucky_number", "parameter_list": "(num)" }, { "docstring": "Returns a list of all lucky number...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_lucky_number(num):\n \"\"\"\n Checks if a number is lucky. A number is considered lucky if it is a multiple of 3 or contains the digit '3'.\n \"\"\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004674", "row_id": 4674, "seed_ids": "[22932]" }
0.44914
Taco_4674
I
[ "is_lucky_number", "lucky_numbers_in_range" ]
2
[ [ "lucky_numbers_in_range", "is_lucky_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
00d2f7695402cc8b569badd23a14e25471fff7a7
b647c9564524415aa8d4fbcb8ecdc20d11eace5e
v1.0
instruct
Taco
Taco_4734_I
Alex loves tinkering with number sequences. He recently came across a sequence where each term depends on the previous one, defined by the following rules: For a given positive integer $a_1$ (starting term), the sequence is defined as: * $a_{i+1} = a_i + \text{sum of digits of } a_i$, where $i$ is the index of the ter...
def sum_of_digits(n): """ Returns the sum of the digits of the number n. """ return sum(int(digit) for digit in str(n)) def kth_term_of_sequence(a1, k): """ Returns the k-th term of the sequence where each term depends on the previous one as follows: a_{i+1} = a_i + sum of digits of a_i. ...
from solution import kth_term_of_sequence def test_example_1(): a1 = 10 k = 5 assert kth_term_of_sequence(a1, k) == 25 def test_example_2(): a1 = 123 k = 3 assert kth_term_of_sequence(a1, k) == 141 def test_single_step_sequence(): a1 = 987 k = 1 assert kth_term_of_sequence(a1, k) ...
[ { "docstring": "Returns the sum of the digits of the number n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the k-th term of the sequence where each term depends on the previous one as follows:\na_{i+1...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of a given number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef kth_te...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00004734", "row_id": 4734, "seed_ids": "[4956]" }
0.725606
Taco_4734
I
[ "sum_of_digits", "kth_term_of_sequence" ]
2
[ [ "kth_term_of_sequence", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
27508e5d91f84c4f0bfa8a5c717fbf1207f3fc15
f15ef939be9b55cf81b82f16f2a9cc70f12c077f
v1.0
instruct
Taco
Taco_4775_I
Given an array of integers, find the maximum possible sum of non-adjacent elements. You can choose not to take any elements at all. Input format: The first line of input will contain an integer `T`, denoting the number of test cases. Each test case will be given in two lines: - The first line contains an integer `N`...
def max_non_adjacent_sum(arr): """ Returns the maximum sum of non-adjacent elements in the array `arr`. """ if not arr: return 0 prev_one, prev_two = 0, 0 for num in arr: current = max(prev_one, prev_two + num) prev_two = prev_one prev_one = current ret...
def test_max_non_adjacent_sum(): # Test case with sample input assert max_non_adjacent_sum([3, 2, 7, 10]) == 13 assert max_non_adjacent_sum([3, 2, 5]) == 8 assert max_non_adjacent_sum([1, 2]) == 2 # Test case with negative values assert max_non_adjacent_sum([-1, -2, -3, -4]) == 0 assert max_...
[ { "docstring": "Returns the maximum sum of non-adjacent elements in the array `arr`.", "function_declaration": "def max_non_adjacent_sum(arr):", "function_name": "max_non_adjacent_sum", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", ...
[ 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_non_adjacent_sum(arr):\n \"\"\"\n Returns the maximum possible sum of non-adjacent elements in the array.\n \"\"\"\n if not arr:\n retur...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004775", "row_id": 4775, "seed_ids": "[5656]" }
0.792512
Taco_4775
I
[ "max_non_adjacent_sum", "solve", "parse_input" ]
3
[ [ "parse_input", "solve" ], [ "solve", "max_non_adjacent_sum" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
3d6c97a00639d945bcba251065b48f324373dad0
f2161033e0d232a91d6833163d3b133a77107f11
v1.0
instruct
Taco
Taco_4849_I
A JSON object is represented as a tree with nodes, where each node corresponds to a key within the object. The value at each node can either be a primitive (string, number, boolean, null), an array, or another JSON object. Write a function that, given a JSON object and a key, traverses the tree and returns a list of a...
import json def find_values_by_key(json_obj, target_key): """ Traverses the JSON object and returns a list of all values associated with the given key. """ values = [] def traverse(obj): if isinstance(obj, dict): for key, value in obj.items(): if key == targ...
from solution import get_values_from_json_string def test_single_occurrence(): json_string = '''{ "json": {"name": "John", "age": 30, "postalCode": "10003"}, "key": "postalCode" }''' assert get_values_from_json_string(json_string) == ["1000...
[ { "docstring": "Traverses the JSON object and returns a list of all values associated with the given key.", "function_declaration": "def find_values_by_key(json_obj, target_key):", "function_name": "find_values_by_key", "parameter_list": "(json_obj, target_key)" }, { "docstring": "Parses the...
[ 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 json\n\ndef find_values(json_obj, target_key):\n \"\"\"\n Traverses the JSON object and returns a list of all values associated with the target key.\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00004849", "row_id": 4849, "seed_ids": "[9907]" }
0.569351
Taco_4849
I
[ "find_values_by_key", "get_values_from_json_string" ]
2
[ [ "get_values_from_json_string", "find_values_by_key" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f036e8ac1c86ae6f7e1216d875b25d73122d92f
2e08efbb38752c939b41d0ba076854b852aa6793
v1.0
instruct
Taco
Taco_4853_I
You are given a list of n integers, where each element represents the population of a city. You are also given m bidirectional roads connecting these cities. Each road has a weight, which represents the time it takes to travel between the two cities. The government wants to impose a lockdown in such a way that they ca...
import heapq def dijkstra(start, n, adj): dist = [float('inf')] * n dist[start] = 0 pq = [(0, start)] # priority queue of (distance, node) while pq: d, u = heapq.heappop(pq) if d > dist[u]: continue for v, w in adj[u]: if dist[u] + w < dist[v]: ...
from solution import min_time_to_reach_all_cities def test_case_1(): n = 5 m = 4 populations = [10, 20, 30, 40, 50] roads = [ (1, 2, 3), (1, 3, 2), (2, 4, 4), (3, 5, 1) ] assert min_time_to_reach_all_cities(n, m, populations, roads) == [2, 3, 1, 4, 1] def test_c...
[ { "docstring": null, "function_declaration": "def dijkstra(start, n, adj):", "function_name": "dijkstra", "parameter_list": "(start, n, adj)" }, { "docstring": null, "function_declaration": "def min_time_to_reach_all_cities(n, m, populations, roads):", "function_name": "min_time_to_r...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find_min_travel_times(n, m, populations, roads):\n # Create adjacency list\n graph = {i: [] for i in range(n)}\n for (u, v, w) in road...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00004853", "row_id": 4853, "seed_ids": "[1312]" }
0.789116
Taco_4853
I
[ "dijkstra", "min_time_to_reach_all_cities" ]
2
[ [ "min_time_to_reach_all_cities", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6f014de88edf6884c49ca46b8ad4a58db6f65d37
e0a00490ab3f13fdea64a4707fa3ad247b4387ba
v1.0
instruct
Taco
Taco_4918_I
Write a function `merge_sort` that takes a list of integers and sorts it using the merge sort algorithm. Merge sort divides the input list into two halves, recursively sorts each half, and then merges the two sorted halves to produce the sorted list. You are required to demonstrate the function with the given input. #...
def merge_sort(lst): """ Sorts a list of integers using the merge sort algorithm. """ if len(lst) <= 1: return lst mid = len(lst) // 2 left_half = merge_sort(lst[:mid]) right_half = merge_sort(lst[mid:]) return merge(left_half, right_half) def merge(left, right): "...
from solution import merge_sort def test_merge_sort_with_positive_numbers(): assert merge_sort([34, 7, 23, 32, 5, 62]) == [5, 7, 23, 32, 34, 62] def test_merge_sort_with_mixed_numbers(): assert merge_sort([0, -1, 3, 2, 1, -2]) == [-2, -1, 0, 1, 2, 3] def test_merge_sort_with_duplicates(): assert merge_so...
[ { "docstring": "Sorts a list of integers using the merge sort algorithm.", "function_declaration": "def merge_sort(lst):", "function_name": "merge_sort", "parameter_list": "(lst)" }, { "docstring": "Helper function to merge two sorted lists.", "function_declaration": "def merge(left, rig...
[ 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 merge_sort(lst):\n \"\"\"\n Sorts a list of integers using merge sort algorithm.\n \n :param lst: List of integers to sort\n :return: Sorted lis...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004918", "row_id": 4918, "seed_ids": "[19147]" }
0.704133
Taco_4918
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
258be243cfe6e5a3936bb0dd689533fe28bbdb8b
fb9fd572a52d476331efc600b3666efd93f66d8d
v1.0
instruct
Taco
Taco_4934_I
Given an integer `n`, determine the minimum number of operations required to reduce `n` to 1. You can perform either of the following 3 operations any number of times: 1. If `n` is divisible by 2, divide it by 2. 2. If `n` is divisible by 3, divide it by 3. 3. Subtract 1 from `n`. ----- Input Format ------ - The fi...
def min_operations(n): """ Returns the minimum number of operations required to reduce n to 1. """ dp = [0] * (n + 1) for i in range(2, n + 1): dp[i] = dp[i - 1] + 1 if i % 2 == 0: dp[i] = min(dp[i], dp[i // 2] + 1) if i % 3 == 0: dp[i] = min(dp[i], dp...
from solution import min_operations, min_operations_for_tests, solve def test_min_operations(): assert min_operations(10) == 3 assert min_operations(15) == 4 assert min_operations(6) == 2 assert min_operations(1) == 0 assert min_operations(2) == 1 assert min_operations(3) == 1 def test_min_ope...
[ { "docstring": "Returns the minimum number of operations required to reduce n to 1.", "function_declaration": "def min_operations(n):", "function_name": "min_operations", "parameter_list": "(n)" }, { "docstring": "Given a list of test cases, returns a list of the minimum operations for each ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_operations_to_reduce_n_to_1(n):\n # Create a cache to store the minimum operations for each number up to n\n dp = [0] * (n + 1)\n \n for i in ran...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00004934", "row_id": 4934, "seed_ids": "[1885]" }
0.717866
Taco_4934
I
[ "min_operations", "min_operations_for_tests", "solve" ]
3
[ [ "min_operations_for_tests", "min_operations" ], [ "solve", "min_operations_for_tests" ] ]
2
[]
false
[]
false
pytest
true
[]
true
20ba417cf8600ad8478793dea8756204b8d6c258
5eb2806074caeafd97151f420a472e4edb24fac7
v1.0
instruct
Taco
Taco_4970_I
You are given an image processing system that involves multiple operations on an image represented by a 2D matrix of integers. Each integer corresponds to the brightness of a pixel. One of the most important operations in this system is to rotate the image. A rotation operation consists of rotating the matrix by 90 d...
def rotate_90_clockwise(matrix): """ Rotates the given n x n matrix 90 degrees clockwise. Args: matrix (list of list of int): 2D list representing the matrix. Returns: list of list of int: Rotated matrix. """ return [list(row) for row in zip(*matrix[::-1])] def process_input(i...
from solution import rotate_90_clockwise, process_input, rotate_matrices def test_rotate_90_clockwise(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] rotated = rotate_90_clockwise(matrix) expected = [ [7, 4, 1], [8, 5, 2], [9, 6, 3] ] assert rotat...
[ { "docstring": "Rotates the given n x n matrix 90 degrees clockwise.\n\nArgs:\nmatrix (list of list of int): 2D list representing the matrix.\n\nReturns:\nlist of list of int: Rotated matrix.", "function_declaration": "def rotate_90_clockwise(matrix):", "function_name": "rotate_90_clockwise", "param...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rotate_image(matrix):\n \"\"\"\n Rotates a n x n matrix 90 degrees clockwise.\n \"\"\"\n n = len(matrix)\n # Create a new matrix with the same d...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00004970", "row_id": 4970, "seed_ids": "[3059]" }
0.58861
Taco_4970
I
[ "rotate_90_clockwise", "process_input", "rotate_matrices" ]
3
[ [ "rotate_matrices", "process_input" ], [ "rotate_matrices", "rotate_90_clockwise" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
c44f1779f2033e78ccb70dd5afcfd97b1e72ce6e
0926d805196b1a6eca4bbb3989b5a2fe19392e72
v1.0
instruct
Taco
Taco_4974_I
[Mina and the Lost Treasure]: Mina has discovered a hidden treasure map that guides her through a mysterious cave with a series of connected chambers. Each chamber is represented as a node, and each possible path between chambers is represented as an undirected edge. The chambers are organized in such a way that there ...
from collections import deque def bfs_farthest_node(start, graph, n): queue = deque([(start, 0)]) visited = [False] * (n + 1) visited[start] = True farthest_node = start max_distance = 0 while queue: node, dist = queue.popleft() if dist > max_distance: max_distance ...
from solution import solve def test_case_1(): test_cases = [ (4, [(1, 2), (2, 3), (2, 4)]), (5, [(1, 2), (1, 3), (3, 4), (3, 5)]) ] expected = [2, 3] assert solve(test_cases) == expected def test_case_2(): test_cases = [ (3, [(1, 2), (2, 3)]), (6, [(1, 2), (1, 3), (...
[ { "docstring": null, "function_declaration": "def bfs_farthest_node(start, graph, n):", "function_name": "bfs_farthest_node", "parameter_list": "(start, graph, n)" }, { "docstring": null, "function_declaration": "def find_max_distance(n, edges):", "function_name": "find_max_distance"...
[ 0, 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef bfs_to_find_farthest_node(start, graph):\n \"\"\"\n Perform a BFS to find the farthest node from the starti...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00004974", "row_id": 4974, "seed_ids": "[1552]" }
0.624572
Taco_4974
I
[ "bfs_farthest_node", "find_max_distance", "solve" ]
3
[ [ "find_max_distance", "bfs_farthest_node" ], [ "solve", "find_max_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8cda78ca4acf8ea032dde8a2d97916da955fff9c
07c97548a5ce069f1ceecabf96e573e2bb128ca6
v1.0
instruct
Taco
Taco_5022_I
Write a function that takes a list of integers and returns another list containing only the prime numbers from the input list, in ascending order. For example, given the input: ```python [29, 15, 3, 11, 2, 42, 37, 91] ``` Your function should return: ```python [2, 3, 11, 29, 37] ``` If there are no prime numbers, th...
def is_prime(n): """ Helper function to check if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False ...
from solution import filter_and_sort_primes def test_filter_and_sort_primes_with_mixed_numbers(): assert filter_and_sort_primes([29, 15, 3, 11, 2, 42, 37, 91]) == [2, 3, 11, 29, 37] def test_filter_and_sort_primes_with_no_primes(): assert filter_and_sort_primes([15, 42, 91, 100]) == [] def test_filter_and_so...
[ { "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": "Given a list of integers, return a sorted list containing only the prime numbers.", "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 <= 3:\n ret...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005022", "row_id": 5022, "seed_ids": "[2604]" }
0.725445
Taco_5022
I
[ "is_prime", "filter_and_sort_primes" ]
2
[ [ "filter_and_sort_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b67c91de03ea4079b09970cee6bb791931bfbc99
d5fad4ebff79dccca9f0586f17dc462a874298b8
v1.0
instruct
Taco
Taco_5043_I
In the world of competitive programming, there's a very common scenario where we need to analyze and process numerical data. One particular case involves checking series of numbers for patterns including prime gaps. A prime gap is the difference between two successive prime numbers. A prime number is a number greater ...
def is_prime(num): """ Check if a number is prime. Parameters: num (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return...
from solution import is_prime, smallest_prime_greater_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(17) == True assert is_prime(18) == False def test_smallest_prime_greater_than(): asse...
[ { "docstring": "Check if a number is prime.\n\nParameters:\nnum (int): The number to check.\n\nReturns:\nbool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Find the smal...
[ 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 Check if the given number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005043", "row_id": 5043, "seed_ids": "[24669]" }
0.573497
Taco_5043
I
[ "is_prime", "smallest_prime_greater_than" ]
2
[ [ "smallest_prime_greater_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc5b40600307c4288a80674ec2bf90a171ff77e7
0db2cd99df4c6921ccd598e26113e7c6dcd558b8
v1.0
instruct
Taco
Taco_5132_I
In a town called Techville, there is a unique system of water distribution. The town's reservoirs supply water to the inhabitants through a series of connected pipes. Each pipe has a maximum capacity indicating the highest amount of water it can transport. To ensure efficient water management, the town's authorities wa...
from collections import deque, defaultdict def bfs(capacity, source, sink, parent): visited = set() queue = deque() queue.append(source) visited.add(source) while queue: node = queue.popleft() for adj in capacity[node]: if adj not in visited and capacity[no...
def test_max_flow_example1(): n = 4 m = 5 edges = [ (1, 2, 100), (2, 3, 50), (1, 3, 50), (3, 4, 100), (2, 4, 100), ] assert max_water_flow(n, m, edges) == 150 def test_max_flow_example2(): n = 3 m = 3 edges = [ (1, 2, 20), (1, 3, 1...
[ { "docstring": null, "function_declaration": "def bfs(capacity, source, sink, parent):", "function_name": "bfs", "parameter_list": "(capacity, source, sink, parent)" }, { "docstring": null, "function_declaration": "def edmonds_karp(n, graph, source, sink):", "function_name": "edmonds...
[ 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, defaultdict\n\ndef bfs(source, sink, parent, graph):\n visited = set()\n queue = deque([source])\n visited.add(source)\n \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005132", "row_id": 5132, "seed_ids": "[2164]" }
0.663838
Taco_5132
I
[ "bfs", "edmonds_karp", "max_water_flow" ]
3
[ [ "edmonds_karp", "bfs" ], [ "max_water_flow", "edmonds_karp" ] ]
2
[]
false
[]
false
pytest
false
[]
true
42629c48111d2f115cf934c5979047fb4a290b91
930dd0a2feac6ba43c35a4f021bd1b32fc984cc7
v1.0
instruct
Taco
Taco_5165_I
You are given a special kind of Sudoku problem on an N×N grid, where N is a perfect square. Each entry in the grid is either a number from 1 to N or an empty cell represented by 0. The objective is to complete the grid such that: 1. Each row contains all numbers from 1 to N exactly once. 2. Each column contains all num...
def is_valid(board, num, pos): n = len(board) sqrt_n = int(n**0.5) row, col = pos # Check row for j in range(n): if board[row][j] == num and col != j: return False # Check column for i in range(n): if board[i][col] == num and row != i: return...
import pytest from solution import complete_sudoku def test_example(): grid = [ [1, 0, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, 0] ] result = complete_sudoku(grid) assert result == [ [1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, ...
[ { "docstring": null, "function_declaration": "def is_valid(board, num, pos):", "function_name": "is_valid", "parameter_list": "(board, num, pos)" }, { "docstring": null, "function_declaration": "def find_empty(board):", "function_name": "find_empty", "parameter_list": "(board)" ...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, num, pos):\n n = len(board)\n sqrt_n = int(n**0.5)\n row, col = pos\n \n # Check row\n for j in range(n):\n if board[r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00005165", "row_id": 5165, "seed_ids": "[24361]" }
0.638844
Taco_5165
I
[ "is_valid", "find_empty", "solve_sudoku", "complete_sudoku" ]
4
[ [ "complete_sudoku", "solve_sudoku" ], [ "solve_sudoku", "find_empty" ], [ "solve_sudoku", "is_valid" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8830febb24b2a6997daef8808518a8347115b826
e02ef77412f19f08229d14ca5cd2a6f485faa008
v1.0
instruct
Taco
Taco_5198_I
In a small village, there is a peculiar game that the villagers love to play during the harvest festival. The game involves a special type of garden, which is essentially a square grid of size NxN. Each cell in the grid either contains a plant (denoted by 1) or is empty (denoted by 0). The objective of the game is to i...
def largest_rectangle_in_histogram(heights): stack = [] max_area = 0 index = 0 while index < len(heights): if not stack or heights[stack[-1]] <= heights[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (he...
def test_largest_rectangular_area(): assert find_largest_rectangular_area(5, [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0], [1, 1, 1, 0, 0] ]) == 6 assert find_largest_rectangular_area(3, [ [1, 1, 1], [1, 1, 1], [1, 1, 1...
[ { "docstring": null, "function_declaration": "def largest_rectangle_in_histogram(heights):", "function_name": "largest_rectangle_in_histogram", "parameter_list": "(heights)" }, { "docstring": null, "function_declaration": "def largest_rectangle_area(matrix):", "function_name": "large...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(grid):\n if not grid or not grid[0]:\n return 0\n\n N = len(grid)\n max_area = 0\n heights = [0] * (N + 1)\n\n for row i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005198", "row_id": 5198, "seed_ids": "[21059]" }
0.640229
Taco_5198
I
[ "largest_rectangle_in_histogram", "largest_rectangle_area", "find_largest_rectangular_area" ]
3
[ [ "find_largest_rectangular_area", "largest_rectangle_area" ], [ "largest_rectangle_area", "largest_rectangle_in_histogram" ] ]
2
[]
false
[]
false
pytest
false
[]
true
b1a10bd86154f6cdf019eac65efe6b3891091486
bb7e303f771cf44f3f500270bcef825fba42bcec
v1.0
instruct
Taco
Taco_5202_I
In a competitive coding environment, developers often encounter scenarios where they need to efficiently manage and manipulate data structures. One such common task is related to managing intervals. Consider the following problem where intervals need to be dynamically merged based on the given operations. ### Problem ...
def merge_intervals(intervals): """ Function to merge overlapping intervals. Args: intervals (List[Tuple[int, int]]): List of intervals [start, end] Returns: List[Tuple[int, int]]: List of merged intervals in ascending order of start point """ if not intervals: return [] # ...
from solution import merge_intervals_from_operations def test_single_interval(): assert merge_intervals_from_operations(1, [(1, 3)]) == [(1, 3)] def test_no_overlap(): assert merge_intervals_from_operations(2, [(1, 2), (3, 4)]) == [(1, 2), (3, 4)] def test_complete_overlap(): assert merge_intervals_from_...
[ { "docstring": "Function to merge overlapping intervals.\nArgs:\nintervals (List[Tuple[int, int]]): List of intervals [start, end]\n\nReturns:\nList[Tuple[int, int]]: List of merged intervals in ascending order of start point", "function_declaration": "def merge_intervals(intervals):", "function_name": ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_intervals(intervals):\n \"\"\"\n Function to merge overlapping intervals.\n Args:\n intervals (List[Tuple[int, int]]): List of intervals [sta...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00005202", "row_id": 5202, "seed_ids": "[9679]" }
0.636396
Taco_5202
I
[ "merge_intervals", "merge_intervals_from_operations" ]
2
[ [ "merge_intervals_from_operations", "merge_intervals" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ccdbba095c07625aac02aa22a28cbf6616f6c595
dedad3865a3398d284e90ad04e59f2c74eb746cf
v1.0
instruct
Taco
Taco_5266_I
Lena is learning about graphs and has a set of cities connected by bidirectional roads. There are `n` cities and `m` roads. Each road has a travel time associated with it. Lena's goal is to determine the shortest travel time between each pair of cities using a specific algorithm. Your task is to implement an algorithm...
def floyd_warshall(n, roads): """ Computes the shortest travel time between each pair of cities using the Floyd-Warshall algorithm. Parameters: n (int): number of cities roads (list of tuples): list of roads, where each road is represented as a tuple (u, v, w) Returns: list of list...
from solution import shortest_travel_times def test_example_1(): n = 4 m = 4 roads = [(1, 2, 5), (2, 3, 10), (1, 3, 9), (3, 4, 2)] result = shortest_travel_times(n, m, roads) expected = [ [0, 5, 9, 11], [5, 0, 10, 12], [9, 10, 0, 2], [11, 12, 2, 0], ] assert ...
[ { "docstring": "Computes the shortest travel time between each pair of cities using the Floyd-Warshall algorithm.\n\nParameters:\nn (int): number of cities\nroads (list of tuples): list of roads, where each road is represented as a tuple (u, v, w)\n\nReturns:\nlist of lists: a distance matrix where entry (i, j)...
[ 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 floyd_warshall(n, m, roads):\n # Initialize the distance matrix with \"infinity\"\n inf = float('inf')\n dist = [[inf if i != j else 0 for j in range(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00005266", "row_id": 5266, "seed_ids": "[14167]" }
0.81338
Taco_5266
I
[ "floyd_warshall", "shortest_travel_times" ]
2
[ [ "shortest_travel_times", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b4df5ae4284751406f41efa69501d37c06e57375
612e3e5c5f4a506de7c6868306ea919fedf7a18e
v1.0
instruct
Taco
Taco_5323_I
Amusement Park Rescue Mission The Amusement Park Corporation has built a large amusement park consisting of various attractions connected by walkways. For safety and convenience, they are planning a rescue mission protocol that routes rescue teams efficiently to any distress call location in the park. The amusement p...
import heapq import sys INF = float('inf') def dijkstra(n, graph): """ Computes the shortest time required to reach each attraction from the command center using Dijkstra's algorithm. Parameters: n (int): Number of attractions graph (dict): Adjacency list representation of graph where key is...
def test_case_1(): test_cases = [ (5, 6, [(1, 2, 10), (1, 3, 20), (2, 4, 15), (2, 3, 35), (3, 5, 30), (4, 5, 30)]) ] expected_output = [[10, 20, 25, 50]] assert amusement_park_rescue(test_cases) == expected_output def test_case_2(): test_cases = [ (4, 4, [(1, 2, 5), (2, 3, 10), (3, ...
[ { "docstring": "Computes the shortest time required to reach each attraction from \nthe command center using Dijkstra's algorithm.\n\nParameters:\nn (int): Number of attractions\ngraph (dict): Adjacency list representation of graph where key is \n the node and value is a list of tuples (neighbor, w...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\n\nINF = float('inf')\n\ndef dijkstra(n, graph):\n \"\"\"\n Computes the shortest time required to reach each attraction from \n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00005323", "row_id": 5323, "seed_ids": "[23581]" }
0.686965
Taco_5323
I
[ "dijkstra", "amusement_park_rescue" ]
2
[ [ "amusement_park_rescue", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7d52394b180ec5d415687432615ded6fd8e04675
fe48a74a633f5722d10d6a2b283ab1309a348e8e
v1.0
instruct
Taco
Taco_5336_I
A team of software developers is working on a project with a specific style guide for variable names. The style guide has the following rules: 1. Variable names should be in CamelCase. 2. All variable names must start with a lowercase letter. 3. Each subsequent word in the variable name must begin with an uppercase let...
def snake_to_camel(snake_str): """ Converts a snake_case variable name to CamelCase following the specific style guide rules. """ components = snake_str.split('_') return components[0] + ''.join(x.title() for x in components[1:]) def convert_snake_to_camel(n, variable_names): camel_case_names =...
from solution import snake_to_camel, convert_snake_to_camel def test_snake_to_camel(): assert snake_to_camel("hello_world") == "helloWorld" assert snake_to_camel("this_is_camel_case") == "thisIsCamelCase" assert snake_to_camel("convert_to_camel_case") == "convertToCamelCase" assert snake_to_camel("sing...
[ { "docstring": "Converts a snake_case variable name to CamelCase following the specific style guide rules.", "function_declaration": "def snake_to_camel(snake_str):", "function_name": "snake_to_camel", "parameter_list": "(snake_str)" }, { "docstring": null, "function_declaration": "def c...
[ 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 convert_to_camel_case(snake_str):\n \"\"\"\n Converts a snake_case string to camelCase format.\n \n Parameters:\n snake_str (str): A variable na...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005336", "row_id": 5336, "seed_ids": "[6697]" }
0.558179
Taco_5336
I
[ "snake_to_camel", "convert_snake_to_camel" ]
2
[ [ "convert_snake_to_camel", "snake_to_camel" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6ea1e208072303cd026bbc6979c52d6475bf1018
9efe5a02739ba2fc35863b1ff7d85391cf25a6ca
v1.0
instruct
Taco
Taco_5364_I
You are given an array of integers. Determine if there exists a sub-sequence of the array whose sum is a prime number. Input: The first line contains a single integer N, the number of elements in the array. The next line contains N space-separated integers denoting the elements of the array. Output: Print "YES" if ...
from itertools import combinations def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def has_prime_sum_subsequence(n, arr): for r in range(1, n + 1): for subseq in combinations(arr, r): i...
from solution import has_prime_sum_subsequence def test_example(): assert has_prime_sum_subsequence(3, [1, 3, 4]) == "YES" def test_all_non_prime(): assert has_prime_sum_subsequence(3, [6, 8, 10]) == "NO" def test_single_prime_element(): assert has_prime_sum_subsequence(1, [11]) == "YES" def test_all_el...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def has_prime_sum_subsequence(n, arr):", "function_name": "has_prime_sum_subsequence", "parameter_list": "(n, arr...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef is_prime(n):\n \"\"\"Check if a given number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00005364", "row_id": 5364, "seed_ids": "[6290]" }
0.654612
Taco_5364
I
[ "is_prime", "has_prime_sum_subsequence" ]
2
[ [ "has_prime_sum_subsequence", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed8b732baecaa1246984b7dd5a5976d62f4f5df2
63fc08d7f3f06bef1ac23711c700dd80abf87785
v1.0
instruct
Taco
Taco_5400_I
You are given a list of $n$ integers. Your task is to reorder it into a permutation such that after reordering, for every position $i$ (1-based index) in the new list, the greatest common divisor (GCD) of the number at position $i$ and the number at position $i + 1$ is greater than 1. If no such reordering is possible,...
from math import gcd from itertools import permutations def gcd_pair(a, b): """Helper function to check gcd > 1 for a pair""" return gcd(a, b) > 1 def reorder_list(n, lst): """ Reorder list such that every consecutive pair of numbers has a GCD > 1 """ for perm in permutations(lst): val...
from solution import list_reorder_response def test_example_1(): result = list_reorder_response(4, [4, 6, 2, 3]) assert result.startswith("YES") def test_example_2(): assert list_reorder_response(3, [2, 5, 7]) == "NO" def test_single_pair_success(): result = list_reorder_response(2, [4, 6]) asser...
[ { "docstring": "Helper function to check gcd > 1 for a pair", "function_declaration": "def gcd_pair(a, b):", "function_name": "gcd_pair", "parameter_list": "(a, b)" }, { "docstring": "Reorder list such that every consecutive pair of numbers has a GCD > 1", "function_declaration": "def re...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom itertools import permutations\n\ndef reorder_with_gcd_conditions(n, array):\n \"\"\"\n Reorders the list such that for every posit...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00005400", "row_id": 5400, "seed_ids": "[8359]" }
0.684178
Taco_5400
I
[ "gcd_pair", "reorder_list", "list_reorder_response" ]
3
[ [ "list_reorder_response", "reorder_list" ], [ "reorder_list", "gcd_pair" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7119d7ec6dd3cb5320634c2be0613a5f3134fa38
4bd176508812856325370bae5cd918364de5abb3