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_76668_I
You are given a list of integers. For each integer, determine how many digits are even. Input N: number of inputs N ≤ 100 then N lines with input X, where 0 ≤ X ≤ 10^9 Output The output for the corresponding input X Example Input: 4 123456 7890 13579 24680 Output: 3 2 0 5 Explanation: In 123456, the even digit...
def count_even_digits(n): """ Given an integer n, return the count of even digits in it. """ even_digits = {'0', '2', '4', '6', '8'} count = 0 for digit in str(n): if digit in even_digits: count += 1 return count def process_numbers(numbers): """ Process a list o...
from solution import count_even_digits, process_numbers def test_count_even_digits(): assert count_even_digits(123456) == 3 assert count_even_digits(7890) == 2 assert count_even_digits(13579) == 0 assert count_even_digits(24680) == 5 assert count_even_digits(0) == 1 assert count_even_digits(222...
[ { "docstring": "Given an integer n, return the count of even digits in it.", "function_declaration": "def count_even_digits(n):", "function_name": "count_even_digits", "parameter_list": "(n)" }, { "docstring": "Process a list of numbers and return a list of counts of even digits for each num...
[ 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 count_even_digits(n):\n \"\"\"\n Returns the number of even digits in the integer n.\n \"\"\"\n even_digits = {'0', '2', '4', '6', '8'}\n count ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076668", "row_id": 76668, "seed_ids": "[21540]" }
0.643002
Taco_76668
I
[ "count_even_digits", "process_numbers" ]
2
[ [ "process_numbers", "count_even_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
789312513106ab93e031328811fb1b4f058690ce
3b87bd8e0f2303c3c251126e92d8edd513487b99
v1.0
instruct
Taco
Taco_76694_I
Sarah is organizing a dinner party and wants to create the most diverse menu possible with the ingredients available. She has a list of unique ingredients and a list of dishes, where each dish requires a specific set of ingredients. Each ingredient can only be used in one dish, and each dish can only be created if all ...
def max_dishes(n, m, ingredients, dishes): """ Returns the maximum number of dishes that can be made given available ingredients and recipes. """ from itertools import combinations ingredient_set = set(ingredients) valid_dishes = [] # Filter dishes that have ingredients present in the ingr...
import pytest from solution import dinner_party_solution def test_example_case(): n = 5 m = 3 ingredients_list = [ "tomato", "cheese", "lettuce", "bread", "chicken" ] dishes_list = [ "2 tomato cheese", "2 bread cheese", "3 chicken ...
[ { "docstring": "Returns the maximum number of dishes that can be made given available ingredients and recipes.", "function_declaration": "def max_dishes(n, m, ingredients, dishes):", "function_name": "max_dishes", "parameter_list": "(n, m, ingredients, dishes)" }, { "docstring": null, "f...
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_dishes(n, m, ingredients, dishes):\n from itertools import combinations\n\n # Function to check if all ingredients of a dish are available in remaini...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00076694", "row_id": 76694, "seed_ids": "[16264]" }
0.75947
Taco_76694
I
[ "max_dishes", "dinner_party_solution" ]
2
[ [ "dinner_party_solution", "max_dishes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
935cfa48a0b92e6a606fe8129ff3b42908299acb
34ee7ae298c7829ea55a2d63dac4e8a902ecc049
v1.0
instruct
Taco
Taco_76716_I
Po has mastered the art of gathering the most delicious dumplings and now must distribute his dumplings among the Furious Five as evenly as possible. Given $N$ plates of dumplings with deliciousness values $A_1, A_2, \ldots, A_N$, Po wants to distribute the dumplings into $K$ groups such that the variance in the sum of...
def can_divide_into_k_groups(max_sum, N, K, A): current_sum = 0 groups_formed = 1 for i in range(N): if A[i] > max_sum: return False if current_sum + A[i] > max_sum: groups_formed += 1 current_sum = A[i] if groups_formed > K: ...
def test_min_max_sum_dumplings_single_case_1(): T = 1 test_cases = [ ((5, 2), [1, 2, 3, 4, 5]) ] assert min_max_sum_dumplings(T, test_cases) == [9] def test_min_max_sum_dumplings_single_case_2(): T = 1 test_cases = [ ((4, 3), [10, 20, 30, 40]) ] assert min_max_sum_dumpli...
[ { "docstring": null, "function_declaration": "def can_divide_into_k_groups(max_sum, N, K, A):", "function_name": "can_divide_into_k_groups", "parameter_list": "(max_sum, N, K, A)" }, { "docstring": null, "function_declaration": "def min_max_sum_dumplings(T, test_cases):", "function_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 can_divide_into_k_groups(max_sum, N, K, A):\n current_sum = 0\n groups_formed = 1\n \n for i in range(N):\n if A[i] > max_sum:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076716", "row_id": 76716, "seed_ids": "[4656]" }
0.69099
Taco_76716
I
[ "can_divide_into_k_groups", "min_max_sum_dumplings" ]
2
[ [ "min_max_sum_dumplings", "can_divide_into_k_groups" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8c28b749155f38a5dc0e8368b61bd917d3f8b945
446695bf1d7982ffcce74c77f7e59c451d74a9d2
v1.0
instruct
Taco
Taco_76725_I
You are given a list of social media posts, where each post contains a series of hashtags. A hashtag is defined as any contiguous word starting with the '#' symbol. Your task is to identify and rank the hashtags by their popularity. The popularity of a hashtag is determined by the number of posts it appears in, not by ...
def extract_hashtags(posts): """ Extracts and ranks hashtags by their popularity according to the rules provided. """ from collections import defaultdict, Counter hashtag_post_count = defaultdict(int) hashtag_total_count = Counter() for post in posts: hashtags_in_post = set() # to...
from solution import get_sorted_hashtags def test_single_post_single_hashtag(): posts = ["#test"] assert get_sorted_hashtags(posts) == ["#test"] def test_multiple_posts_same_hashtag(): posts = ["#test", "Another post with #test"] assert get_sorted_hashtags(posts) == ["#test"] def test_posts_with_diff...
[ { "docstring": "Extracts and ranks hashtags by their popularity according to the rules provided.", "function_declaration": "def extract_hashtags(posts):", "function_name": "extract_hashtags", "parameter_list": "(posts)" }, { "docstring": "Given a list of social media posts, extract and retur...
[ 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 re\nfrom collections import defaultdict\n\ndef extract_and_rank_hashtags(n, posts):\n hashtag_posts_count = defaultdict(set)\n hashtag_total_count = d...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076725", "row_id": 76725, "seed_ids": "[12979]" }
0.570085
Taco_76725
I
[ "extract_hashtags", "get_sorted_hashtags" ]
2
[ [ "get_sorted_hashtags", "extract_hashtags" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a9257588840745dc6d69ed3afcf52d2459cbafb
2d95db15788e8dc129efb8a30eacba43e281e333
v1.0
instruct
Taco
Taco_76745_I
Given a string of lowercase letters, you have to perform the following operation until you are left with no characters in the string: 1. Find the length of the longest prefix which is also a suffix of the string (excluding the entire string itself). 2. Remove this longest prefix from the string to form a new string. 3....
def longest_prefix_suffix(s): """ Finds the longest prefix which is also a suffix. """ n = len(s) lps = [0] * n j = 0 i = 1 while i < n: if s[i] == s[j]: j += 1 lps[i] = j i += 1 else: if j != 0: j = lps...
from solution import process_string, final_string_lengths def test_process_string(): assert process_string("abxabx") == 0 assert process_string("abcdef") == 0 assert process_string("xyzxyzxyz") == 0 assert process_string("aaaa") == 0 assert process_string("ababab") == 0 def test_final_string_lengt...
[ { "docstring": "Finds the longest prefix which is also a suffix.", "function_declaration": "def longest_prefix_suffix(s):", "function_name": "longest_prefix_suffix", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def process_string(s):", "function_name": "pr...
[ 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_longest_prefix_suffix(s):\n n = len(s)\n lps = [0]*n\n length = 0 \n i = 1\n \n while i < n:\n if s[i] == s[length]:\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00076745", "row_id": 76745, "seed_ids": "[4524]" }
0.787629
Taco_76745
I
[ "longest_prefix_suffix", "process_string", "final_string_lengths" ]
3
[ [ "final_string_lengths", "process_string" ], [ "process_string", "longest_prefix_suffix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fb351dd53b671ec97b6430fa49edbc0a403c0f05
6a5eb4d232d1192d6173d3e47b772592d41ee299
v1.0
instruct
Taco
Taco_76763_I
A city has a system of one-way streets. Each street connects two different intersections in one direction. The city planners are concerned with ensuring that emergency vehicles can reach every intersection from a central station. To ensure this, they want to make sure that the street network forms a strongly connected ...
from collections import defaultdict, deque def strongly_connected(n, m, streets): # Create adjacency list for the graph and its transpose graph = defaultdict(list) reverse_graph = defaultdict(list) for u, v in streets: graph[u].append(v) reverse_graph[v].append(u) def bfs(...
from solution import solution def test_example_1(): input_str = "4 4\n1 2\n2 3\n3 4\n4 1" assert solution(input_str) == 0 def test_example_2(): input_str = "4 2\n1 2\n3 4" assert solution(input_str) == 2 def test_single_node(): input_str = "1 0" assert solution(input_str) == 0 def test_disco...
[ { "docstring": null, "function_declaration": "def strongly_connected(n, m, streets):", "function_name": "strongly_connected", "parameter_list": "(n, m, streets)" }, { "docstring": null, "function_declaration": "def process_input(input_str):", "function_name": "process_input", "pa...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef is_strongly_connected(n, streets):\n def bfs(start, adj_list):\n visited = set()\n queue = deque...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00076763", "row_id": 76763, "seed_ids": "[1409]" }
0.653885
Taco_76763
I
[ "strongly_connected", "process_input", "solution" ]
3
[ [ "solution", "process_input" ], [ "solution", "strongly_connected" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
0468330f9b43e6465d000c23c68fb823c06be42b
eb6129fa1cc2731dfe1501dcca9d4d15a1eb3d8d
v1.0
instruct
Taco
Taco_76766_I
You are a specialist in urban development working on a new project for the city of Logiville. The city is planned on an $n$-by-$m$ grid, where each cell represents a building lot. Some lots are already built-up and cannot be changed, while other lots are available for construction. Your task is to design a new public ...
def largest_park_area(matrix): if not matrix or not matrix[0]: return 0 n, m = len(matrix), len(matrix[0]) max_area = 0 heights = [0] * m for i in range(n): for j in range(m): if matrix[i][j] == 'A': heights[j] += 1 else: ...
def test_largest_park_small_grid(): matrix = [ ['A', 'B'], ['B', 'A'] ] assert largest_park_area(matrix) == 1 def test_largest_park_single_line(): matrix = [ ['A', 'A', 'A', 'A'], ['A', 'B', 'A', 'A'] ] assert largest_park_area(matrix) == 4 def test_largest_park...
[ { "docstring": null, "function_declaration": "def largest_park_area(matrix):", "function_name": "largest_park_area", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def max_histogram_area(heights):", "function_name": "max_histogram_area", "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 maximalRectangle(grid):\n if not grid:\n return 0\n \n n = len(grid)\n m = len(grid[0])\n max_area = 0\n heights = [0] * (m + 1)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076766", "row_id": 76766, "seed_ids": "[23438]" }
0.595286
Taco_76766
I
[ "largest_park_area", "max_histogram_area" ]
2
[ [ "largest_park_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b70f6f0bbd019f3a3c2d84010f576b08b3d619fa
666cefd419135368cae11e437aa9387f41919e36
v1.0
instruct
Taco
Taco_76772_I
Little Zooey is fascinated by patterns and sequences. She loves creating new sequences from existing ones by applying specific rules repeatedly. Here's a sequence transformation challenge she has devised. You are given a sequence of `n` integers `a1, a2, ..., an` and `m` transformation rules. Each transformation rule ...
def apply_transformation(n, m, sequence, transformations): for transformation in transformations: l, r, k = transformation for i in range(l-1, r): sequence[i] += k return sequence def final_sequence(n, m, sequence, transformations): return apply_transformation(n, m, sequence, tr...
from solution import final_sequence def test_final_sequence_1(): n = 5 m = 3 sequence = [1, 2, 3, 4, 5] transformations = [(1, 3, 2), (2, 4, -1), (3, 5, 3)] assert final_sequence(n, m, sequence, transformations) == [3, 3, 7, 6, 8] def test_final_sequence_2(): n = 4 m = 2 sequence = [10...
[ { "docstring": null, "function_declaration": "def apply_transformation(n, m, sequence, transformations):", "function_name": "apply_transformation", "parameter_list": "(n, m, sequence, transformations)" }, { "docstring": null, "function_declaration": "def final_sequence(n, m, sequence, tr...
[ 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 apply_transformations(n, m, sequence, rules):\n # Apply each rule to the sequence\n for rule in rules:\n l, r, k = rule\n for i in range(l-...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076772", "row_id": 76772, "seed_ids": "[13902]" }
0.642109
Taco_76772
I
[ "apply_transformation", "final_sequence" ]
2
[ [ "final_sequence", "apply_transformation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bb1bce3f9ddb86d461be19d8957ae92cfec30384
7d269631a23586770391f7b7d5b28ba205f7a817
v1.0
instruct
Taco
Taco_76780_I
Alice and Bob are playing a game using a list of positive integers. Alice starts by picking any two distinct integers, and replaces them with their greatest common divisor (GCD). Bob then takes his turn, picking any two distinct integers from the list and replacing them with their least common multiple (LCM). They alte...
from math import gcd from functools import reduce def find_gcd(a, b): """Return the GCD of a and b.""" return gcd(a, b) def find_lcm(a, b): """Return the LCM of a and b.""" return a * b // gcd(a, b) def alice_bob_game(n, arr): # Alice's turn -> find GCD of all elements gcd_all = reduce(find_g...
from solution import find_gcd, find_lcm, alice_bob_game, process_game def test_find_gcd(): assert find_gcd(6, 9) == 3 assert find_gcd(12, 15) == 3 assert find_gcd(17, 19) == 1 def test_find_lcm(): assert find_lcm(6, 9) == 18 assert find_lcm(12, 15) == 60 assert find_lcm(17, 19) == 323 def tes...
[ { "docstring": "Return the GCD of a and b.", "function_declaration": "def find_gcd(a, b):", "function_name": "find_gcd", "parameter_list": "(a, b)" }, { "docstring": "Return the LCM of a and b.", "function_declaration": "def find_lcm(a, b):", "function_name": "find_lcm", "paramet...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom functools import reduce\n\ndef find_gcd(a, b):\n \"\"\"Return the GCD of a and b.\"\"\"\n return gcd(a, b)\n\ndef find_lcm(a, b):\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076780", "row_id": 76780, "seed_ids": "[18087]" }
0.714221
Taco_76780
I
[ "find_gcd", "find_lcm", "alice_bob_game", "process_game", "game_from_input" ]
5
[ [ "alice_bob_game", "find_gcd" ], [ "game_from_input", "process_game" ], [ "process_game", "alice_bob_game" ] ]
3
[]
false
[]
false
pytest
true
[]
true
3636a460b9c6179d3a702dc7c1ebf1efe93129fd
5880d3cf604429840e22674fa27e0f62e00d1b3b
v1.0
instruct
Taco
Taco_76784_I
You are given a rectangular grid with R rows and C columns. Each cell in the grid is either empty (denoted by '.') or contains an obstacle (denoted by '#'). Alice and Bob are playing a game in which they take turns moving. Alice starts the game. - In her turn, Alice can move to any empty cell that is directly above, ...
from collections import deque def bfs(grid, start, target): """ Performs breadth-first search to find the shortest path from start to target. """ R, C = len(grid), len(grid[0]) visited = [[False] * C for _ in range(R)] queue = deque([(start[0], start[1], 0)]) # (row, col, distance) visited...
def test_case_1(): R = 3 C = 3 grid = [ ".#.", ".#.", "..#" ] assert solve(R, C, grid) == "Draw" def test_case_2(): R = 2 C = 2 grid = [ "..", "#." ] assert solve(R, C, grid) == "Alice" def test_case_3(): R = 2 C = 2 grid = [ ...
[ { "docstring": "Performs breadth-first search to find the shortest path from start to target.", "function_declaration": "def bfs(grid, start, target):", "function_name": "bfs", "parameter_list": "(grid, start, target)" }, { "docstring": null, "function_declaration": "def solve(R, C, grid...
[ 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": "from collections import deque\n\ndef bfs(grid, start, target):\n R, C = len(grid), len(grid[0])\n queue = deque([start])\n visited = set([start])\n \n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00076784", "row_id": 76784, "seed_ids": "[14076]" }
0.798892
Taco_76784
I
[ "bfs", "solve", "game_outcome" ]
3
[ [ "game_outcome", "solve" ], [ "solve", "bfs" ] ]
2
[]
false
[]
false
pytest
false
[]
true
4488a6535ebfb7aacdf83d6d7a6498b5574280fa
5e8591afce9570dfdb5cdd22e05832ff749fe77c
v1.0
instruct
Taco
Taco_76865_I
# Task Given an integer `n`, return the list of all prime numbers less than `n`. # Input/Output `[input]` integer `n` An integer `n` such that 2 ≤ n ≤ 100. `[output]` array of integers The array of all prime numbers less than `n`. # Example For `n = 10`, the output should be `[2, 3, 5, 7]` For `n = 20`, the out...
def is_prime(num): """ Returns True if num is a prime number, False otherwise. """ if num < 2: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def list_primes_less_than(n): """ Returns a list of all prime numbers...
from solution import list_primes_less_than def test_list_primes_less_than_10(): assert list_primes_less_than(10) == [2, 3, 5, 7] def test_list_primes_less_than_20(): assert list_primes_less_than(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_list_primes_less_than_2(): assert list_primes_less_than(2) == [] ...
[ { "docstring": "Returns True if num is a prime number, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of all prime numbers less than n.", "function_declaration": "def list_primes_le...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, False otherwise.\n \"\"\"\n if num < 2:\n return False\n for i in range(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076865", "row_id": 76865, "seed_ids": "[12556]" }
0.758473
Taco_76865
I
[ "is_prime", "list_primes_less_than" ]
2
[ [ "list_primes_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20e9bb96f5b9e3088823ce59a11949540434ddc8
f563a2625e4083e0439ee90d9b59a0e220264232
v1.0
instruct
Taco
Taco_76877_I
Given an integer `N`, you are required to determine the factorial of numbers `1` to `N` and then find the sum of the digits of each factorial. -----Input----- N: an integer 1 <= N <= 100 -----Output----- The output will be `N` lines, each line containing the sum of digits of the factorial of the respective number fro...
def factorial(n): """ Returns the factorial of n. """ if n == 0 or n == 1: return 1 result = 1 for i in range(2, n + 1): result *= i return result def sum_of_digits(n): """ Returns the sum of digits of n. """ return sum(int(digit) for digit in str(n)) def su...
from solution import factorial, sum_of_digits, sum_of_digits_of_factorials def test_factorial(): assert factorial(1) == 1 assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 def test_sum_of_digits(): assert sum_of_digits(1) == 1 assert sum...
[ { "docstring": "Returns the factorial of n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns the sum of digits of n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", ...
[ 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 factorial(n):\n \"\"\"\n Returns the factorial of n.\n \"\"\"\n if n == 0 or n == 1:\n return 1\n result = 1\n for i in range(2, n + 1...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076877", "row_id": 76877, "seed_ids": "[23036]" }
0.574639
Taco_76877
I
[ "factorial", "sum_of_digits", "sum_of_digits_of_factorials" ]
3
[ [ "sum_of_digits_of_factorials", "factorial" ], [ "sum_of_digits_of_factorials", "sum_of_digits" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0f654e5488c15c337d8ce7eeafbf6447b0dc8c3a
b39432bfbfef45db219e5b763c76fe3e411440b3
v1.0
instruct
Taco
Taco_76918_I
You are tasked with designing a secure vault that is protected by a custom lock system. The vault can be opened only when given a specific sequence of binary numbers. Each binary number represents a specific lock state, and the sequence must follow a predetermined rule. The vault will only open if there is a path from...
def can_unlock_vault(n, states): def is_bit_change_one(a, b): """ Check if there is exactly one bit difference between two binary strings a and b """ return sum(x != y for x, y in zip(a, b)) == 1 states_set = set(states) # Check if both "000" and "111" are in the allowe...
from solution import vault_status def test_vault_openable(): assert vault_status(8, ["000", "001", "010", "011", "100", "101", "110", "111"]) == "OPEN" assert vault_status(3, ["000", "001", "011"]) == "LOCKED" assert vault_status(5, ["000", "001", "011", "010", "111"]) == "OPEN" assert vault_status(5, ...
[ { "docstring": null, "function_declaration": "def can_unlock_vault(n, states):", "function_name": "can_unlock_vault", "parameter_list": "(n, states)" }, { "docstring": null, "function_declaration": "def vault_status(n, states):", "function_name": "vault_status", "parameter_list":...
[ 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": "from collections import deque\n\ndef can_unlock_vault(n, states):\n \"\"\"\n Determines if the vault can be unlocked given the states.\n\n :param n: Numbe...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00076918", "row_id": 76918, "seed_ids": "[13465]" }
0.563271
Taco_76918
I
[ "can_unlock_vault", "vault_status" ]
2
[ [ "vault_status", "can_unlock_vault" ] ]
1
[]
false
[]
false
pytest
true
[]
true
541456953e7cbbe1f3801710d7d023d47879413d
11350e705df79d5f104e465cf4965951fc70ebbb
v1.0
instruct
Taco
Taco_76956_I
You are given a sequence of integers. Your task is to rearrange the sequence such that every adjacent pair of elements are relatively prime. Two integers are relatively prime if their greatest common divisor (GCD) is 1. If it is possible to rearrange the sequence to satisfy this condition, output the rearranged sequen...
from itertools import permutations from math import gcd def is_relatively_prime_sequence(seq): for i in range(len(seq) - 1): if gcd(seq[i], seq[i+1]) != 1: return False return True def rearrange_to_rel_prime_sequence(n, sequence): for perm in permutations(sequence): if is_relat...
from solution import rearrange_to_rel_prime_sequence def test_example_1(): assert rearrange_to_rel_prime_sequence(4, [2, 3, 4, 5]) == [2, 3, 4, 5] def test_example_2(): assert rearrange_to_rel_prime_sequence(3, [2, 4, 6]) == -1 def test_single_element(): assert rearrange_to_rel_prime_sequence(1, [1]) == ...
[ { "docstring": null, "function_declaration": "def is_relatively_prime_sequence(seq):", "function_name": "is_relatively_prime_sequence", "parameter_list": "(seq)" }, { "docstring": null, "function_declaration": "def rearrange_to_rel_prime_sequence(n, sequence):", "function_name": "rea...
[ 0, 0, 0, 0, 0, 0, 1, 1, 1 ]
3
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\nfrom math import gcd\n\ndef rearrange_relative_prime(n, sequence):\n \"\"\"\n Rearranges the given sequence such that eve...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00076956", "row_id": 76956, "seed_ids": "[23125]" }
0.611484
Taco_76956
I
[ "is_relatively_prime_sequence", "rearrange_to_rel_prime_sequence" ]
2
[ [ "rearrange_to_rel_prime_sequence", "is_relatively_prime_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4766eb9ee38256539d973675acf39f67509fec15
852f8b204ee880254b5eb4def5043cf8f9e2ba50
v1.0
instruct
Taco
Taco_76996_I
Create a function that returns a list of 'n' prime numbers starting from a given number 'start'. -----Constraints----- - `1 \leq n \leq 10^3` - `2 \leq start \leq 10^5` - Both `n` and `start` are integers. -----Input----- Input is given from Standard Input in the following format: ``` start n ``` -----Output----- Ou...
import math def is_prime(num): """ Check if a number is prime. """ if num < 2: return False for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: return False return True def primes_from(start, n): """ Returns a list of 'n' prime numbers starting from...
from solution import primes_from, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_primes_from_edge_case(): result = primes_from(2, 5) expected = [2, 3, 5, 7, 11...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of 'n' prime numbers starting from 'start'.", "function_declaration": "def primes_from(start, n):", "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076996", "row_id": 76996, "seed_ids": "[19331]" }
0.709062
Taco_76996
I
[ "is_prime", "primes_from" ]
2
[ [ "primes_from", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1fbec3dc31196ac482b2d88dd83b3d6147b25012
da875e410a317b2440edbec2f581d7b341bc8958
v1.0
instruct
Taco
Taco_77020_I
Sam loves collecting comic books and he has recently received a large shipment. Each comic book has a certain number of pages, and Sam wants to arrange them in stacks such that all stacks have exactly the same number of pages. He can choose any number of stacks, but each stack must contain at least one comic book. Hel...
import math from functools import reduce def gcd(a, b): while b: a, b = b, a % b return a def find_gcd_of_list(arr): return reduce(gcd, arr) def can_form_equal_page_stacks(test_cases): results = [] for pages in test_cases: if len(pages) == 1: results.append("YES") ...
from solution import can_form_equal_page_stacks def test_single_book(): assert can_form_equal_page_stacks([[5]]) == ["YES"] def test_all_same_pages(): assert can_form_equal_page_stacks([[3, 3]]) == ["YES"] def test_no_common_gcd(): assert can_form_equal_page_stacks([[1, 2, 3]]) == ["NO"] def test_common...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def find_gcd_of_list(arr):", "function_name": "find_gcd_of_list", "parameter_list": "(arr)" }, { "docstring":...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom functools import reduce\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef can_arrange_stacks(t, test_cases):\n res...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00077020", "row_id": 77020, "seed_ids": "[4495]" }
0.658347
Taco_77020
I
[ "gcd", "find_gcd_of_list", "can_form_equal_page_stacks" ]
3
[ [ "can_form_equal_page_stacks", "find_gcd_of_list" ], [ "find_gcd_of_list", "gcd" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8e5c1a1232731eff639b1083f7847ceafdda0e22
94a6af16901ad25b6c5e999109ba9b90c2fc10c6
v1.0
instruct
Taco
Taco_77024_I
Problem: Consider a grid of size N x N. You are given the initial positions of S sheep and W wolves scattered across the grid. Sheep can move one step up, down, left, or right. Wolves can also move one step up, down, left, or right. However, a wolf catches a sheep if it moves to the same cell as the sheep. The objecti...
def can_sheep_escape(N, S, W, sheep_positions, wolf_positions): def is_captured(sheep, wolves): for wolf in wolves: if sheep == wolf: return True return False for sheep in sheep_positions: if is_captured(sheep, wolf_positions): return "CAUGHT"...
def test_escape_check_case1(): input_data = "5 2 2\n2 2\n4 4\n1 1\n5 5" assert escape_check(input_data) == "ESCAPED" def test_escape_check_case2(): input_data = "5 2 2\n2 2\n4 4\n2 2\n5 5" assert escape_check(input_data) == "CAUGHT" def test_escape_check_case3(): input_data = "2 1 1\n1 1\n2 2" ...
[ { "docstring": null, "function_declaration": "def can_sheep_escape(N, S, W, sheep_positions, wolf_positions):", "function_name": "can_sheep_escape", "parameter_list": "(N, S, W, sheep_positions, wolf_positions)" }, { "docstring": null, "function_declaration": "def process_input(input_dat...
[ 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_sheep_escape(grid_size, sheep_positions, wolf_positions):\n from collections import deque\n\n N = grid_size\n S = len(sheep_positions)\n W = le...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077024", "row_id": 77024, "seed_ids": "[21744]" }
0.614801
Taco_77024
I
[ "can_sheep_escape", "process_input", "escape_check" ]
3
[ [ "escape_check", "can_sheep_escape" ], [ "escape_check", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
fdb8ab2d182100cbf3019996bbe11ce53c8f0175
c55d953a7a01d531e3f9e7fe1eef84ec0d9751a2
v1.0
instruct
Taco
Taco_77040_I
Write a program that finds the closest pair of points in a given set of points in a 2D plane. The program should print the distance between the closest pair of points, rounded to four decimal places, for each set of points. The input consists of several sets of points, with each set having n points (2 ≤ n ≤ 10,000) gi...
import math import sys def calculate_distance(point1, point2): return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def closest_pair(points): def closest_pair_rec(px, py): if len(px) <= 3: return min((calculate_distance(px[i], px[j]), (px[i], px[j])) ...
def test_calculate_distance(): assert math.isclose(calculate_distance((0, 0), (3, 4)), 5.0) def test_closest_pair_case1(): points = [(0, 0), (0, 2), (2, 0), (2, 2)] assert math.isclose(closest_pair(points), 2.0, rel_tol=1e-4) def test_closest_pair_case2(): points = [(-1, -1), (-4, 3), (-2, 2)] ass...
[ { "docstring": null, "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def closest_pair(points):", "function_name": "closest_pair", "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": "import math\n\ndef closest_pair_of_points(points):\n \"\"\"\n Returns the distance between the closest pair of points to four decimal places.\n points: A ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077040", "row_id": 77040, "seed_ids": "[12779]" }
0.69996
Taco_77040
I
[ "calculate_distance", "closest_pair", "process_input" ]
3
[ [ "closest_pair", "calculate_distance" ], [ "process_input", "closest_pair" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
236e54fa3a36f58c676acc1059af2b2026bba380
372a4e8d5eaac0469780fef0806d480bfce3e4d8
v1.0
instruct
Taco
Taco_77088_I
You are given an integer array. You need to find the number of distinct prime factors of the sum of all elements of the array. Input: The first line contains a single integer N, the number of elements in the array. The second line contains N space-separated integers representing the elements of the array. Output: Out...
def distinct_prime_factors(arr): from math import isqrt def is_prime(n): if n <= 1: return False if n == 2 or n == 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i...
import pytest from solution import number_of_distinct_prime_factors def test_small_array(): assert number_of_distinct_prime_factors(3, [2, 4, 7]) == 1 def test_array_with_single_element(): assert number_of_distinct_prime_factors(1, [10]) == 2 def test_large_sum_with_multiple_factors(): assert number_of_d...
[ { "docstring": null, "function_declaration": "def distinct_prime_factors(arr):", "function_name": "distinct_prime_factors", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def number_of_distinct_prime_factors(N, arr):", "function_name": "number_of_distinct_...
[ 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 distinct_prime_factors_count(arr):\n \"\"\"\n Returns the number of distinct prime factors of the sum of all elements of the array.\n \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077088", "row_id": 77088, "seed_ids": "[9426]" }
0.596606
Taco_77088
I
[ "distinct_prime_factors", "number_of_distinct_prime_factors" ]
2
[ [ "number_of_distinct_prime_factors", "distinct_prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
75990cb48c55fd5abf9c6a3de022fb4eea30b008
7af86488fe52887d184f67e95532894e92459547
v1.0
instruct
Taco
Taco_77129_I
In a company, employees have a hierarchical structure. Each employee has a unique ID and is managed by exactly one other employee, except for the CEO who does not have a manager. You are given a list of employee-manager pairs and need to determine the number of employees under each manager. An employee A is considered ...
from collections import defaultdict, deque def build_hierarchy(employee_manager_pairs, n): hierarchy = defaultdict(list) for emp, mngr in employee_manager_pairs: hierarchy[mngr].append(emp) return hierarchy def count_subordinates(hierarchy, query): visited = set() queue = deque() queue...
from solution import employees_under_manager def test_single_employee_no_subordinates(): n, q = 1, 1 employee_manager_pairs = [] queries = [1] assert employees_under_manager(n, q, employee_manager_pairs, queries) == [0] def test_multiple_employees_simple_hierarchy(): n, q = 3, 1 employee_manag...
[ { "docstring": null, "function_declaration": "def build_hierarchy(employee_manager_pairs, n):", "function_name": "build_hierarchy", "parameter_list": "(employee_manager_pairs, n)" }, { "docstring": null, "function_declaration": "def count_subordinates(hierarchy, query):", "function_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": "from collections import defaultdict, deque\n\ndef build_hierarchy(employee_manager_pairs, n):\n hierarchy = defaultdict(list)\n for emp, mngr in employee_man...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077129", "row_id": 77129, "seed_ids": "[16770]" }
0.699408
Taco_77129
I
[ "build_hierarchy", "count_subordinates", "employees_under_manager" ]
3
[ [ "employees_under_manager", "build_hierarchy" ], [ "employees_under_manager", "count_subordinates" ] ]
2
[]
false
[]
false
pytest
true
[]
true
27b5adc6ac1263d95bc20ce2cf8c80690847fb64
1280bf3bb78c2c1d41c3877b4be210e2226ca8fa
v1.0
instruct
Taco
Taco_77142_I
You are given an integer array `arr` and an integer `x`. You need to find and print the length of the smallest subarray with a sum greater than the given `x`. If no such subarray exists, print `-1`. A subarray is defined as a contiguous part of an array. **Input format:** - The first line contains two integers `n` (...
def smallest_subarray_length(arr, x): n = len(arr) # Initialize the variables min_length = float('inf') start = 0 current_sum = 0 for end in range(n): current_sum += arr[end] # Shrink the window as small as possible while the current_sum is greater than x ...
from solution import find_smallest_subarray def test_example1(): assert find_smallest_subarray(6, 51, [1, 4, 45, 6, 0, 19]) == 3 def test_example2(): assert find_smallest_subarray(5, 9, [1, 10, 5, 2, 7]) == 1 def test_example3(): assert find_smallest_subarray(4, 100, [1, 2, 4, 5]) == -1 def test_small_a...
[ { "docstring": null, "function_declaration": "def smallest_subarray_length(arr, x):", "function_name": "smallest_subarray_length", "parameter_list": "(arr, x)" }, { "docstring": null, "function_declaration": "def find_smallest_subarray(n, x, arr):", "function_name": "find_smallest_su...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def smallest_subarray_with_sum_greater_than_x(arr, x):\n n = len(arr)\n min_length = n + 1\n \n start = 0\n end = 0\n current_sum = 0\n \n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00077142", "row_id": 77142, "seed_ids": "[5560]" }
0.875124
Taco_77142
I
[ "smallest_subarray_length", "find_smallest_subarray" ]
2
[ [ "find_smallest_subarray", "smallest_subarray_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
648f6a80e7a65cb8dfd47cb31ac942d8c5427be5
5cef36e6ad8ddb793909d51152bf43fcc5406865
v1.0
instruct
Taco
Taco_77152_I
A company is organizing an online coding competition where n participants will compete. Each participant is assigned a unique score based on their performance in the competition. The company wants to find the score of the participant who ranks k-th in the competition. Given a list of scores, you need to determine the ...
def find_kth_rank_score(test_cases): results = [] for case in test_cases: n, k, scores = case scores.sort(reverse=True) results.append(scores[k - 1]) return results def parse_input(input_string): lines = input_string.strip().split('\n') T = int(lines[0]) test_cases = [] ...
def test_find_kth_rank_score(): input_string = "2\n5 2\n50 30 40 10 20\n4 1\n100 90 80 70\n" expected_output = [40, 100] assert process_input_and_find_scores(input_string) == expected_output def test_with_minimum_values(): input_string = "1\n1 1\n10\n" expected_output = [10] assert process_inpu...
[ { "docstring": null, "function_declaration": "def find_kth_rank_score(test_cases):", "function_name": "find_kth_rank_score", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "paramet...
[ 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_kth_rank_score(test_cases):\n results = []\n for case in test_cases:\n n, k, scores = case\n scores.sort(reverse=True)\n result...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077152", "row_id": 77152, "seed_ids": "[19862]" }
0.698663
Taco_77152
I
[ "find_kth_rank_score", "parse_input", "process_input_and_find_scores" ]
3
[ [ "process_input_and_find_scores", "find_kth_rank_score" ], [ "process_input_and_find_scores", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
3492cdb87dc5d13823ad32744d00eeda5b53b66f
fbb65c465fc860515f095a861167b830d7ff7d86
v1.0
instruct
Taco
Taco_77222_I
Given an array of integers, you need to find the absolute difference between the sum of all prime numbers present in the array and the sum of all non-prime numbers present in the array. If the array contains no prime numbers or no non-prime numbers, print -1. A prime number is defined as a number greater than 1 that h...
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 p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def absolute_...
from solution import is_prime, absolute_diff_prime_nonprime, process_input 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(20) == False assert is_prime(1) == False def test_absolute_diff_prime_no...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Function to calculate the absolute difference between the sum of prime numbers \nand non-prime numbers in the a...
[ 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_prime(num):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return Tru...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00077222", "row_id": 77222, "seed_ids": "[3417]" }
0.724421
Taco_77222
I
[ "is_prime", "absolute_diff_prime_nonprime", "process_input", "main" ]
4
[ [ "absolute_diff_prime_nonprime", "is_prime" ], [ "process_input", "absolute_diff_prime_nonprime" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
cc2f53981a8a6a5c10219c73cc0b138debaac459
eb66feea6cc7127033f6a6611b1335c6274f0a5e
v1.0
instruct
Taco
Taco_77311_I
Anna is a software engineer who loves working with binary trees. She has a deep interest in finding unique paths from the root to each node and is curious to know more about them. Given a binary tree, she wants to find the sum of all root-to-node paths. Can you help her? -----Input:----- - First-line will contain $T$,...
class TreeNode: def __init__(self, value): self.val = value self.left = None self.right = None def build_tree(edges): nodes = {} for parent, child, direction in edges: if parent not in nodes: nodes[parent] = TreeNode(parent) if child not in nodes: ...
from solution import sum_of_all_paths def test_single_path(): T = 1 testcases = [ (3, [ (1, 2, 'L'), (2, 3, 'L') ]) ] result = sum_of_all_paths(T, testcases) assert result == [123] def test_multiple_paths(): T = 1 testcases = [ (5, [ ...
[]
[ 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": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00077311", "row_id": 77311, "seed_ids": "[4787]" }
0.65854
Taco_77311
I
[ "build_tree", "sum_root_to_node_paths", "sum_of_all_paths" ]
3
[ [ "sum_of_all_paths", "build_tree" ], [ "sum_of_all_paths", "sum_root_to_node_paths" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
904fe9a3a0ba73451eb0f3749414bc867465af06
2df8c36873397c6b2b571cfaf4512e3cf60aef70
v1.0
instruct
Taco
Taco_77402_I
Problem A traveling salesman is planning his routes between various cities. To optimize his travels, he wants to determine the minimal travel cost between any two cities in his itinerary. The cities and the travel costs between them can be represented using a graph where each node represents a city, and the weights o...
import heapq def dijkstra(n, edges, start, end): graph = {i: [] for i in range(1, n + 1)} for u, v, w in edges: graph[u].append((v, w)) graph[v].append((u, w)) pq = [(0, start)] dist = {i: float('inf') for i in range(1, n + 1)} dist[start] = 0 while pq: current...
from solution import minimal_travel_cost def test_case_1(): n = 5 m = 6 routes = [(1, 2, 3), (1, 3, 10), (2, 3, 1), (2, 4, 2), (3, 4, 4), (4, 5, 3)] assert minimal_travel_cost(n, m, routes, 1, 5) == 8 def test_case_2(): n = 3 m = 3 routes = [(1, 2, 1), (2, 3, 2), (1, 3, 4)] assert mini...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start, end):", "function_name": "dijkstra", "parameter_list": "(n, edges, start, end)" }, { "docstring": null, "function_declaration": "def minimal_travel_cost(n, m, routes, start, end):", "function_name": "minimal_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, edges, start, end):\n graph = {i: [] for i in range(1, n + 1)}\n for u, v, w in edges:\n graph[u].append((v, w))\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077402", "row_id": 77402, "seed_ids": "[3522]" }
0.759613
Taco_77402
I
[ "dijkstra", "minimal_travel_cost" ]
2
[ [ "minimal_travel_cost", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bff7957d7c0abec77514a0a139430b676c2e64d5
3e784d864b54fbce5b3aa7fd25209d85414516d4
v1.0
instruct
Taco
Taco_77448_I
The Galactic Empire has recently deployed a new communication network across its planets. Each planet is represented as a node in a network graph, and each communication channel between two planets is an undirected edge with a certain distance. However, due to budget constraints, the Empire wants to ensure that the tot...
import heapq def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root...
def test_minimum_spanning_tree(): input_data = "2\n4 5\n1 2 1\n1 3 4\n2 3 2\n2 4 3\n3 4 5\n3 3\n1 2 1\n2 3 3\n1 3 2" expected_output = [6, 3] assert main(input_data) == expected_output def test_single_edge(): input_data = "1\n2 1\n1 2 4" expected_output = [4] assert main(input_data) == expected...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = find(parent, x)\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077448", "row_id": 77448, "seed_ids": "[19772]" }
0.768842
Taco_77448
I
[ "find", "union", "kruskal", "solve_cases", "main" ]
5
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "solve_cases", "kruskal" ], [ "union", "find" ] ]
4
[ "solve_cases" ]
false
[]
false
pytest
false
[]
true
d29d0b99d73d2aca4f71d143e2668a99e60bd890
bd3b747100662520184be55f53712f698f310519
v1.0
instruct
Taco
Taco_77454_I
Han wants to go on a hiking trip. He has a backpack with a maximum capacity of W (in kilograms). He has n items, each item i has a weight w_i and a value v_i. Han wants to maximize the total value of items he can pack into his backpack, but the total weight of items should not exceed W. Han can only take one unit of e...
def knapsack(n, W, items): """ Solves the 0/1 knapsack problem. Parameters: n (int): Number of items W (int): Maximum capacity of the backpack items (list of tuples): List of items where each item is represented as (weight, value) Returns: int: The maximum value that can be pa...
from solution import solve_knapsack_problem def test_example_1(): n = 4 W = 7 items = [(2, 10), (3, 20), (4, 30), (5, 40)] assert solve_knapsack_problem(n, W, items) == 50 def test_example_2(): n = 3 W = 50 items = [(10, 60), (20, 100), (30, 120)] assert solve_knapsack_problem(n, W, it...
[ { "docstring": "Solves the 0/1 knapsack problem.\n\nParameters:\nn (int): Number of items \nW (int): Maximum capacity of the backpack\nitems (list of tuples): List of items where each item is represented as (weight, value)\n\nReturns:\nint: The maximum value that can be packed into the backpack without exceedin...
[ 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 knapsack(n, W, items):\n \"\"\"\n Finds the maximum value of items that can be packed into the backpack\n without exceeding the maximum weight.\n\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077454", "row_id": 77454, "seed_ids": "[2468]" }
0.731336
Taco_77454
I
[ "knapsack", "solve_knapsack_problem" ]
2
[ [ "solve_knapsack_problem", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
001b2b0bcbffcb7a8ce4ff0a57d1d00553b35c67
82a4b28bb110f97bb8969dfd483d3223436254c4
v1.0
instruct
Taco
Taco_77461_I
In a small town called Algora, every house has a unique and positive integer address. Recently, the town council has decided to renovate certain houses. They have specific criteria to decide which houses will be renovated. The council has given you a number P. A house will be considered for renovation if the sum of the...
def digit_sum(n): """Returns the sum of digits of n""" return sum(int(digit) for digit in str(n)) def find_renovation_addresses(T, cases): results = [] for case in cases: a, b, P = case qualifying_addresses = [i for i in range(a, b+1) if digit_sum(i) == P] if qualifying_addresse...
from solution import find_renovation_addresses def test_single_case_no_qualifying_addresses(): T = 1 cases = [ (1, 5, 10) ] assert find_renovation_addresses(T, cases) == ["No houses will be renovated"] def test_single_case_with_qualifying_addresses(): T = 1 cases = [ (10, 20, 2...
[ { "docstring": "Returns the sum of digits of n", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_renovation_addresses(T, cases):", "function_name": "find_renovation_addresses"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(n):\n return sum(int(digit) for digit in str(n))\n\ndef houses_for_renovation(T, test_cases):\n results = []\n for i in range(T):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077461", "row_id": 77461, "seed_ids": "[3338]" }
0.656301
Taco_77461
I
[ "digit_sum", "find_renovation_addresses" ]
2
[ [ "find_renovation_addresses", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
61e1076f019e212c839680e0a87e675096c4b1a2
d7d94b6b2fccf5062b7cdf15b04be067bc9fcfa8
v1.0
instruct
Taco
Taco_77492_I
We are given the root node of a binary search tree: a tree where each node follows the property that all nodes in its left subtree have values less than the node's value, and all nodes in its right subtree have values greater than the node's value. Given a binary search tree, root, and the value of a node that needs t...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def deleteNode(root, key): if not root: return None if key < root.val: root.left = deleteNode(root.left, key) elif key > root.val: root.r...
import pytest from solution import TreeNode, deleteNode, inorderTraversal def build_tree(values): if not values: return None nodes = [TreeNode(val) if val is not None else None for val in values] kids = nodes[::-1] root = kids.pop() for node in nodes: if node: if kids: n...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n \ndef...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077492", "row_id": 77492, "seed_ids": "[7485]" }
0.556389
Taco_77492
I
[ "deleteNode", "findMin", "inorderTraversal" ]
3
[ [ "deleteNode", "findMin" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
9c40b1643a5c1097bf54590c365b5c7d43fe6380
c14dcce9c525c090b56b9deb958ffa3c09fe02fe
v1.0
instruct
Taco
Taco_77496_I
A digital library wants to organize a large number of books efficiently. Each book has a unique identifier and belongs to a specific genre. The library wants to place all the books on shelves such that each shelf contains books of only one genre. Furthermore, within a genre, all books should be sorted by their identifi...
def organize_books(T, test_cases): """ Organizes books by genre and identifier. Parameters: T (int): Number of test cases. test_cases (list): A list of lists where each sublist corresponds to a test case. Each sublist contains a tuple that represents a book (genre, identi...
def test_organize_books(): input_string = "2\n3\nfiction 2\nnonfiction 1\nfiction 1\n4\nromance 1\nscience 2\nromance 3\nscience 1\n" expected_output = "fiction:\n1 2\nnonfiction:\n1\n\nromance:\n1 3\nscience:\n1 2" assert handle_books(input_string) == expected_output def test_single_genre(): input_str...
[ { "docstring": "Organizes books by genre and identifier.\n\nParameters:\nT (int): Number of test cases.\ntest_cases (list): A list of lists where each sublist corresponds to a test case.\n Each sublist contains a tuple that represents a book (genre, identifier).\n \nReturns:\...
[ 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 organize_books(test_cases):\n results = []\n for case in test_cases:\n N, books = case\n genre_dict = {}\n ordered_genres = []\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077496", "row_id": 77496, "seed_ids": "[3772]" }
0.684718
Taco_77496
I
[ "organize_books", "parse_input", "handle_books" ]
3
[ [ "handle_books", "organize_books" ], [ "handle_books", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
da2429d87837181fd5348f9a6396b7fec8b32593
6351e17732de14f959adc6b7e8fb9f6b1fc7205b
v1.0
instruct
Taco
Taco_77573_I
As a software engineer, you are tasked with creating an algorithm to sort a list of distinct integers in a non-decreasing order. However, the catch is that you can only use a specific subset of sorting algorithms. The algorithms you are allowed to use are: - Selection Sort - Insertion Sort - Bubble Sort Your task is ...
def bubble_sort(nums): n = len(nums) for i in range(n): for j in range(0, n-i-1): if nums[j] > nums[j+1]: nums[j], nums[j+1] = nums[j+1], nums[j] def is_sorted(nums): return all(nums[i] <= nums[i+1] for i in range(len(nums)-1)) def sort_and_verify(n, nums): bubble_s...
from solution import bubble_sort, is_sorted, sort_and_verify def test_bubble_sort(): arr = [64, 34, 25, 12, 22] bubble_sort(arr) assert arr == [12, 22, 25, 34, 64] def test_is_sorted_true(): assert is_sorted([1, 2, 3, 4, 5]) == True def test_is_sorted_false(): assert is_sorted([1, 3, 2, 4, 5]) ==...
[ { "docstring": null, "function_declaration": "def bubble_sort(nums):", "function_name": "bubble_sort", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def is_sorted(nums):", "function_name": "is_sorted", "parameter_list": "(nums)" }, { "docstri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bubble_sort(nums):\n n = len(nums)\n for i in range(n):\n for j in range(0, n-i-1):\n if nums[j] > nums[j+1]:\n nums[j],...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077573", "row_id": 77573, "seed_ids": "[2904]" }
0.645071
Taco_77573
I
[ "bubble_sort", "is_sorted", "sort_and_verify" ]
3
[ [ "sort_and_verify", "bubble_sort" ], [ "sort_and_verify", "is_sorted" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a7a71e3a043d5787347f3d2795b2709a54fbb9f5
a2c2cbc94a719b0786e6ab46e50171e10dd1524b
v1.0
instruct
Taco
Taco_77584_I
Manao is now tasked with optimizing the location of research towers on a vast grid. The research towers must be placed at specific points and each tower covers an influence area defined by a square centered at the tower's location. Two towers can cooperate if their influence areas overlap or touch. Your job is to dete...
def calculate_union_find(parents, tower): if parents[tower] != tower: parents[tower] = calculate_union_find(parents, parents[tower]) return parents[tower] def union(parents, rank, tower1, tower2): root1 = calculate_union_find(parents, tower1) root2 = calculate_union_find(parents, tower2) if...
from solution import max_cooperative_group def test_example_1(): n = 5 towers = [ (0, 0, 2), (3, 0, 2), (1, 1, 2), (4, 4, 2), (5, 5, 2) ] assert max_cooperative_group(n, towers) == 3 def test_no_overlap(): n = 3 towers = [ (0, 0, 2), (10,...
[ { "docstring": null, "function_declaration": "def calculate_union_find(parents, tower):", "function_name": "calculate_union_find", "parameter_list": "(parents, tower)" }, { "docstring": null, "function_declaration": "def union(parents, rank, tower1, tower2):", "function_name": "union...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_cooperative_towers(n, towers):\n def can_communicate(t1, t2):\n x1, y1, s1 = t1\n x2, y2, s2 = t2\n x1_min, x1_max = x1 - s1 // 2, ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077584", "row_id": 77584, "seed_ids": "[4645]" }
0.61915
Taco_77584
I
[ "calculate_union_find", "union", "max_cooperative_group", "main" ]
4
[ [ "max_cooperative_group", "calculate_union_find" ], [ "max_cooperative_group", "union" ], [ "union", "calculate_union_find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1da00a1e01a2b58fd1847e27122a59d3f7915a2c
14d972f7b4c448f2aa20ce80c71b2f36cf876ca0
v1.0
instruct
Taco
Taco_77616_I
Peter is fascinated by a certain numerical pattern he discovered. This pattern contains sequences of numbers, each starting from a given positive integer. Each next number in the sequence is calculated by the following rules: - If the number is even, divide it by 2. - If the number is odd, multiply it by 3 and then ad...
def has_terminating_sequence(n): """ Returns True if the sequence starting from n terminates at 1, False otherwise. """ seen = set() while n != 1: if n in seen: return False seen.add(n) if n % 2 == 0: n //= 2 else: n = 3 * n + 1 ...
from solution import has_terminating_sequence, find_terminating_sequences def test_has_terminating_sequence(): assert has_terminating_sequence(1) == True assert has_terminating_sequence(2) == True assert has_terminating_sequence(3) == True assert has_terminating_sequence(4) == True assert has_termi...
[ { "docstring": "Returns True if the sequence starting from n terminates at 1, False otherwise.", "function_declaration": "def has_terminating_sequence(n):", "function_name": "has_terminating_sequence", "parameter_list": "(n)" }, { "docstring": "Returns a list of numbers below n that have ter...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_terminating_sequence(x):\n \"\"\"\n Returns True if the sequence starting from x reaches 1, False otherwise.\n \"\"\"\n seen = set()\n while ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00077616", "row_id": 77616, "seed_ids": "[18552]" }
0.653769
Taco_77616
I
[ "has_terminating_sequence", "find_terminating_sequences" ]
2
[ [ "find_terminating_sequences", "has_terminating_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0aeb96059269a4515cc527f039677697b0da0e5a
8b50c00d4fd2fc2ad0730e1d81b84f6959505d72
v1.0
instruct
Taco
Taco_77628_I
You have been given a list of transaction records. Each record contains an identifier of the account holder, the transaction type (either deposit or withdrawal), and the amount involved in the transaction. Your task is to write a program to determine the final balance of each account holder. If the balance of any acco...
def calculate_final_balances(transactions): from collections import defaultdict balances = defaultdict(int) invalid_accounts = set() for account, trans_type, amount in transactions: if account in invalid_accounts: continue # Skip processing if the account is already invalid ...
from solution import process_transactions_input def test_single_valid_deposit(): T = 1 transactions = ["alice deposit 1000"] result = process_transactions_input(T, transactions) assert result == {"alice": 1000} def test_single_invalid_withdrawal(): T = 1 transactions = ["alice withdrawal 1000"...
[ { "docstring": null, "function_declaration": "def calculate_final_balances(transactions):", "function_name": "calculate_final_balances", "parameter_list": "(transactions)" }, { "docstring": null, "function_declaration": "def process_transactions_input(T, transaction_list):", "functio...
[ 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_final_balances(transactions):\n accounts = {}\n \n for account_id, trans_type, amount in transactions:\n if account_id not in account...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077628", "row_id": 77628, "seed_ids": "[3231]" }
0.610291
Taco_77628
I
[ "calculate_final_balances", "process_transactions_input" ]
2
[ [ "process_transactions_input", "calculate_final_balances" ] ]
1
[]
false
[]
false
pytest
true
[]
true
764f79adc891d7511c082116b8acb2721272697c
3df4077cdb8be5c121a1376bd317e239dd6e9fd5
v1.0
instruct
Taco
Taco_77669_I
Given a binary tree, write a function to determine if it is a balanced binary tree. A balanced binary tree is defined as a binary tree in which the left and right subtrees of every node differ in height by no more than 1. ------ Input Format ------ - The input consists of lines in which each line contains a tree nod...
from typing import List, Tuple class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def build_tree(nodes: List[Tuple[int, int, str]]) -> TreeNode: if not nodes: return None node_dict = {} for parent, child, direction i...
from solution import is_balanced_tree def test_balanced_tree(): tree1 = [(1, 2, 'L'), (1, 3, 'R'), (2, 4, 'L'), (2, 5, 'R'), (3, 6, 'L')] assert is_balanced_tree(tree1) == True def test_unbalanced_tree(): tree2 = [(1, 2, 'L'), (1, 3, 'R'), (2, 4, 'L'), (2, 5, 'R'), (4, 8, 'L')] assert is_balanced_tree...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Tuple, Optional\n\nclass TreeNode:\n def __init__(self, value: int):\n self.value = value\n self.left = None\n sel...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077669", "row_id": 77669, "seed_ids": "[10572]" }
0.847075
Taco_77669
I
[ "build_tree", "is_balanced_tree" ]
2
[ [ "is_balanced_tree", "build_tree" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
35fe617bc370bdab66805b3547edd1ff842a3647
48eb77563d0790e0750168f0c5dd7a61c9bce828
v1.0
instruct
Taco
Taco_77678_I
Wooden Blocks are fun to play with! John has a collection of wooden blocks, each with a number written on it. He loves to rearrange these blocks in different ways. Today, he decided to challenge himself by forming the largest possible number using all the blocks he has. Every block can only be used once and they must ...
from functools import cmp_to_key def compare(x, y): """ Comparator function to determine the order for the largest concatenated number """ if x + y > y + x: return -1 elif x + y < y + x: return 1 else: return 0 def largest_number(blocks): """ Forms the large...
def test_largest_number(): # Simple case test_cases = [(3, [10, 2, 9]), (4, [62, 32, 21, 9])] assert process_input(test_cases) == ["9210", "9623221"] # Case with leading zeros test_cases = [(3, [0, 0, 0])] assert process_input(test_cases) == ["0"] # Larger numbers test_cases = ...
[ { "docstring": "Comparator function to determine the order for the largest concatenated number", "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": "Forms the largest number possible with given blocks", "function_declara...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(x, y):\n \"\"\"\n Comparator function to determine the order for the largest concatenated number\n \"\"\"\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077678", "row_id": 77678, "seed_ids": "[1043]" }
0.580201
Taco_77678
I
[ "compare", "largest_number", "process_input" ]
3
[ [ "largest_number", "compare" ], [ "process_input", "largest_number" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
c189583dbf8f05bfe287766e7525d26f0f6a637c
33b001496185f3f1c166f251a70545aff6d20a69
v1.0
instruct
Taco
Taco_77763_I
In a certain kingdom, there are n cities connected by m bidirectional roads. Each road connects two different cities and has a travel cost associated with it. The king wants to select a subset of these roads to build a special infrastructure project that satisfies the following conditions: 1. Every city in the kingdom...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y]...
def test_sample1(): n = 4 m = 5 roads = [ (1, 2, 1), (1, 3, 4), (1, 4, 3), (2, 3, 2), (3, 4, 5) ] assert minimum_cost_to_connect_all_cities(n, m, roads) == 6 def test_sample2(): n = 3 m = 1 roads = [ (1, 2, 5) ] assert minimum_cost...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_min_cost_to_connect_all_cities(n, m, roads):\n \"\"\"\n Finds the minimum cost to connect all cities or returns \"IMPOSSIBLE\" if not possible.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077763", "row_id": 77763, "seed_ids": "[4310]" }
0.792304
Taco_77763
I
[ "find", "union", "minimum_cost_to_connect_all_cities" ]
3
[ [ "minimum_cost_to_connect_all_cities", "find" ], [ "minimum_cost_to_connect_all_cities", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
6bab997a986788692b2fb16287a1d16a679162ad
6d2c17579955d16630e9d443298d0cee1b100f9c
v1.0
instruct
Taco
Taco_77768_I
Mahmoud and his friend are playing a game! They each have an integer, and they take turns guessing the other player's integer. Mahmoud has an integer \( x \) and his friend has an integer \( y \). Both \( x \) and \( y \) are initially unknown to the other player. To guess the value, each player can ask a question in ...
def guess_integer(y): """ Guesses the integer y held by a friend using a binary search strategy. """ low, high = 0, 2**30 - 1 while low < high: mid = (low + high) // 2 if is_greater(y, mid): low = mid + 1 else: high = mid return low def is_g...
from solution import guess_integer def test_guess_integer(): test_cases = [ (0, 0), (1, 1), (20, 20), (2**30 - 1, 2**30 - 1), (2**29, 2**29), (123456, 123456), ] for y, expected in test_cases: assert guess_integer(y) == expected
[ { "docstring": "Guesses the integer y held by a friend using a binary search strategy.", "function_declaration": "def guess_integer(y):", "function_name": "guess_integer", "parameter_list": "(y)" }, { "docstring": "Mock response function to simulate the friend's answer.\nFor test purposes, i...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def guess_integer(y):\n \"\"\"\n Guesses the integer y held by a friend using a binary search strategy.\n \"\"\"\n low, high =...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077768", "row_id": 77768, "seed_ids": "[504]" }
0.646785
Taco_77768
I
[ "guess_integer", "is_greater" ]
2
[ [ "guess_integer", "is_greater" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1c614f9d2cf42a0231f408123674f25d70c5f032
338de6fd64eb2ec2e9a79b0ef05f921c34d86f34
v1.0
instruct
Taco
Taco_77896_I
Write a function that receives a list of integers and returns a list of integers where each element is replaced by the nearest prime number. If the element itself is a prime, it remains unchanged. If there is a tie between two prime numbers (i.e., the same distance from the number), choose the smaller one. A prime nu...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
from solution import replace_with_nearest_primes def test_replace_with_nearest_primes(): assert replace_with_nearest_primes([4, 10, 27, 38, 59]) == [3, 11, 29, 37, 59] assert replace_with_nearest_primes([7, 12, 1, 100, 250]) == [7, 11, 2, 101, 251] assert replace_with_nearest_primes([1, 2, 3, 4, 5]) == [2,...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find the nearest prime number to n. If n is prime, it remains unchanged.\nIf there is a tie between two prime numbers, return the ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve(n):\n \"\"\"\n Generate a list of primes up to and including `n` using the Sieve of Eratosthenes.\n \"\"\"\n is_prime = [True] * (n + 1)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077896", "row_id": 77896, "seed_ids": "[23720]" }
0.682374
Taco_77896
I
[ "is_prime", "nearest_prime", "replace_with_nearest_primes" ]
3
[ [ "nearest_prime", "is_prime" ], [ "replace_with_nearest_primes", "nearest_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6316b9af842da70044408546bbce010c3307815c
721590d67fddc3f4ed5c8ef2d2716c4272534910
v1.0
instruct
Taco
Taco_77977_I
Given a positive integer N, define a function `isPrime(X)` which returns true if X is a prime number and false otherwise. For example, `isPrime(11)` = True, because 11 has no divisors other than 1 and itself. Your task is to find the smallest prime number P which is both greater than N and can be expressed as the sum...
def isPrime(X): """ Returns True if X is a prime number, False otherwise. """ if X <= 1: return False if X <= 3: return True if X % 2 == 0 or X % 3 == 0: return False i = 5 while i * i <= X: if X % i == 0 or X % (i + 2) == 0: return False ...
from solution import isPrime, isSumOfSquares, smallest_prime_sum_of_squares_greater_than, process_input def test_is_prime(): assert isPrime(2) == True assert isPrime(3) == True assert isPrime(4) == False assert isPrime(29) == True assert isPrime(30) == False def test_is_sum_of_squares(): asser...
[ { "docstring": "Returns True if X is a prime number, False otherwise.", "function_declaration": "def isPrime(X):", "function_name": "isPrime", "parameter_list": "(X)" }, { "docstring": "Returns True if PR can be expressed as the sum of the squares of two non-negative integers.", "functio...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef isPrime(x):\n \"\"\"\n Returns True if x is a prime number, otherwise False.\n \"\"\"\n if x <= 1:\n return False\n if x <...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077977", "row_id": 77977, "seed_ids": "[2002]" }
0.643146
Taco_77977
I
[ "isPrime", "isSumOfSquares", "smallest_prime_sum_of_squares_greater_than", "process_input" ]
4
[ [ "process_input", "smallest_prime_sum_of_squares_greater_than" ], [ "smallest_prime_sum_of_squares_greater_than", "isPrime" ], [ "smallest_prime_sum_of_squares_greater_than", "isSumOfSquares" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
2152f2028fd2c985a920db38313580de0c7a75d4
c759285d4ef4575310f8134cc02d01cd2aa9b104
v1.0
instruct
Taco
Taco_78021_I
A transportation company is planning the most efficient way to deliver packages from a central hub to several delivery points. Each package has a weight, and each delivery vehicle has a maximum weight capacity. Your task is to determine how many trips each vehicle will need to make in order to deliver all the packages....
def calculate_trips(packages, capacity): trips = 0 current_weight = 0 for weight in packages: if current_weight + weight <= capacity: current_weight += weight else: trips += 1 current_weight = weight if current_weight > 0: trips += 1 ...
from solution import min_trips def test_basic_example1(): assert min_trips(5, [2, 3, 4, 5, 6], 10) == 3 def test_basic_example2(): assert min_trips(7, [1, 2, 3, 4, 5, 6, 7], 7) == 5 def test_single_package(): assert min_trips(1, [5], 10) == 1 def test_exact_capacity(): assert min_trips(3, [3, 3,...
[ { "docstring": null, "function_declaration": "def calculate_trips(packages, capacity):", "function_name": "calculate_trips", "parameter_list": "(packages, capacity)" }, { "docstring": null, "function_declaration": "def min_trips(n, weights, capacity):", "function_name": "min_trips", ...
[ 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 minimum_trips(packages, capacity):\n \"\"\"\n Returns the minimum number of trips needed to deliver all packages\n given the weight capacity of each v...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00078021", "row_id": 78021, "seed_ids": "[15829]" }
0.752588
Taco_78021
I
[ "calculate_trips", "min_trips" ]
2
[ [ "min_trips", "calculate_trips" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2e17a91562e87375768b4f2b21cc6d5c7257e8d4
e18848e4346ad7f7511b57c385a73b14e647f0e4
v1.0
instruct
Taco
Taco_78047_I
Write a function that takes two integers `nextMove` and `lastMove` to simulate moves in a two-player turn-based game. The function should determine if the second player can win with their next move based on the initial moves of the game provided by `nextMove` and `lastMove`. The goal is to reach a score of at least `8`...
def game_result(nextMove, lastMove): """ Determines the result of the game based on nextMove and lastMove. If nextMove is greater than or equal to 8, or if nextMove is greater than lastMove, Second player wins ("Second"). If both players have the same move, it's a draw ("Draw"). Otherwise, the First...
from solution import game_series def test_game_series(): moves = [(6, 4), (5, 3), (2, 1), (0, 0)] expected_results = ["Second", "Second", "Second"] assert game_series(moves) == expected_results def test_game_series_with_draw(): moves = [(6, 4), (5, 3), (2, 2), (0, 0)] expected_results = ["Second",...
[ { "docstring": "Determines the result of the game based on nextMove and lastMove.\nIf nextMove is greater than or equal to 8, or if nextMove is greater than lastMove, Second player wins (\"Second\").\nIf both players have the same move, it's a draw (\"Draw\").\nOtherwise, the First player wins (\"First\").", ...
[ 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 simulate_moves(nextMove, lastMove):\n \"\"\"\n Determines the winner of the game based on the given moves.\n \n The goal is to reach a score of at ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00078047", "row_id": 78047, "seed_ids": "[14982]" }
0.701826
Taco_78047
I
[ "game_result", "game_series" ]
2
[ [ "game_series", "game_result" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6b20870435958548da8d78e8914833c9ed6d2490
1df84121c7078128a6dbd71b2a1da9fe355571c5
v1.0
instruct
Taco
Taco_78075_I
You are given a list of n integers representing the scores of n players in a game. The game, however, has a peculiar rule: players' scores can be changed when specific events occur, and some queries need to be answered about the scores in specific ranges. You must handle two types of operations on this list: * 1 i k...
def update_range(arr, i, k, d): """ Increment the values in the range [i, k] by d. """ for idx in range(i-1, k): arr[idx] += d def query_sum(arr, i, k): """ Calculate the sum of values in the range [i, k]. """ return sum(arr[i-1:k]) def process_operations(n, q, a, operations): ...
def test_update_range(): arr = [10, 20, 30, 40, 50] update_range(arr, 2, 4, 10) assert arr == [10, 30, 40, 50, 50] def test_query_sum(): arr = [10, 30, 40, 50, 50] result = query_sum(arr, 1, 3) assert result == 80 def test_process_operations(): n = 5 q = 4 a = [10, 20, 30, 40, 50] ...
[ { "docstring": "Increment the values in the range [i, k] by d.", "function_declaration": "def update_range(arr, i, k, d):", "function_name": "update_range", "parameter_list": "(arr, i, k, d)" }, { "docstring": "Calculate the sum of values in the range [i, k].", "function_declaration": "d...
[ 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 update_range(arr, i, k, d):\n \"\"\"\n Increment the values in the range [i, k] by d.\n \"\"\"\n for idx in range(i-1, k):\n arr[idx] += d\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078075", "row_id": 78075, "seed_ids": "[16430]" }
0.714736
Taco_78075
I
[ "update_range", "query_sum", "process_operations" ]
3
[ [ "process_operations", "query_sum" ], [ "process_operations", "update_range" ] ]
2
[]
false
[]
false
pytest
false
[]
true
35e5adfc07e15f5b29926e01af14ef7df292d644
5786db62bb166754fba2b0057c8036557fef7a24
v1.0
instruct
Taco
Taco_78129_I
Write a function `largestRotatedRectangle` that accepts two integers `M` and `N` representing the dimensions of a 2D grid and a 2D list `matrix` of size MxN, consisting of only '0's and '1's. The function should return the area of the largest rectangle containing only 1's that can be obtained by rotating the matrix by ...
def maximalRectangle(matrix): if not matrix or not matrix[0]: return 0 max_area = 0 heights = [0] * len(matrix[0]) for row in matrix: for i in range(len(row)): if row[i] == '1': heights[i] += 1 else: heights[i] = 0 max_ar...
def test_largestRotatedRectangle(): matrix1 = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert largestRotatedRectangle(4, 5, [[str(x) for x in row] for row in matrix1]) == 6 matrix2 = [ [0, 1], [1, 0] ] assert larg...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 0, 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 largest_rectangle_area(histogram):\n stack = []\n max_area = 0\n index = 0\n \n while index < len(histogram):\n if not stack or histogram...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078129", "row_id": 78129, "seed_ids": "[10401]" }
0.709465
Taco_78129
I
[ "maximalRectangle", "largestRectangleArea", "rotate90", "largestRotatedRectangle" ]
4
[ [ "largestRotatedRectangle", "maximalRectangle" ], [ "largestRotatedRectangle", "rotate90" ], [ "maximalRectangle", "largestRectangleArea" ] ]
3
[]
false
[]
false
pytest
false
[]
true
1d6fc0037e41cba82f369687bec247c2942b5745
d32a3dc4e2102e6b00cd6de612da21854d0e4e85
v1.0
instruct
Taco
Taco_78135_I
Bob is a skilled carpenter and has just received an unusual order. He needs to craft rectangular tables using wooden planks. Each plank has a positive integer length, but since Bob wants the tables to look aesthetically pleasing, the lengths of the planks of a single table must follow the Fibonacci sequence. Additiona...
MOD = 1000000007 def fibonacci_sequence_upto(m): """Generate Fibonacci numbers up to `m`.""" fibs = [1, 1] while True: next_fib = fibs[-1] + fibs[-2] if next_fib > m: break fibs.append(next_fib) return fibs def count_fibonacci_tables(M): fibonacci_numbers = fibo...
def test_fibonacci_sequence_upto(): assert fibonacci_sequence_upto(10) == [1, 1, 2, 3, 5, 8] assert fibonacci_sequence_upto(1000) == [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987] def test_count_fibonacci_tables(): assert count_fibonacci_tables(10) == 6 assert count_fibonacci_tables(10...
[ { "docstring": "Generate Fibonacci numbers up to `m`.", "function_declaration": "def fibonacci_sequence_upto(m):", "function_name": "fibonacci_sequence_upto", "parameter_list": "(m)" }, { "docstring": null, "function_declaration": "def count_fibonacci_tables(M):", "function_name": "c...
[ 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 count_fibonacci_tables(T, Ms):\n MOD = 1000000007\n \n def fibonacci_up_to(n):\n fibs = [1, 2]\n while True:\n next_fib = fib...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00078135", "row_id": 78135, "seed_ids": "[24800]" }
0.576245
Taco_78135
I
[ "fibonacci_sequence_upto", "count_fibonacci_tables", "find_all_unique_tables" ]
3
[ [ "count_fibonacci_tables", "fibonacci_sequence_upto" ], [ "find_all_unique_tables", "count_fibonacci_tables" ] ]
2
[]
false
[]
false
pytest
false
[]
true
117a2bf5f57c4a78d06054ba7762e73162db6887
fa741a735bd9b9db7fcb3ebcb928839d4978deb8
v1.0
instruct
Taco
Taco_78153_I
Consider that you are working with a method where you have to determine if a given number is a "Special Number." A "Special Number" is defined as a number whose digits can be rearranged to form at least one square number. Input T, the number of test cases. N, the number for which you have to determine if it is a Sp...
import math from itertools import permutations def is_special_number(n: int) -> str: """ Determine if the digits of the given number can be rearranged to form a square number. """ digits = str(n) seen_permutations = set() for perm in permutations(digits): perm_number = int(''.join(...
from solution import is_special_number, process_test_cases def test_is_special_number(): assert is_special_number(1) == "YES" assert is_special_number(10) == "YES" assert is_special_number(35) == "NO" assert is_special_number(4) == "YES" assert is_special_number(13) == "NO" assert is_special_nu...
[ { "docstring": "Determine if the digits of the given number can be rearranged to form a square number.", "function_declaration": "def is_special_number(n):", "function_name": "is_special_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def process_test_ca...
[ 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": "from itertools import permutations\nimport math\n\ndef is_special_number(N):\n \"\"\"\n Determines if the given number N is a Special Number.\n \n A Sp...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00078153", "row_id": 78153, "seed_ids": "[15809]" }
0.633912
Taco_78153
I
[ "is_special_number", "process_test_cases", "run" ]
3
[ [ "process_test_cases", "is_special_number" ], [ "run", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
a117c16a29fc91ebffa7024b95e9f2192e538e57
326fa325e47b3f1a4981fc50a07b3a3bb862d6d6
v1.0
instruct
Taco
Taco_78216_I
You are given a rectangular matrix of characters where '1' represents land and '0' represents water. An island is a group of adjacent lands connected horizontally or vertically. You need to count the number of distinct islands in the matrix. Input The first input line contains two integers, R and C (1 ≤ R, C ≤ 50), w...
def num_islands(matrix): if not matrix: return 0 R = len(matrix) C = len(matrix[0]) visited = [[False for _ in range(C)] for _ in range(R)] def dfs(r, c): stack = [(r, c)] while stack: row, col = stack.pop() if 0 <= row < R and 0 <= col < C and not v...
import pytest from solution import count_islands def test_single_island(): input_str = """4 5 11110 11010 11000 00000""" assert count_islands(input_str) == 1 def test_multiple_islands(): input_str = """4 5 11000 11000 00100 00011""" assert count_islands(input_str) == 3 def test_no_islands(): inpu...
[ { "docstring": null, "function_declaration": "def num_islands(matrix):", "function_name": "num_islands", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(input_str)" }...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_islands(matrix):\n \"\"\"\n Returns the number of distinct islands (connected groups of '1') in the given matrix.\n \"\"\"\n \n def dfs(ma...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078216", "row_id": 78216, "seed_ids": "[14982]" }
0.590155
Taco_78216
I
[ "num_islands", "parse_input", "count_islands" ]
3
[ [ "count_islands", "num_islands" ], [ "count_islands", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
7607d3cc235e4bee09a269fd623772621eeaad8d
f0a20be44d891c0652dd2ba0dea381699ee47359
v1.0
instruct
Taco
Taco_78247_I
The National Railway Company is planning to construct a new rail network. The network will consist of stations connected by direct rail lines. Each rail line has a specific construction cost. The goal is to connect all the stations with the minimum possible construction cost. The network does not need to be fully conn...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] = xroot ...
from solution import min_construction_cost def test_sample_input_1(): assert min_construction_cost(4, 5, [(1, 2, 5), (1, 3, 10), (2, 3, 2), (3, 4, 1), (2, 4, 8)]) == 8 def test_sample_input_2(): assert min_construction_cost(3, 3, [(1, 2, 1), (1, 3, 4), (2, 3, 2)]) == 3 def test_min_construction_cost_single_s...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 1 ]
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 if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00078247", "row_id": 78247, "seed_ids": "[15372]" }
0.740636
Taco_78247
I
[ "find", "union", "kruskal", "min_construction_cost" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "min_construction_cost", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
333b7091776afe4a573ea5f7c1cbb95db6011430
62bdde79a503c58b951648062a074f78a8f5e686
v1.0
instruct
Taco
Taco_78265_I
A fleet of drones needs to be recharged using charging stations. Each drone has a specific amount of initial battery life. A drone can move to a neighboring cell (east, west, north, or south), consuming 1 unit of battery for each move. If a drone runs out of battery, it cannot move anymore. Your task is to optimize the...
from collections import deque def bfs_shortest_distance(w, h, stations): directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] # Initialize distances with -1 (unreachable) distances = [[-1] * w for _ in range(h)] queue = deque() for x, y in stations: queue.append((x, y)) distances[y-...
from solution import minimum_moves_to_charging def test_example_1(): drones = [(1, 1, 3), (4, 4, 2), (5, 5, 10)] stations = [(2, 2), (4, 3)] assert minimum_moves_to_charging(3, 5, 5, drones, stations) == 3 def test_example_2(): drones = [(1, 1, 1), (3, 3, 5)] stations = [(2, 2)] assert minimum...
[ { "docstring": null, "function_declaration": "def bfs_shortest_distance(w, h, stations):", "function_name": "bfs_shortest_distance", "parameter_list": "(w, h, stations)" }, { "docstring": null, "function_declaration": "def minimum_moves_to_charging(N, W, H, drones, stations):", "func...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\nimport sys\n\ndef minimum_moves(drones, stations, W, H):\n def bfs(visited, queue):\n while queue:\n x, y, dist...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00078265", "row_id": 78265, "seed_ids": "[2891]" }
0.630707
Taco_78265
I
[ "bfs_shortest_distance", "minimum_moves_to_charging" ]
2
[ [ "minimum_moves_to_charging", "bfs_shortest_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4df6a9dd547ddf634ba4f3175d5644b3430c998e
61ccde9dfd4eb990682d962e0c627ccd910db293
v1.0
instruct
Taco
Taco_78309_I
### Preface You have been hired by a logistics company to optimize the delivery routes for their delivery trucks. The goal is to find the shortest possible route that allows each truck to deliver all packages and return to the warehouse. ### Problem Given is a set of delivery locations and a starting point for the tru...
import itertools import math def calculate_distance(loc1, loc2): """ Calculate the Euclidean distance between two points represented as dictionaries with 'x' and 'y' coordinates. """ return math.sqrt((loc1['x'] - loc2['x'])**2 + (loc1['y'] - loc2['y'])**2) def tsp(locations): """ Solve the Tra...
from solution import tsp def test_tsp_simple_case(): locations = [ {"id": 0, "x": 0, "y": 0}, {"id": 1, "x": 2, "y": 3}, {"id": 2, "x": 5, "y": 4}, ] result = tsp(locations) assert "The best route is: 0 -> " in result assert " -> 0 with a total distance of " in result def t...
[ { "docstring": "Calculate the Euclidean distance between two points represented as dictionaries with 'x' and 'y' coordinates.", "function_declaration": "def calculate_distance(loc1, loc2):", "function_name": "calculate_distance", "parameter_list": "(loc1, loc2)" }, { "docstring": "Solve the ...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\nimport math\n\ndef total_route_distance(route, locations):\n \"\"\"\n Calculate the total distance of the given route.\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00078309", "row_id": 78309, "seed_ids": "[5678]" }
0.657385
Taco_78309
I
[ "calculate_distance", "tsp" ]
2
[ [ "tsp", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1bcd19f9acaa2ec1a18004bc889861221753918d
2484372811d60a292bc3a5b79bf79e97c4e04020
v1.0
instruct
Taco
Taco_78319_I
# Water Jug Problem You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two jugs. If z liters of water is measurable, you must have z liters of water contained within one or b...
def gcd(a, b): while b != 0: a, b = b, a % b return a def canMeasureWater(x: int, y: int, z: int) -> bool: """ Determine if it's possible to measure exactly z liters using jugs of size x and y. """ # If z exceeds the combined capacity of both jugs, it's impossible if z > x + y: ...
from solution import canMeasureWater def test_can_measure_water_example_1(): assert canMeasureWater(3, 5, 4) == True def test_can_measure_water_example_2(): assert canMeasureWater(2, 6, 5) == False def test_can_measure_water_example_3(): assert canMeasureWater(1, 2, 3) == True def test_can_measure_water...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Determine if it's possible to measure exactly z liters using jugs of size x and y.", "function_declaration": "def canMeasureWater(x, y, z):", "function...
[ 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 gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\ndef canMeasureWater(x: int, y: int, z: int) -> bool:\n \"\"\"\n Determine if it's...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078319", "row_id": 78319, "seed_ids": "[10169]" }
0.609416
Taco_78319
I
[ "gcd", "canMeasureWater" ]
2
[ [ "canMeasureWater", "gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8cb3b806d3b28a096a47e8bb70eac9929e9d3583
839abe1300fd03cdfbc06d90a747a1b963602599
v1.0
instruct
Taco
Taco_78348_I
Dr. Roboto is a researcher who loves analyzing communication networks. He’s currently studying a network of servers connected by unidirectional communication channels. The network is represented as a directed graph with N nodes and M edges. Each edge has an associated non-negative weight representing the round-trip com...
import heapq def dijkstra(graph, start): """ Apply Dijkstra's algorithm to find the shortest paths from start node to all other nodes. """ n = len(graph) distances = [float('inf')] * n distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, cur...
from solution import minimum_round_trip_delay def test_case_1(): n = 4 m = 4 s = 1 edges = [(1, 2, 10), (2, 3, 10), (3, 4, 10), (4, 1, 10)] assert minimum_round_trip_delay(n, m, s, edges) == 40 def test_case_2(): n = 4 m = 3 s = 1 edges = [(1, 2, 10), (2, 3, 10), (3, 4, 10)] as...
[ { "docstring": "Apply Dijkstra's algorithm to find the shortest paths from start node to all other nodes.", "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": "Find the minimum round-trip delay starting and...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start):\n \"\"\"\n Apply Dijkstra's algorithm to find the shortest paths from start node to all other nodes.\n \"\"\"\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078348", "row_id": 78348, "seed_ids": "[10436]" }
0.665638
Taco_78348
I
[ "dijkstra", "minimum_round_trip_delay", "main" ]
3
[ [ "minimum_round_trip_delay", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b95ff25bc7ec1b391ab6f465d4ce957c6dc880ff
1fadb9a59370fd87a7531d654a92333031de07c9
v1.0
instruct
Taco
Taco_78365_I
A group of friends is planning a road trip, and they want to minimize the cost of fuel. They have multiple car options, each with a different fuel efficiency and fuel cost. Given the duration of the trip, the fuel efficiency of each car, and the price of fuel per unit distance for each car, your task is to determine th...
def calculate_fuel_cost(d, t, cars): """ Calculate the total fuel cost for each car and identify the car with the minimum fuel cost. """ min_cost = float('inf') min_car_index = -1 costs = [] for i in range(d): efficiency, price = cars[i] cost = (t / efficiency) * price ...
from solution import road_trip_cost_minimizer def test_single_dataset(): input_data = "3 500\n10 5\n15 4\n20 3\n0 0" expected_output = "250.00\n133.33\n75.00\nCar 3" assert road_trip_cost_minimizer(input_data) == expected_output def test_multiple_datasets(): input_data = "3 500\n10 5\n15 4\n20 3\n2 30...
[ { "docstring": "Calculate the total fuel cost for each car and identify the car with the minimum fuel cost.", "function_declaration": "def calculate_fuel_cost(d, t, cars):", "function_name": "calculate_fuel_cost", "parameter_list": "(d, t, cars)" }, { "docstring": null, "function_declara...
[ 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 calculate_fuel_costs(d, t, car_specs):\n \"\"\"\n Calculates the total fuel cost for each car and identifies the car with the minimum fuel cost.\n \n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078365", "row_id": 78365, "seed_ids": "[23045]" }
0.674556
Taco_78365
I
[ "calculate_fuel_cost", "process_input", "format_output", "road_trip_cost_minimizer" ]
4
[ [ "process_input", "calculate_fuel_cost" ], [ "road_trip_cost_minimizer", "format_output" ], [ "road_trip_cost_minimizer", "process_input" ] ]
3
[ "process_input", "format_output" ]
false
[]
false
pytest
true
[]
true
1a067cf3f3ce16ce5d89dd80dbc7f2ef408c757b
08055b066e0976c944e3d890b67b1f8500a4d2df
v1.0
instruct
Taco
Taco_78446_I
You are working on a system that monitors spaceship cargo. Each spaceship can carry a certain number of distinct cargo items, each identified by a unique ID number. The cargo system monitors both incoming and outgoing ships, tracking several cargo parameters. In tracking the cargo, every ship is assigned a record that...
def is_fibonacci(n, fib_set): """ Check if a number is in the precomputed set of Fibonacci numbers. """ return n in fib_set def generate_fibonacci_up_to(max_val): """ Generate all Fibonacci numbers up to a maximum value and return as a set. """ fib_set = set() a, b = 0, 1 while ...
import pytest from solution import validate_cargo_records def test_validate_cargo_records_all_valid(): assert validate_cargo_records([(2, 1, 1), (4, 0, 1, 1, 2)]) == ['YES', 'YES'] def test_validate_cargo_records_some_invalid(): assert validate_cargo_records([(3, 2, 3, 4)]) == ['NO'] assert validate_cargo...
[ { "docstring": "Check if a number is in the precomputed set of Fibonacci numbers.", "function_declaration": "def is_fibonacci(n, fib_set):", "function_name": "is_fibonacci", "parameter_list": "(n, fib_set)" }, { "docstring": "Generate all Fibonacci numbers up to a maximum value and return as...
[ 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_fibonacci(n, fib_set):\n \"\"\"\n Check if a number is in the precomputed set of Fibonacci numbers.\n \"\"\"\n return n in fib_set\n\ndef genera...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078446", "row_id": 78446, "seed_ids": "[19317]" }
0.628553
Taco_78446
I
[ "is_fibonacci", "generate_fibonacci_up_to", "validate_cargo_records" ]
3
[ [ "validate_cargo_records", "generate_fibonacci_up_to" ], [ "validate_cargo_records", "is_fibonacci" ] ]
2
[]
false
[]
false
pytest
true
[]
true
673ac0bbee3f1e3099139f4b0c61cc76d1715d99
bb19c4dd985c8dd4c6d4ba2ad94cf1100de208ee
v1.0
instruct
Taco
Taco_78509_I
Dana loves exploring new places, and she has recently taken an interest in a series of ancient cities laid out in a line. The cities are numbered from 1 to n and there are m roads connecting pairs of cities. Each road has a certain beauty index, which represents how scenic the road is. Dana wants to find the most scen...
from collections import defaultdict import heapq def preprocess_graph(n, edges): """ Preprocess the graph using the given edges and returns an adjacency list. """ graph = defaultdict(list) for u, v, b in edges: graph[u].append((v, b)) graph[v].append((u, b)) return graph def ma...
from solution import most_scenic_paths def test_most_scenic_paths_basic(): n, m, q = 5, 7, 3 edges = [ (1, 2, 4), (2, 3, 8), (1, 3, 5), (4, 5, 1), (3, 4, 6), (2, 5, 10), (3, 5, 7), ] queries = [ (1, 5), (2, 4), (4, 1), ...
[ { "docstring": "Preprocess the graph using the given edges and returns an adjacency list.", "function_declaration": "def preprocess_graph(n, edges):", "function_name": "preprocess_graph", "parameter_list": "(n, edges)" }, { "docstring": "Use Dijkstra's-like algorithm to find the maximum scen...
[ 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 find_most_scenic_path(n, m, q, roads, queries):\n def dikjstra_max_min_heap(graph, start, end):\n # distance now stores the max of mi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078509", "row_id": 78509, "seed_ids": "[16884]" }
0.693686
Taco_78509
I
[ "preprocess_graph", "max_scenic_path", "most_scenic_paths" ]
3
[ [ "most_scenic_paths", "max_scenic_path" ], [ "most_scenic_paths", "preprocess_graph" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2c0b52fc77da0fa0e1a282ab3c639336796345de
acfddc7e7937f022ae1a9736b6f0bd16317eace0
v1.0
instruct
Taco
Taco_78554_I
Johnny has recently started learning about number theory and is fascinated by the concept of prime numbers. He came up with a problem for himself and asked you to help him solve it. Given an integer `n`, return the smallest prime number `p` such that `p` is greater than or equal to `n`. A prime number is a natural nu...
def is_prime(num): """ Check if the given number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False ...
from solution import is_prime, smallest_prime_ge def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(20) == False assert is_prime(23) == True assert is_prime(1) == False def test_smallest_prime_g...
[ { "docstring": "Check if the given number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number p such that p is greater than or equal to n.", "function_declaration": "def 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 prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078554", "row_id": 78554, "seed_ids": "[16189]" }
0.604242
Taco_78554
I
[ "is_prime", "smallest_prime_ge" ]
2
[ [ "smallest_prime_ge", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c5659ce9e4e909267bafafb6f0e1920188d914a9
00dce7923be07e1b8118117d0298b44d6b1bec75
v1.0
instruct
Taco
Taco_78568_I
You are given an undirected graph with n nodes and m edges. Each edge has a weight associated with it. Your task is to find the minimum spanning tree (MST) of this graph and compute the product of the weights of all the edges in the MST. Input The first line contains two integers n (1 ≤ n ≤ 1000) and m (0 ≤ m ≤ 1000...
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]...
import pytest from solution import product_of_weights_in_mst def test_example_case_1(): n = 4 m = 5 edge_list = [ (1, 2, 3), (1, 3, 1), (2, 3, 3), (2, 4, 6), (3, 4, 2) ] assert product_of_weights_in_mst(n, m, edge_list) == 6 def test_example_case_2(): n ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\nMOD = 998244353\n\ndef find_mst_product(n, m, edges):\n if m == 0:\n return 1\n\n # Kruskal's algorithm with Union-Find data structure...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00078568", "row_id": 78568, "seed_ids": "[3974]" }
0.758876
Taco_78568
I
[ "find", "union", "kruskal_mst", "product_of_weights_in_mst", "main" ]
5
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "product_of_weights_in_mst", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
e401fe648aa0f926e5803326ebfbdbd237db541f
bd86e8e1b7abb0237d5a00c007b584a5fb40c57b
v1.0
instruct
Taco
Taco_78581_I
Given an array of integers, your task is to calculate the "digit sum" of all elements in the array. The digit sum of a number is defined as the sum of its individual digits. After calculating the digit sum of each element, find and return the maximum digit sum among them. For example: ```python arr = [34, 65, 127, 89]...
def digit_sum(n): """ Returns the sum of the digits of the given number n. """ return sum(int(digit) for digit in str(n)) def max_digit_sum(arr): """ Returns the maximum digit sum among the elements of the array arr. """ return max(digit_sum(num) for num in arr)
from solution import digit_sum, max_digit_sum def test_digit_sum(): assert digit_sum(34) == 7 # 3 + 4 assert digit_sum(65) == 11 # 6 + 5 assert digit_sum(127) == 10 # 1 + 2 + 7 assert digit_sum(89) == 17 # 8 + 9 assert digit_sum(0) == 0 # 0 def test_max_digit_sum(): assert max_digit_sum([34, 6...
[ { "docstring": "Returns the sum of the digits of the given number n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "Returns the maximum digit sum among the elements of the array arr.", "function_declaration": "def m...
[ 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 digit_sum(n):\n \"\"\"\n Returns the sum of the digits of the given number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef max_digi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078581", "row_id": 78581, "seed_ids": "[17080]" }
0.700082
Taco_78581
I
[ "digit_sum", "max_digit_sum" ]
2
[ [ "max_digit_sum", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13852e1f5da957515ecb002d67bbdb736d884d41
b61e92762ae060a844a0352ed72e94b453d53a55
v1.0
instruct
Taco
Taco_78608_I
Shiro loves solving puzzles and he recently came across the 'Sudoku Solver' challenge. In this challenge, you are given a partially filled 9x9 grid of a Sudoku puzzle and you need to fill in the empty cells such that each row, each column, and each of the nine 3x3 subgrids that compose the grid contain all of the digit...
def is_valid(board, row, col, num): """ Check if it's valid to place the number 'num' in the board at (row, col). """ # Check if the number is in the current row or column for i in range(9): if board[row][i] == num or board[i][col] == num: return False # Check if the num...
from solution import solve_sudoku, is_valid, solve_and_print_sudoku def test_is_valid(): grid = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0,...
[ { "docstring": "Check if it's valid to place the number 'num' in the board at (row, col).", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Solve the Sudoku board using backtracking.", ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n # Check if 'num' is not in the current row, column and 3x3 subgrid\n for i in range(9):\n if board[row][i] == nu...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00078608", "row_id": 78608, "seed_ids": "[21951]" }
0.630024
Taco_78608
I
[ "is_valid", "solve_sudoku", "print_board", "solve_and_print_sudoku" ]
4
[ [ "solve_and_print_sudoku", "print_board" ], [ "solve_and_print_sudoku", "solve_sudoku" ], [ "solve_sudoku", "is_valid" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5d2255f231b671dca8545a7ad3b806ca9e2d5cd9
9525ee987878650ca00e56c189fc762cfe7996e5
v1.0
instruct
Taco
Taco_78625_I
You have been tasked with organizing a race event. For the event, you need to design a track such that the total length of the track is minimized but it contains a series of required waypoints. Given a set of waypoints, each with a specific distance between them, determine the minimum total distance of the track if you...
from itertools import permutations from math import sqrt def calculate_distance(point1, point2): return sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def find_minimum_distance(waypoints): n = len(waypoints) min_distance = float('inf') for perm in permutations(range(n)): ...
def test_calculate_distance(): assert calculate_distance((0, 0), (3, 4)) == 5.0 assert calculate_distance((1, 1), (4, 5)) == 5.0 def test_find_minimum_distance_simple(): waypoints = [(0, 0), (1, 0), (1, 1), (0, 1)] assert find_minimum_distance(waypoints) == 4.0 def test_minimum_track_distance_single_c...
[ { "docstring": null, "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def find_minimum_distance(waypoints):", "function_name": "find_minimum_...
[ 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 itertools\nimport math\n\ndef calculate_distance(point1, point2):\n return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2)\n\ndef mini...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00078625", "row_id": 78625, "seed_ids": "[13128]" }
0.738162
Taco_78625
I
[ "calculate_distance", "find_minimum_distance", "minimum_track_distance", "main" ]
4
[ [ "find_minimum_distance", "calculate_distance" ], [ "minimum_track_distance", "find_minimum_distance" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0477c5a3917fb57ba9bed2a7de485b3e8dfab94a
ae394f5f5dc895dde98f83aadbeb8159b07860fb
v1.0
instruct
Taco
Taco_78665_I
A new online game allows players to form alliances. Each player starts alone and can choose to ally with other players. When a player allies with another player, all their alliances merge into one. There are $n$ players and $m$ moves describing alliances between players. Can you determine if all players are in the sam...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, x, y): xroot = find(parent, x) yroot = find(parent, y) parent[xroot] = yroot def are_all_players_in_same_alliance(n, moves): parent = list(range(n+1)) for u, v in moves: union...
from solution import are_all_players_in_same_alliance def test_players_in_same_alliance_1(): assert are_all_players_in_same_alliance(4, [(1, 2), (2, 3), (3, 4)]) == "yes" def test_players_in_same_alliance_2(): assert are_all_players_in_same_alliance(4, [(1, 2), (3, 4)]) == "no" def test_players_in_same_allia...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }, { "doc...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def are_all_players_in_same_alliance(n, m, moves):\n \"\"\"\n Determine if all players are in the same alliance.\n \n Args:\n n (int): number of pla...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078665", "row_id": 78665, "seed_ids": "[18269]" }
0.600994
Taco_78665
I
[ "find", "union", "are_all_players_in_same_alliance" ]
3
[ [ "are_all_players_in_same_alliance", "find" ], [ "are_all_players_in_same_alliance", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
9286ec0213739e50725a44b4e983733cff53c717
cfab58229206a381793f92bbc0652baf684d6e5b
v1.0
instruct
Taco
Taco_78681_I
You are given a backpack with a limited weight capacity and a collection of items, each with a specific weight and value. Your goal is to determine the maximum value you can carry in the backpack without exceeding the weight capacity. This is a variation of the Knapsack Problem, where you need to select a subset of th...
def knapsack(W, N, items): dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N + 1): weight, value = items[i - 1] for w in range(W + 1): if weight <= w: dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight] + value) else: dp[i][w] ...
import pytest from solution import max_value def test_example_case(): W = 5 N = 4 items = ['2 3', '3 4', '4 5', '5 6'] assert max_value(W, N, items) == 7 def test_minimum_capacity(): W = 1 N = 1 items = ['1 1'] assert max_value(W, N, items) == 1 def test_zero_values(): W = 10 ...
[ { "docstring": null, "function_declaration": "def knapsack(W, N, items):", "function_name": "knapsack", "parameter_list": "(W, N, items)" }, { "docstring": null, "function_declaration": "def max_value(W, N, item_data):", "function_name": "max_value", "parameter_list": "(W, N, ite...
[ 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 knapsack(W, items):\n \"\"\"\n Returns the maximum value that can be achieved with the given weight capacity W and the list of items.\n \"\"\"\n dp...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078681", "row_id": 78681, "seed_ids": "[9883]" }
0.716897
Taco_78681
I
[ "knapsack", "max_value" ]
2
[ [ "max_value", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8e2e231173d5a45128fb24cd19812265a6c48934
5f24f6792dd93d9934278700eb5300936ee5ed4a
v1.0
instruct
Taco
Taco_78712_I
Consider a land surveying expedition on a field represented as a grid of N x M dimensions. The expedition team is to traverse from the top-left corner of the grid to the bottom-right corner. Each cell in the grid has a certain elevation given, and the challenge is to find a path that minimizes the total elevation chang...
def min_elevation_change(grid): """ This function computes the minimum possible total elevation change to traverse from the top-left corner to the bottom-right corner of the grid. """ N = len(grid) M = len(grid[0]) # Create a dp table to store the minimum elevation change for each cell ...
from solution import min_elevation_change, solve def test_min_elevation_change(): grid = [ [1, 3, 5], [2, 8, 4], [3, 2, 1] ] assert min_elevation_change(grid) == 4 def test_solve_example_1(): input_string = "3 3\n1 3 5\n2 8 4\n3 2 1\n" assert solve(input_string) == 4 def t...
[ { "docstring": "This function computes the minimum possible total elevation change to traverse from\nthe top-left corner to the bottom-right corner of the grid.", "function_declaration": "def min_elevation_change(grid):", "function_name": "min_elevation_change", "parameter_list": "(grid)" }, { ...
[ 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_elevation_change(grid):\n import heapq\n \n N = len(grid)\n M = len(grid[0])\n \n if N == 0 or M == 0:\n return 0\n \n direc...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00078712", "row_id": 78712, "seed_ids": "[16725]" }
0.66286
Taco_78712
I
[ "min_elevation_change", "solve" ]
2
[ [ "solve", "min_elevation_change" ] ]
1
[]
false
[]
false
pytest
true
[]
true
206f5a7c04668af6b566f494b29f2bda016be317
98bf2d10801c84b14251f2ef1a1c9189b4846aba
v1.0
instruct
Taco
Taco_78717_I
The kingdom of Graphland has n cities connected by m bidirectional roads. Each road can have different widths. The width of a road is defined in terms of the maximum number of vehicles that can travel simultaneously on that road. A trade route between two cities is a path that allows merchants to travel from one city t...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot]...
def test_min_cut_edge_width_example(): n = 5 m = 6 edges_list = [ (1, 2, 4), (1, 3, 2), (2, 3, 1), (2, 4, 3), (3, 5, 5), (4, 5, 6) ] assert min_cut_edge_width(n, m, edges_list) == 3 def test_min_cut_edge_width_single_edge(): n = 2 m = 1 ed...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078717", "row_id": 78717, "seed_ids": "[7818]" }
0.672513
Taco_78717
I
[ "find", "union", "kruskal", "min_cut_edge_width" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "min_cut_edge_width", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
32d890d505bee296bf6c98ae614ce1f6246e4d17
963e6406d8135b72e7602d5665c35c9ea31349a8
v1.0
instruct
Taco
Taco_78744_I
Alex, a software developer, is working on a project that involves processing a grid of characters. Each cell in the grid contains a single character, which can be either 'A' or 'B'. Alex needs to find the largest rectangular area within this grid that contains only 'A's. Given an $m \times n$ grid filled with characte...
def maximal_rectangle_area(grid): if not grid: return 0 m, n = len(grid), len(grid[0]) heights = [0] * n max_area = 0 for row in grid: for j in range(n): if row[j] == 'A': heights[j] += 1 else: heights[j] = 0 ...
from solution import maximal_rectangle_area def test_example1(): grid = ["AAAAA", "ABAAA", "AABAA", "AAAAA"] assert maximal_rectangle_area(grid) == 8 def test_example2(): grid = ["BBB", "BBB", "BBB"] assert maximal_rectangle_area(grid) == 0 def test_example3(): grid = ["AAABAA", "ABBBAA", "ABAABA...
[ { "docstring": null, "function_declaration": "def maximal_rectangle_area(grid):", "function_name": "maximal_rectangle_area", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def max_histogram_area(heights):", "function_name": "max_histogram_area", "para...
[ 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 maximal_rectangle_area(grid):\n if not grid:\n return 0\n\n m, n = len(grid), len(grid[0])\n heights = [0] * n\n max_area = 0\n \n for...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078744", "row_id": 78744, "seed_ids": "[24790]" }
0.676511
Taco_78744
I
[ "maximal_rectangle_area", "max_histogram_area" ]
2
[ [ "maximal_rectangle_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22efa410684ed627e1b79f7b2cc2d99d90cd5d48
425b434cf61390713a902ab4be5feee966836c9b
v1.0
instruct
Taco
Taco_78855_I
Aman loves reading and has a collection of books. Each book is represented by a unique ID and has its own number of pages. Each page of a book can contain different numbers of words. Aman wants to know the total number of words across all pages in a specific book from his collection. **Help Aman calculate the total nu...
def calculate_total_words(test_cases): results = [] for test_case in test_cases: book_details = test_case['book_details'] query_id = test_case['query_id'] for book in book_details: if book['id'] == query_id: results.append(sum(book['words'])) b...
from solution import solve def test_case_1(): input_text = "2\n3\n1 3 100 200 300\n2 2 50 75\n3 4 10 20 30 40\n2\n2\n1 3 100 200 300\n3 4 10 20 30 40\n3" expected_output = [125, 100] assert solve(input_text) == expected_output def test_case_2(): input_text = "1\n1\n50 3 500 600 700\n50" expected_o...
[ { "docstring": null, "function_declaration": "def calculate_total_words(test_cases):", "function_name": "calculate_total_words", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_text):", "function_name": "parse_input", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def total_words_per_book(test_cases):\n results = []\n for case in test_cases:\n books = case['books']\n query_id = case['query_id']\n f...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078855", "row_id": 78855, "seed_ids": "[11767]" }
0.722751
Taco_78855
I
[ "calculate_total_words", "parse_input", "solve" ]
3
[ [ "solve", "calculate_total_words" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
ddd259e65d6f661996c4ac51500ee988fe19b5f6
852676a80e7b6ed5d2976e545c9786612602a625
v1.0
instruct
Taco
Taco_78909_I
You are given several cryptographic codes, each represented as a string consisting of lowercase English alphabet characters. The security level of each code is determined by the number of distinct substrings it can generate. Your task is to find the security level of the weakest code among the given set, where the weak...
def distinct_substring_count(s): """ Returns the number of distinct substrings in a string s. """ substrings = set() n = len(s) for i in range(n): for j in range(i + 1, n + 1): substrings.add(s[i:j]) return len(substrings) def weakest_security_level(codes): ...
from solution import weakest_security_level def test_single_code(): assert weakest_security_level(["abcde"]) == 15 def test_multiple_codes(): assert weakest_security_level(["abcde", "zzz"]) == 3 # correct minimal substrings count for "zzz" is 3 def test_minimal_case(): assert weakest_security_level(["a"...
[ { "docstring": "Returns the number of distinct substrings in a string s.", "function_declaration": "def distinct_substring_count(s):", "function_name": "distinct_substring_count", "parameter_list": "(s)" }, { "docstring": "Returns the security level of the weakest code.", "function_decla...
[ 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 distinct_substrings_count(s):\n \"\"\"\n Helper function to calculate the number of distinct substrings of a given string `s`.\n \"\"\"\n substring...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078909", "row_id": 78909, "seed_ids": "[11258]" }
0.621243
Taco_78909
I
[ "distinct_substring_count", "weakest_security_level" ]
2
[ [ "weakest_security_level", "distinct_substring_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cfc8ce9261c1c9d0d0bf3f1fe070ed0cfcb5b009
d8d4d0f8b07f6d5b600b7f456ad34f4f2b5fd97e
v1.0
instruct
Taco
Taco_78935_I
There is a city with $n$ transportation stations and $m$ bidirectional roads connecting them. Each road has a travel time of 1 unit. The city transit authority wants to improve efficiency by identifying the longest travel time between the two most distant stations. If the stations are represented as vertices of a grap...
from collections import deque def bfs(graph, start): """ Perform BFS starting from the vertex `start` and return the farthest node and its distance. """ visited = [-1] * len(graph) visited[start] = 0 q = deque([start]) farthest_node = start max_distance = 0 while q: node = ...
from solution import graph_diameter def test_example_1(): n = 4 m = 4 roads = [(1, 2), (2, 3), (3, 4), (4, 1)] assert graph_diameter(n, m, roads) == 2 def test_example_2(): n = 5 m = 4 roads = [(1, 2), (2, 3), (3, 4), (4, 5)] assert graph_diameter(n, m, roads) == 4 def test_single_edg...
[ { "docstring": "Perform BFS starting from the vertex `start` and return the farthest node and its distance.", "function_declaration": "def bfs(graph, start):", "function_name": "bfs", "parameter_list": "(graph, start)" }, { "docstring": null, "function_declaration": "def graph_diameter(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": "from collections import deque\n\ndef bfs(graph, start):\n \"\"\"\n Perform BFS starting from the vertex `start` and return the farthest node and its distance...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078935", "row_id": 78935, "seed_ids": "[9046]" }
0.674584
Taco_78935
I
[ "bfs", "graph_diameter" ]
2
[ [ "graph_diameter", "bfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6285d1bbe16381d3b1735e2110c046fc4183b3b9
8ad15d06da9d20d24776ed68157a492cc4f3a4a4
v1.0
instruct
Taco
Taco_78945_I
A group of friends are playing a game where they have to jump across stones placed in a straight line on a river. The friends start at the first stone, and the goal is to reach the last stone following a set of rules. Each friend can jump up to a maximum number of stones ahead in one jump, but not further. However, the...
def min_jumps_to_cross_stones(T, test_cases): results = [] for i in range(T): N, M = test_cases[i*3] strengths = test_cases[i*3 + 1] W = test_cases[i*3 + 2][0] if strengths[0] < W or strengths[-1] < W: results.append(-1) continue ...
def test_min_jumps_to_cross_stones(): data = "3\n5 2\n3 2 1 4 5\n2\n5 3\n3 2 1 4 5\n3\n4 1\n3 2 1 4\n2" expected_output = [3, 2, -1] T, test_cases = process_input(data) assert min_jumps_to_cross_stones(T, test_cases) == expected_output data = "1\n3 1\n1 1 1\n1" expected_output = [2] T, test...
[ { "docstring": null, "function_declaration": "def min_jumps_to_cross_stones(T, test_cases):", "function_name": "min_jumps_to_cross_stones", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def process_input(data):", "function_name": "process_input"...
[ 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 min_jumps_to_cross_river(T, test_cases):\n results = []\n \n for i in range(T):\n N, M = test_cases[i][0]\n strengths = test_cases[i][1]...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078945", "row_id": 78945, "seed_ids": "[5269]" }
0.689663
Taco_78945
I
[ "min_jumps_to_cross_stones", "process_input", "solve" ]
3
[ [ "solve", "min_jumps_to_cross_stones" ], [ "solve", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
420b33ca88527fa2d226d644664b8fff2d603317
328e11d87e7c0e0c1fba7a8005dabfcab122e9a5
v1.0
instruct
Taco
Taco_78986_I
Given a list of intervals, determine the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Constraints * $1 \leq n \leq 100,000$ * $1 \leq start_i, end_i \leq 1,000,000,000$ * Each interval [start_i, end_i] is represented by two integers, start_i and end_i, where $start...
def min_intervals_to_remove(intervals): """ Determines the minimum number of intervals to remove to make the rest non-overlapping. :param intervals: List of intervals represented as [start, end] :return: Minimum number of intervals to remove """ if not intervals: return 0 # Sort in...
def test_min_intervals_to_remove(): assert min_intervals_to_remove([[1, 2], [2, 3], [3, 4], [1, 3]]) == 1 assert min_intervals_to_remove([[1, 2], [1, 2], [1, 2]]) == 2 assert min_intervals_to_remove([[1, 2], [2, 3]]) == 0 assert min_intervals_to_remove([]) == 0 assert min_intervals_to_remove([[1, 4]...
[ { "docstring": "Determines the minimum number of intervals to remove to make the rest non-overlapping.\n\n:param intervals: List of intervals represented as [start, end]\n:return: Minimum number of intervals to remove", "function_declaration": "def min_intervals_to_remove(intervals):", "function_name": ...
[ 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 erase_overlap_intervals(intervals):\n \"\"\"\n Find the minimum number of intervals to remove to make the intervals non-overlapping.\n :param interval...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078986", "row_id": 78986, "seed_ids": "[4188]" }
0.742668
Taco_78986
I
[ "min_intervals_to_remove", "solve" ]
2
[ [ "solve", "min_intervals_to_remove" ] ]
1
[]
false
[]
false
pytest
false
[]
true
285d563cab1aa3cdf85c24677b8966e5c15bfab0
01baaf6e45ffda2deeb29a988f6c23c1485443c5
v1.0
instruct
Taco
Taco_78988_I
Ivy loves working with binary trees. She comes across a problem where she needs to find the maximum path sum in a binary tree. A path in the binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can be included in the path at most once. The path does no...
class TreeNode: def __init__(self, val=0): self.val = val self.left = None self.right = None def build_tree(level_order, edges): if not level_order: return None nodes = [None] + [TreeNode(val) for val in level_order] for u, v in edges: if nodes[v].left is None: ...
from solution import find_max_path_sum def test_example_case(): n = 5 level_order = [1, 2, 3, 4, 5] edges = [(2, 1), (3, 1), (4, 2), (5, 2)] assert find_max_path_sum(n, level_order, edges) == 11 def test_single_node(): n = 1 level_order = [10] edges = [] assert find_max_path_sum(n, lev...
[]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom collections import defaultdict, deque\n\nsys.setrecursionlimit(10**6)\n\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00078988", "row_id": 78988, "seed_ids": "[10321]" }
0.649337
Taco_78988
I
[ "build_tree", "max_path_sum_helper", "max_path_sum", "find_max_path_sum" ]
4
[ [ "find_max_path_sum", "build_tree" ], [ "find_max_path_sum", "max_path_sum" ], [ "max_path_sum", "max_path_sum_helper" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
1bc8d85d89445b351adbfd35b73faad609e73a5b
70b42ee070ebe04be36e898260abe6c171708ed1
v1.0
instruct
Taco
Taco_79010_I
Develop a program to determine the largest rectangle in a histogram. INPUT: The first line contains the number of test cases t. For each test case, the first line contains n (the number of bars in the histogram). The second line contains n integers representing the heights of the bars. OUTPUT: For each test case, o...
def largest_rectangle_area(histogram): """ Calculate the largest rectangle area in a histogram. :param histogram: List of integers representing the heights of the histogram :return: The area of the largest rectangle possible in the histogram """ # Create an empty stack. The stack holds indexes o...
def test_largest_rectangle_area(): # Test cases from the prompt assert largest_rectangle_area([2, 1, 5, 6, 2, 3, 2]) == 10 # Additional test cases assert largest_rectangle_area([6, 2, 5, 4, 5, 1, 6]) == 12 assert largest_rectangle_area([1, 1, 1, 1, 1, 1, 1]) == 7 assert largest_rectangle_area([1...
[ { "docstring": "Calculate the largest rectangle area in a histogram.\n:param histogram: List of integers representing the heights of the histogram\n:return: The area of the largest rectangle possible in the histogram", "function_declaration": "def largest_rectangle_area(histogram):", "function_name": "l...
[ 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 largest_rectangle_area(histograms):\n def calculate_max_area(histogram):\n n = len(histogram)\n stack = []\n max_area = 0\n\n in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079010", "row_id": 79010, "seed_ids": "[977]" }
0.632811
Taco_79010
I
[ "largest_rectangle_area", "process_histograms", "parse_input", "generate_output" ]
4
[ [ "process_histograms", "largest_rectangle_area" ] ]
1
[ "parse_input", "generate_output" ]
false
[]
false
pytest
false
[]
true
768e8760a39e4d367dcebfc46c07819748fe018d
0f066dc9aa113d8a3862f1b04257681bf1227f73
v1.0
instruct
Taco
Taco_79031_I
Amelia loves prime numbers and enjoys finding interesting properties about them. One day, her friend challenged her to find the smallest prime number larger than a given integer. Amelia finds this an intriguing problem and decides to write a program to solve it quickly. -----Task----- Your task is to write a program t...
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 smallest_prime_greater_than(N): candid...
from solution import smallest_prime_greater_than def test_example_1(): assert smallest_prime_greater_than(10) == 11 def test_example_2(): assert smallest_prime_greater_than(14) == 17 def test_on_prime_input(): assert smallest_prime_greater_than(17) == 19 def test_large_input(): assert smallest_prime...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def smallest_prime_greater_than(N):", "function_name": "smallest_prime_greater_than", "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(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00079031", "row_id": 79031, "seed_ids": "[12860]" }
0.58242
Taco_79031
I
[ "is_prime", "smallest_prime_greater_than" ]
2
[ [ "smallest_prime_greater_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d8e8ac04bc6169843a39e200fcb75a84f52dca3b
61e4a683c00bc5c50c386fe31b8b2ffee6c6189b
v1.0
instruct
Taco
Taco_79036_I
You are given a binary tree with N nodes. Each node has an integer value assigned to it. Your task is to find the sum of values of nodes on the longest path from the root to any leaf. If there are multiple longest paths, consider the path with the maximum sum of node values. Input: The first line contains an integer ...
class TreeNode: def __init__(self, value): self.value = value self.children = [] def build_tree(n, values, edges): nodes = [TreeNode(values[i]) for i in range(n)] for u, v in edges: nodes[u-1].children.append(nodes[v-1]) nodes[v-1].children.append(nodes[u-1]) return node...
def test_example_1(): n = 5 values = [1, 2, 3, 4, 5] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] assert solve(n, values, edges) == 8 def test_example_2(): n = 3 values = [10, 2, 3] edges = [(1, 2), (1, 3)] assert solve(n, values, edges) == 13 def test_single_node_tree(): n = 1 val...
[]
[ 0, 1 ]
1
medium
0.5
{ "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_max_sum_longest_path(N, values, edges):\n tree = defaultdict(list)\n for U, V in edges:\n tree[U].appe...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00079036", "row_id": 79036, "seed_ids": "[24352]" }
0.706551
Taco_79036
I
[ "build_tree", "find_longest_path_sum", "solve" ]
3
[ [ "solve", "build_tree" ], [ "solve", "find_longest_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
512c7208873b55ff4895eba55f592700fa3385e4
5007947fd4fdffdfe8f8a33236cf4888ce84b43c
v1.0
instruct
Taco
Taco_79117_I
A large computer network consists of $N$ computers connected in an acyclic, undirected graph (i.e., a tree). Each edge in the graph has an associated cost representing the latency between the two computers it connects. The root computer is always computer $1$, and we need to consider paths between $1$ and every other c...
import heapq def dijkstra(tree, number_of_nodes, start): distances = {node: float('infinity') for node in range(1, number_of_nodes + 1)} distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) ...
from solution import minimum_total_latency def test_example_case(): assert minimum_total_latency(6, 3, [(1, 2, 1), (1, 3, 2), (2, 4, 1), (2, 5, 2), (5, 6, 1)]) == 3 def test_min_k(): assert minimum_total_latency(5, 1, [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 5, 6)]) == 0 def test_same_latencies(): assert mi...
[ { "docstring": null, "function_declaration": "def dijkstra(tree, number_of_nodes, start):", "function_name": "dijkstra", "parameter_list": "(tree, number_of_nodes, start)" }, { "docstring": null, "function_declaration": "def minimum_total_latency(N, K, connections):", "function_name"...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from heapq import heappush, heappop\n\ndef min_total_latency(N, K, edges):\n from collections import defaultdict\n import heapq\n \n # Build graph\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00079117", "row_id": 79117, "seed_ids": "[21526]" }
0.618252
Taco_79117
I
[ "dijkstra", "minimum_total_latency" ]
2
[ [ "minimum_total_latency", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bf72279979ed1a1d0761ef068cf353cac2332f19
4d094b2be0eb167386f22f2a518badc6ffdd4477
v1.0
instruct
Taco
Taco_79129_I
Watson gives Sherlock a list of positive integers and asks him to find the first integer in the list that occurs only once. Help Sherlock. You are given a list of integers. You have to find the first integer that occurs only once in the list. If no such integer exists, print -1. Input and Output: The first line contai...
def first_unique_number(test_cases): results = [] for case in test_cases: count = {} for num in case: count[num] = count.get(num, 0) + 1 found = -1 for num in case: if count[num] == 1: found = num break results.appen...
import pytest from solution import first_unique_number, parse_input, produce_output, solve_problem def test_first_unique_number(): assert first_unique_number([[2, 3, 4, 2, 3]]) == [4] assert first_unique_number([[1, 2, 3, 4, 5, 1]]) == [2] assert first_unique_number([[7, 7, 7, 7]]) == [-1] assert first...
[ { "docstring": null, "function_declaration": "def first_unique_number(test_cases):", "function_name": "first_unique_number", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "paramet...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_first_non_repeating_integer(test_cases):\n \"\"\"\n Given a list of test cases, finds and returns the first integer in each list that\n occurs on...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079129", "row_id": 79129, "seed_ids": "[14771]" }
0.52681
Taco_79129
I
[ "first_unique_number", "parse_input", "produce_output", "solve_problem" ]
4
[ [ "solve_problem", "first_unique_number" ], [ "solve_problem", "parse_input" ], [ "solve_problem", "produce_output" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
2f5514982329fb3da34411ac5cca11ac9a5e9592
31d828e26e19fce6a29f8f073ee24ef4cfad1e72
v1.0
instruct
Taco
Taco_79141_I
You are tasked with developing a program to analyze the distribution of words in a series of text files and determine which category each file most likely belongs to based on word frequency. The three categories are: News, Sports, and Entertainment. You are provided with a training set of documents that are pre-categor...
import os from collections import Counter, defaultdict import string import math def read_documents(directory): documents = [] for filename in os.listdir(directory): filepath = os.path.join(directory, filename) if os.path.isfile(filepath): with open(filepath, 'r') as file: ...
import pytest from solution import classify_new_document, preprocess, read_documents, get_word_frequencies def test_preprocess(): text = "Hello, World!" assert preprocess(text) == ["hello", "world"] def test_get_word_frequencies(): docs = ["Hello world", "world of Python"] word_freq = get_word_frequen...
[ { "docstring": null, "function_declaration": "def read_documents(directory):", "function_name": "read_documents", "parameter_list": "(directory)" }, { "docstring": "Basic preprocessing of text by:\n- Converting to lowercase\n- Removing punctuation", "function_declaration": "def preproces...
[ 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 os\nimport string\nfrom collections import Counter, defaultdict\nimport math\n\ndef tokenize(text):\n \"\"\"\n Tokenizes the input text into words.\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00079141", "row_id": 79141, "seed_ids": "[12637]" }
0.540024
Taco_79141
I
[ "read_documents", "preprocess", "get_word_frequencies", "classify_document", "classify_new_document" ]
5
[ [ "classify_document", "get_word_frequencies" ], [ "classify_document", "preprocess" ], [ "classify_new_document", "classify_document" ], [ "classify_new_document", "read_documents" ], [ "get_word_frequencies", "preprocess" ] ]
5
[]
false
[]
false
pytest
true
[]
true
115ec1aa41cfb75fd3bf073e714307aa48171ada
a2240e1619a38838d379d326b3049570c0f6fc04
v1.0
instruct
Taco
Taco_79159_I
Jamie is a keen camper and loves to track the weather during his camping trips. On one such trip, Jamie decided to record the highest and lowest temperatures every day. After coming back, Jamie realized that it would be interesting to find the temperature range he experienced during the trip. Given the number of days ...
def max_temperature_difference(test_cases): """ Determines the maximum difference in temperatures for multiple test cases. Parameters: test_cases (list of list of tuple): Each element is a test case, which is a list of tuples with highest and lowest temperat...
from solution import process def test_example_case(): input_str = "2\n3\n30 10\n40 20\n25 5\n2\n15 5\n10 0\n" expected_output = [35, 15] assert process(input_str) == expected_output def test_single_day(): input_str = "1\n1\n0 -50\n" expected_output = [50] assert process(input_str) == expected_...
[ { "docstring": "Determines the maximum difference in temperatures for multiple test cases.\n\nParameters:\ntest_cases (list of list of tuple): Each element is a test case, which is a list \n of tuples with highest and lowest temperatures.\n \...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_temperature_range(T, test_cases):\n \"\"\"\n Returns a list of the maximum temperature differences for each test case.\n \n Parameters:\n T ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079159", "row_id": 79159, "seed_ids": "[16581]" }
0.670146
Taco_79159
I
[ "max_temperature_difference", "parse_input", "process" ]
3
[ [ "process", "max_temperature_difference" ], [ "process", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
512157472d4b438773a4b41a2a3ffa7b4d5b82af
cf61bb85f07b89c4b88af1f0be59361ed2d5d062
v1.0
instruct
Taco
Taco_79188_I
You have been hired by a top-security agency to develop an encryption mechanism for their messaging system. The mechanism uses a unique method of shifting the positions of characters within a string while preserving the order of non-letter characters. Your task is to write a function that takes a string and an intege...
def shift_char(c, k): if 'a' <= c <= 'z': return chr((ord(c) - ord('a') + k) % 26 + ord('a')) elif 'A' <= c <= 'Z': return chr((ord(c) - ord('A') + k) % 26 + ord('A')) else: return c def shift_string(s, k): """ Shifts all alphabetic characters in the string s by k positions ...
from solution import shift_string def test_shift_string_simple_case(): assert shift_string("Hello, World!", 3) == "Khoor, Zruog!" def test_shift_string_with_numbers(): assert shift_string("Encrypt123", 5) == "Jshwduy123" def test_shift_string_wrap_around(): assert shift_string("xyz", 3) == "abc" def tes...
[ { "docstring": null, "function_declaration": "def shift_char(c, k):", "function_name": "shift_char", "parameter_list": "(c, k)" }, { "docstring": "Shifts all alphabetic characters in the string s by k positions\nin the alphabet, preserving the positions of non-alphabetic characters.", "f...
[ 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 shift_char(c, k):\n if 'a' <= c <= 'z':\n return chr((ord(c) - ord('a') + k) % 26 + ord('a'))\n elif 'A' <= c <= 'Z':\n return chr((ord(c) ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00079188", "row_id": 79188, "seed_ids": "[20236]" }
0.726349
Taco_79188
I
[ "shift_char", "shift_string" ]
2
[ [ "shift_string", "shift_char" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4197cbd2168913ca96aacbd7f45d4b19c0a419b
8c2348daa2c9e81425e8ff832be8f316f511b1e9
v1.0
instruct
Taco
Taco_79193_I
Alice loves palindrome numbers and decided to create an interesting game involving them. In this game, you are given an integer `n`, and you are required to find the smallest palindrome number greater than `n`. A palindrome number is a number that remains the same when its digits are reversed, like 121 or 12321. Impl...
def is_palindrome(num): """ Check if the given number is a palindrome. """ return str(num) == str(num)[::-1] def next_palindrome(n): """ Find the smallest palindrome number greater than n. """ n += 1 while not is_palindrome(n): n += 1 return n # Example usage: # next_pa...
from solution import next_palindrome def test_next_palindrome_simple(): assert next_palindrome(123) == 131 assert next_palindrome(99) == 101 assert next_palindrome(1234) == 1331 def test_next_palindrome_small_numbers(): assert next_palindrome(1) == 2 assert next_palindrome(9) == 11 assert next...
[ { "docstring": "Check if the given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Find the smallest palindrome number greater than n.", "function_declaration": "def next_palindrom...
[ 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 next_palindrome(n):\n \"\"\"\n Returns the smallest palindrome number greater than n.\n \"\"\"\n def is_palindrome(num):\n return str(num) =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079193", "row_id": 79193, "seed_ids": "[10405]" }
0.827408
Taco_79193
I
[ "is_palindrome", "next_palindrome" ]
2
[ [ "next_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cef290bdcfd3edb0690f4fa7571f7a82ceceacad
f9a7d239c50d71273eb259e6826c857e1bddb847
v1.0
instruct
Taco
Taco_79200_I
There is a kingdom with n cities connected by m bidirectional roads. Each road connects two different cities and has a certain length. The king wants to make his kingdom more accessible, so he plans to build a palace in one of the cities. The goal is to place the palace in such a way that the maximum distance from any ...
import heapq def dijkstra(n, graph, start): distances = [float('inf')] * (n + 1) distances[start] = 0 pq = [(0, start)] while pq: current_distance, current_node = heapq.heappop(pq) if current_distance > distances[current_node]: continue for nei...
from solution import find_palace_city def test_find_palace_city_example1(): n = 4 m = 4 roads = [ (1, 2, 2), (2, 3, 4), (3, 4, 1), (4, 1, 3) ] assert find_palace_city(n, roads) == 1 def test_find_palace_city_example2(): n = 3 m = 2 roads = [ (1, ...
[ { "docstring": null, "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def find_palace_city(n, roads):", "function_name": "find_palace_city", "parameter_lis...
[ 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n distances = [float('inf')] * n\n distances[start] = 0\n priority_queue = [(0, start)]\n \n while pr...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00079200", "row_id": 79200, "seed_ids": "[16568]" }
0.692312
Taco_79200
I
[ "dijkstra", "find_palace_city" ]
2
[ [ "find_palace_city", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
946acb230be43bd1584f295ddc2b6cc446440204
d2d54ab19da7cf7c39de2c578b09830b269ffb2b
v1.0
instruct
Taco
Taco_79230_I
A group of friends are planning a road trip. They have a specific list of cities they want to visit, and they have asked you to help them with the logistics of the trip. The friends will start the trip from one of the cities and will visit each of the listed cities exactly once before returning to the starting city. Th...
import itertools def tsp_min_cost(n, cost): """ Find the minimum cost to complete the trip where friends visit each city exactly once and return to the starting city. :param n: int, number of cities :param cost: list of list of ints, cost[i][j] is the cost of traveling from city i to city j ...
from solution import tsp_min_cost, solve def test_tsp_min_cost(): assert tsp_min_cost(4, [ [0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0] ]) == 80 assert tsp_min_cost(3, [ [0, 10, 15], [10, 0, 20], [15, 20, 0] ]) == 45 ...
[ { "docstring": "Find the minimum cost to complete the trip where friends visit each city exactly once \nand return to the starting city.\n\n:param n: int, number of cities\n:param cost: list of list of ints, cost[i][j] is the cost of traveling from city i to city j\n:return: int, minimum cost to complete the tr...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef min_cost_trip(n, cost):\n \"\"\"\n Finds the minimum cost to complete the trip where friends visit each city exactl...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00079230", "row_id": 79230, "seed_ids": "[9111]" }
0.787103
Taco_79230
I
[ "tsp_min_cost", "solve" ]
2
[ [ "solve", "tsp_min_cost" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b3ade10723335b3b97104f08adef7b0529da1914
f05421d6793e3ef6376d8207ff3811bcbc70612b
v1.0
instruct
Taco
Taco_79276_I
Given an integer amount representing cents (0 <= amount <= 10000), write a function to convert it into a string representing that amount in dollars and cents in words. Note: Consider the singular and plural forms based on the values, as well as zero values. Examples of conversion: 1234 -> twelve dollars and thirty-four...
def number_to_words(n): """Convert numbers to words for given integer 0 <= n < 100.""" words_1_to_19 = [ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "...
from solution import amountToWords def test_amount_in_single_dollars_and_single_cents(): assert amountToWords(101) == "one dollar and one cent" def test_amount_in_single_dollars_and_multiple_cents(): assert amountToWords(107) == "one dollar and seven cents" def test_amount_in_tens_of_dollars_and_single_cents...
[ { "docstring": "Convert numbers to words for given integer 0 <= n < 100.", "function_declaration": "def number_to_words(n):", "function_name": "number_to_words", "parameter_list": "(n)" }, { "docstring": "Converts an amount in cents to words representing dollars and cents.\n\nParameters:\nam...
[ 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 number_to_words(n):\n \"\"\"Convert numbers to words for given integer 0 <= n < 100.\"\"\"\n \n words_1_to_19 = [\n \"zero\", \"one\", \"two\",...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00079276", "row_id": 79276, "seed_ids": "[16968]" }
0.592791
Taco_79276
I
[ "number_to_words", "amountToWords" ]
2
[ [ "amountToWords", "number_to_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
416bf12736a4c56e283a67e30cfd22e6183d7ab5
099caebddad6efdfb2de45adc6e4aa09c594d38b
v1.0
instruct
Taco
Taco_79321_I
Write a function that takes a list of integers and returns a sorted list of their prime factors. If an integer is negative or zero, it should be excluded from the output. ## Examples ``` Input: [6, 15, -4, 0, 21] Output: [[2, 3], [3, 5], [3, 7]] Input: [10, 25, 8] Output: [[2, 5], [5, 5], [2, 2, 2]] Input: [13, 19] ...
def prime_factors(n): """ Returns the list of prime factors of a given positive integer n. """ factors = [] divisor = 2 while n > 1: while n % divisor == 0: factors.append(divisor) n = n // divisor divisor += 1 return factors def prime_factors_list(nu...
from solution import prime_factors, prime_factors_list def test_prime_factors(): assert prime_factors(6) == [2, 3] assert prime_factors(15) == [3, 5] assert prime_factors(21) == [3, 7] assert prime_factors(10) == [2, 5] assert prime_factors(25) == [5, 5] assert prime_factors(8) == [2, 2, 2] ...
[ { "docstring": "Returns the list of prime factors of a given positive integer n.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Given a list of integers, return a sorted list of lists, \neach containing the prim...
[ 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 prime_factors(n):\n \"\"\"\n Returns the list of prime factors of a given number n.\n If n is zero or negative, it returns an empty list.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079321", "row_id": 79321, "seed_ids": "[1250]" }
0.683697
Taco_79321
I
[ "prime_factors", "prime_factors_list" ]
2
[ [ "prime_factors_list", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c78cb86f9731365ae7e1f6aa5c150e18a34296b8
6f714906fdc20bef8be8b7f68c5ab390638bdb8b
v1.0
instruct
Taco
Taco_79357_I
Given a grid of size MxN filled with integers, you're required to find the sum of all unique elements in the grid. Input: - The first line contains two integers M and N, denoting the number of rows and columns of the grid, respectively. - The next M lines each contain N integers representing the elements of the grid. ...
def sum_of_unique_elements(grid): """ Returns the sum of all unique elements in the grid. :param grid: list of list of integers representing the grid :return: sum of all unique elements in the grid """ element_count = {} for row in grid: for element in row: if eleme...
def test_sum_of_unique_elements(): grid = [ [1, 2, 3], [4, 5, 6], [1, 2, 3] ] assert sum_of_unique_elements(grid) == 15 grid = [ [10] ] assert sum_of_unique_elements(grid) == 10 grid = [ [1, 2, 2], [3, 4, 4], [5, 6, 6] ] asser...
[ { "docstring": "Returns the sum of all unique elements in the grid.\n\n:param grid: list of list of integers representing the grid\n:return: sum of all unique elements in the grid", "function_declaration": "def sum_of_unique_elements(grid):", "function_name": "sum_of_unique_elements", "parameter_lis...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_unique_elements(grid):\n \"\"\"\n Returns the sum of all unique elements in the grid.\n\n :param grid: list of list of integers representing th...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00079357", "row_id": 79357, "seed_ids": "[9558]" }
0.636619
Taco_79357
I
[ "sum_of_unique_elements", "parse_input", "main_function" ]
3
[ [ "main_function", "parse_input" ], [ "main_function", "sum_of_unique_elements" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
a14222c57d7bb967c117b1ca7c70f0abe1cc11fb
b6f77c903e550978a7bcc1ed2be2187419240d4e
v1.0
instruct
Taco
Taco_79402_I
Digits Reversal Problem Statement Given a non-negative integer n, reverse the digits of n and determine if the resultant number is a prime. Write a function to check whether the reversed number is a prime number or not. A prime number is a number greater than 1 with no positive divisors other than 1 and itself. For ...
def is_prime(num): """ Returns True if the input number 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) ==...
from solution import is_prime, reverse_num, is_reversed_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(17) == True assert is_prime(20) == False assert is_prime(1) == False def test_reve...
[ { "docstring": "Returns True if the input number is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the reversed digits of the input number.", "function_declaration": "def r...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a given number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00079402", "row_id": 79402, "seed_ids": "[7914]" }
0.678714
Taco_79402
I
[ "is_prime", "reverse_num", "is_reversed_prime" ]
3
[ [ "is_reversed_prime", "is_prime" ], [ "is_reversed_prime", "reverse_num" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6b892a4eda3b83727e5b80b6878f6083d1386100
be5b61e2902ee838192c8c1ab87315858addce06
v1.0
instruct
Taco
Taco_79446_I
Write a function to reform fractions by converting them into their simplest forms or mixed numbers. Given a non-negative fraction represented as a string "N/D" (where N and D are integers and D > 0), perform the following steps: 1. Simplify the fraction, if possible, by dividing both the numerator (N) and denominator ...
def gcd(a, b): while b: a, b = b, a % b return a def simplify_fraction(n, d): common_divisor = gcd(n, d) return n // common_divisor, d // common_divisor def to_mixed_number(n, d): integer_part = n // d remainder = n % d if remainder == 0: return f"{integer_part}" else: ...
from solution import simplify_fraction, to_mixed_number, reform_fraction, process_input_output def test_simplify_fraction(): assert simplify_fraction(4, 2) == (2, 1) assert simplify_fraction(6, 9) == (2, 3) assert simplify_fraction(50, 100) == (1, 2) assert simplify_fraction(7, 1) == (7, 1) def test_t...
[ { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def simplify_fraction(n, d):", "function_name": "simplify_fraction", "parameter_list": "(n, d)" }, { "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": "from math import gcd\n\ndef simplify_fraction(q, fractions):\n \"\"\"\n This function takes the number of fractions q and a list of fraction strings,\n th...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079446", "row_id": 79446, "seed_ids": "[11910]" }
0.615887
Taco_79446
I
[ "gcd", "simplify_fraction", "to_mixed_number", "reform_fraction", "process_input_output" ]
5
[ [ "process_input_output", "reform_fraction" ], [ "reform_fraction", "simplify_fraction" ], [ "reform_fraction", "to_mixed_number" ], [ "simplify_fraction", "gcd" ], [ "to_mixed_number", "simplify_fraction" ] ]
5
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
5384a5142809684af36b643f02111832d2e472d7
4b3870bf2ff7742f810824564c53fabb2fcb35fa
v1.0
instruct
Taco
Taco_79492_I
### Problem Statement You are given two linked lists representing two non-negative integers. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function to add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leadin...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def addTwoNumbers(l1, l2): """ Adds two numbers represented by linked lists in reverse order. :param l1: ListNode :param l2: ListNode :return: ListNode """ dummy_head = ListNode(0)...
def parse_output(output_list): lists = [] current_list = [] for item in output_list: if item == '-': lists.append(current_list) current_list = [] else: current_list.append(int(item)) return lists def test_add_two_linked_lists(): input_data = [ ...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef addTwoNumbers(l1, l2):\n \"\"\"\n Given t...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00079492", "row_id": 79492, "seed_ids": "[12122]" }
0.543472
Taco_79492
I
[ "addTwoNumbers", "add_linked_list_pairs" ]
2
[ [ "add_linked_list_pairs", "addTwoNumbers" ] ]
1
[]
false
[ "ListNode" ]
true
pytest
false
[]
true
ee2d189bd30f5690f7f38d882db8bd780bfedd02
bfc307386f9487d6166d5113b7b17b3cd4717f9f
v1.0
instruct
Taco
Taco_79502_I
Given an array of integers, find the contiguous subarray which has the largest sum and return the sum. Implement your solution using a Divide and Conquer approach. Input: First line contains an integer T, the number of test cases. For each test case, the first line contains an integer N, the size of the array. The sec...
def max_crossing_sum(arr, left, mid, right): """ Helper function to find the maximum sum crossing the middle of the array. """ sm = 0 left_sum = float('-inf') for i in range(mid, left - 1, -1): sm = sm + arr[i] if (sm > left_sum): left_sum = sm sm = 0 ri...
from solution import find_maximum_subarray_sum def test_example_case_1(): arr = [-2, 1, -3, 4, -1, 2, 1, -5, 4] assert find_maximum_subarray_sum(arr) == 6 def test_example_case_2(): arr = [-1, -2, -3, -4, -5, -6] assert find_maximum_subarray_sum(arr) == -1 def test_all_positive_numbers(): arr = [...
[ { "docstring": "Helper function to find the maximum sum crossing the middle of the array.", "function_declaration": "def max_crossing_sum(arr, left, mid, right):", "function_name": "max_crossing_sum", "parameter_list": "(arr, left, mid, right)" }, { "docstring": "Helper function using the di...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_crossing_sum(arr, left, mid, right):\n \"\"\"\n Helper function to find the maximum contiguous subarray sum that crosses the midpoint.\n \"\"\"\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00079502", "row_id": 79502, "seed_ids": "[23826]" }
0.780533
Taco_79502
I
[ "max_crossing_sum", "max_subarray_sum", "find_maximum_subarray_sum" ]
3
[ [ "find_maximum_subarray_sum", "max_subarray_sum" ], [ "max_subarray_sum", "max_crossing_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
eb548defbd42432e7f39ee60341ace5c3ca1b9f6
d1789d3d374b0d32108137f2551a0702ec02257e
v1.0
instruct
Taco
Taco_79547_I
Tom is a nature enthusiast who loves counting the animals he sees while hiking. However, all of his counts are written in a specific encoding style where each type of animal is represented by a specific letter, and the count of each sighting is attached as a suffix to the letter. Tom wants to automate the decoding of h...
import re from collections import defaultdict def parse_record(record): pattern = re.compile(r'([a-z])(\d+)') matches = pattern.findall(record) animal_counts = defaultdict(int) for animal, count in matches: animal_counts[animal] += int(count) return animal_counts def combine_results(result...
def test_parse_record(): assert parse_record('a10b20c30') == {'a': 10, 'b': 20, 'c': 30} assert parse_record('a5b15c25a40') == {'a': 45, 'b': 15, 'c': 25} assert parse_record('z100y200z300') == {'z': 400, 'y': 200} def test_combine_results(): records = [ {'a': 10, 'b': 20, 'c': 30}, {'a...
[ { "docstring": null, "function_declaration": "def parse_record(record):", "function_name": "parse_record", "parameter_list": "(record)" }, { "docstring": null, "function_declaration": "def combine_results(results):", "function_name": "combine_results", "parameter_list": "(results...
[ 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 re\nfrom collections import defaultdict\n\ndef decode_records(N, records):\n result = []\n pattern = re.compile(r'([a-z])(\\d+)')\n\n for record in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079547", "row_id": 79547, "seed_ids": "[22808]" }
0.586315
Taco_79547
I
[ "parse_record", "combine_results", "process_records", "main" ]
4
[ [ "process_records", "combine_results" ], [ "process_records", "parse_record" ] ]
2
[]
false
[]
false
pytest
false
[]
true
8358d34180cc0bed08419ed9fb62ef4e9bb2259b
7dc1bc836bf97b95b0341eb3208625d15abaf68b
v1.0
instruct
Taco
Taco_79549_I
In a kingdom, there are several cities connected by bidirectional roads. Each road has a specific travel time associated with it. The king wants to build a new road such that the maximum travel time between any two cities is minimized. -----Input----- The first line of the input consists of two space-separated integer...
import heapq def calculate_max_distances(adj_matrix, C): dist = [[float('inf')]*C for _ in range(C)] for i in range(C): for j in range(C): if i == j: dist[i][j] = 0 elif adj_matrix[i][j] != float('inf'): dist[i][j] = adj_matrix[i][j] for ...
def test_minimize_max_travel_time(): assert minimize_max_travel_time(4, 4, [(1, 2, 5), (2, 3, 10), (3, 4, 5), (1, 4, 15)]) == 10 assert minimize_max_travel_time(3, 2, [(1, 2, 1), (2, 3, 1)]) == 1 assert minimize_max_travel_time(3, 3, [(1, 2, 1), (2, 3, 1), (3, 1, 2)]) == 2 assert minimize_max_travel_tim...
[ { "docstring": null, "function_declaration": "def calculate_max_distances(adj_matrix, C):", "function_name": "calculate_max_distances", "parameter_list": "(adj_matrix, C)" }, { "docstring": null, "function_declaration": "def minimize_max_travel_time(C, R, roads):", "function_name": "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef calculate_max_distances(adj_matrix, C):\n dist = [[float('inf')]*C for _ in range(C)]\n for i in range(C):\n for j in range(C):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00079549", "row_id": 79549, "seed_ids": "[4671]" }
0.765361
Taco_79549
I
[ "calculate_max_distances", "minimize_max_travel_time" ]
2
[ [ "minimize_max_travel_time", "calculate_max_distances" ] ]
1
[]
false
[]
false
pytest
false
[]
true
44793ab208b8cf6cd394aeb4bbdac1e34cdf4962
603ea1c31739d057100e26942efa7e66809312b3
v1.0
instruct
Taco
Taco_79591_I
Given a positive integer N, return the smallest integer Y that is greater than or equal to N and is a palindrome. A palindrome is a number that reads the same forward and backward, such as 101 or 1331. Example 1: Input: 28 Output: 33 Explanation: The smallest palindrome greater than or equal to 28 is 33. Example 2: ...
def is_palindrome(num): """ Check if a given number is a palindrome. """ return str(num) == str(num)[::-1] def smallest_palindrome(N): """ Returns the smallest palindrome greater than or equal to N. """ while not is_palindrome(N): N += 1 return N
from solution import smallest_palindrome def test_example1(): assert smallest_palindrome(28) == 33 def test_example2(): assert smallest_palindrome(123) == 131 def test_example3(): assert smallest_palindrome(8) == 8 def test_single_digit_palindrome(): assert smallest_palindrome(5) == 5 def test_near...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Returns the smallest palindrome greater than or equal to N.", "function_declaration": "def smallest...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(num):\n \"\"\"\n Helper function to determine if a given number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079591", "row_id": 79591, "seed_ids": "[17811]" }
0.831237
Taco_79591
I
[ "is_palindrome", "smallest_palindrome" ]
2
[ [ "smallest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cfb20fdf12b2b5b21b01be74ba8948a9e2a2357f
4b32c1839375dc008067b5488faf3fb4d956c385
v1.0
instruct
Taco
Taco_79611_I
**Problem** Given a string `s` and a list of words `words`, determine the number of words that are subsequences of `s`. A subsequence of a string is a new string generated from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. Fo...
def is_subsequence(s, word): """ Check if word is a subsequence of the string s. :param s: The main string :param word: The word to check if it's a subsequence :return: True if word is a subsequence of s, False otherwise """ it = iter(s) return all(char in it for char in word) def coun...
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("xyz", "xyz") == True assert is_subsequence("xyz", "zx") == False def test_count_subsequences(): assert count_...
[ { "docstring": "Check if word is a subsequence of the string s.\n\n:param s: The main string\n:param word: The word to check if it's a subsequence\n:return: True if word is a subsequence of s, False otherwise", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", ...
[ 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_subsequence(s, word):\n \"\"\"\n Returns True if word is a subsequence of s.\n \"\"\"\n it = iter(s)\n for char in word:\n if char not...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079611", "row_id": 79611, "seed_ids": "[24595]" }
0.795839
Taco_79611
I
[ "is_subsequence", "count_subsequences" ]
2
[ [ "count_subsequences", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
68815a2177eef17b298d76f6917bdafaf3b6463d
fef3d238558e115d5b5208453d898c7a51acf520
v1.0
instruct
Taco
Taco_79652_I
You are given an undirected graph with N vertices numbered 1 through N and M edges. Each edge has a weight assigned to it, representing the cost to travel along that edge. Your task is to determine the minimum cost required to traverse from Vertex A to Vertex B. Consider that there might be multiple paths between two v...
import heapq def dijkstra(graph, start, end, n): distances = {i: float('infinity') for i in range(1, n + 1)} distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_vertex = heapq.heappop(priority_queue) if current_vertex == end: ...
from solution import min_cost def test_min_cost_basic(): N = 5 M = 6 edges = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 2) ] A = 1 B = 5 assert min_cost(N, M, edges, A, B) == 6 def test_no_path(): N = 4 M = 2 ...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, start, end, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, end, n)" }, { "docstring": null, "function_declaration": "def min_cost(N, M, edges, A, B):", "function_name": "min_cost", "parameter_...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start, end, n):\n distances = {i: float('infinity') for i in range(1, n + 1)}\n distances[start] = 0\n priority_queue ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00079652", "row_id": 79652, "seed_ids": "[15856]" }
0.871139
Taco_79652
I
[ "dijkstra", "min_cost" ]
2
[ [ "min_cost", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2876bbae7d60bb70c471150d80b8c54a5954a776
7bc36f220382ca67f190f780d26edd77205b5e39
v1.0
instruct
Taco
Taco_79671_I
Alice is going on a summer trip and she wants to pack her suitcase optimally. She has a suitcase with a maximum weight capacity W and a set of items, each with a certain weight. Alice wants to know the maximum number of items she can pack without exceeding the weight limit of her suitcase. ------ Input Format ------ ...
def max_items(weight_limit, items): items.sort() current_weight = 0 count = 0 for weight in items: if current_weight + weight <= weight_limit: current_weight += weight count += 1 else: break return count def solve_trip_packing(test_cases): res...
import pytest from solution import max_items, solve_trip_packing, process_input, process_output def test_max_items_basic(): assert max_items(10, [2, 3, 4, 5]) == 3 assert max_items(15, [1, 2, 8, 4, 5]) == 4 def test_max_items_edge_cases(): assert max_items(5, [5, 5, 5, 5]) == 1 assert max_items(10, []...
[ { "docstring": null, "function_declaration": "def max_items(weight_limit, items):", "function_name": "max_items", "parameter_list": "(weight_limit, items)" }, { "docstring": null, "function_declaration": "def solve_trip_packing(test_cases):", "function_name": "solve_trip_packing", ...
[ 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_items_to_pack(W, weights):\n \"\"\"\n Returns the maximum number of items that can be packed without exceeding the weight limit.\n \"\"\"\n # S...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00079671", "row_id": 79671, "seed_ids": "[20341]" }
0.732369
Taco_79671
I
[ "max_items", "solve_trip_packing", "process_input", "process_output" ]
4
[ [ "solve_trip_packing", "max_items" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
1fc39c3d2ab221e5706f8039c1df988a924c1db1
b5758e5808f7bdb347986a1cb45e3b84a962f312
v1.0
instruct
Taco
Taco_79692_I
Polycarpus enjoys solving number problems. One day, he encountered an interesting problem related to the properties of prime numbers. He defines an interesting number as a number that is either a prime number itself or can be expressed as the product of exactly two prime numbers (which could possibly be the same). Pol...
import math def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def is_interesting_number(n): ...
from solution import is_interesting_number def test_prime_numbers(): assert is_interesting_number(2) == "Yes" assert is_interesting_number(5) == "Yes" assert is_interesting_number(11) == "Yes" def test_product_of_two_primes(): assert is_interesting_number(6) == "Yes" # 2*3 assert is_interesting_n...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_interesting_number(n):", "function_name": "is_interesting_number", "parameter_list": "(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_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n p = 3\n while p * p <...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079692", "row_id": 79692, "seed_ids": "[2844]" }
0.624472
Taco_79692
I
[ "is_prime", "is_interesting_number" ]
2
[ [ "is_interesting_number", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8b7cd9f41745a02ae47499f0afbf26e4c5f5600
2c03333aa6afbd74afe49f27fb26a7fa249ebe53
v1.0
instruct
Taco
Taco_79697_I
A software company CNV Solutions has a system that logs user activity in a file. The log contains entries that track user sessions, marking the start and end time of each session. Each entry in the log is in the format: ``` USER_ID SESSION_START SESSION_END ``` where: - `USER_ID` is a unique identifier for the user (...
from datetime import datetime def calculate_total_active_time(n, log_entries): import heapq from collections import defaultdict user_sessions = defaultdict(list) for entry in log_entries: user_id, start, end = entry start_time = datetime.strptime(start, "%Y-%m-%d %H:%M:%S") en...
from datetime import datetime from solution import calculate_total_active_time def test_no_overlap_sessions(): n = 2 log_entries = [ ["1", "2023-01-01 08:00:00", "2023-01-01 08:30:00"], ["1", "2023-01-01 09:00:00", "2023-01-01 09:30:00"] ] result = calculate_total_active_time(n, log_ent...
[ { "docstring": null, "function_declaration": "def calculate_total_active_time(n, log_entries):", "function_name": "calculate_total_active_time", "parameter_list": "(n, log_entries)" }, { "docstring": null, "function_declaration": "def process_log_entries():", "function_name": "proces...
[ 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 datetime import datetime\n\ndef calculate_total_active_time(n, logs):\n \"\"\"\n Calculate the total active time (in seconds) for each user considering ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00079697", "row_id": 79697, "seed_ids": "[21722]" }
0.614966
Taco_79697
I
[ "calculate_total_active_time", "process_log_entries" ]
2
[ [ "process_log_entries", "calculate_total_active_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8474bfe33e843d1e3500a931bc811fcbc48347f2
ec62c4341b298aef9d576705182bc9a6cd717e07
v1.0
instruct
Taco
Taco_79732_I
An online gaming company is organizing a competition where players need to navigate through a series of interconnected rooms. Each room has multiple doors leading to other rooms, and each door has a specific time delay to open. The goal for the players is to determine the shortest time required to travel from the start...
import heapq def dijkstra(matrix, start): """ Dijkstra's algorithm to find the shortest path from start to all other nodes. Returns a list of shortest path distances from the start node. """ n = len(matrix) dist = [float('inf')] * n dist[start] = 0 priority_queue = [(0, start)] # (dist...
def test_shortest_time_to_travel(): N = 4 matrix = [ [0, 2, 1, 3], [2, 0, 4, 5], [1, 4, 0, 3], [3, 5, 3, 0] ] players = [(0, 2), (1, 3), (3, 0)] results = shortest_time_to_travel(N, matrix, players) assert results == [1, 5, 3] def test_all_rooms_directly_connecte...
[ { "docstring": "Dijkstra's algorithm to find the shortest path from start to all other nodes.\nReturns a list of shortest path distances from the start node.", "function_declaration": "def dijkstra(matrix, start):", "function_name": "dijkstra", "parameter_list": "(matrix, start)" }, { "docst...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, time_matrix, start, end):\n \"\"\"\n Use Dijkstra's algorithm to find the shortest time from start to end.\n \"\"\"\n d...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00079732", "row_id": 79732, "seed_ids": "[16476]" }
0.792828
Taco_79732
I
[ "dijkstra", "shortest_time_to_travel" ]
2
[ [ "shortest_time_to_travel", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d31d89de9a09064d94996d61464add83656cb04f
620a4208e54baf3eb642f223676392267f30cbbf
v1.0
instruct
Taco
Taco_79848_I
Savita is fascinated with graphs and shortest paths. She is trying to experiment by defining a new measure in a connected undirected graph called "strong distance" between two vertices $u$ and $v$. The strong distance $s(u, v)$ is defined as the length of the longest shortest path between any pair of vertices $(w, x)$ ...
def floyd_warshall(n, graph): dist = [[float('inf')] * n for _ in range(n)] for i in range(n): dist[i][i] = 0 for u, v, w in graph: dist[u-1][v-1] = w dist[v-1][u-1] = w for k in range(n): for i in range(n): for j in range(n): if dist[...
def test_floyd_warshall(): graph = [ (1, 2, 1), (2, 3, 1), (3, 4, 1), (4, 1, 1) ] result = floyd_warshall(4, graph) expected = [ [0, 1, 2, 1], [1, 0, 1, 2], [2, 1, 0, 1], [1, 2, 1, 0] ] assert result == expected def test_strong_...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, graph):", "function_name": "floyd_warshall", "parameter_list": "(n, graph)" }, { "docstring": null, "function_declaration": "def strong_distance(n, graph):", "function_name": "strong_distance", "parameter_list": ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def floyd_warshall(n, adj_matrix):\n \"\"\"\n Helper function to implement the Floyd-Warshall algorithm to find the shortest\n path between all pairs of v...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079848", "row_id": 79848, "seed_ids": "[2210]" }
0.699629
Taco_79848
I
[ "floyd_warshall", "strong_distance", "solve" ]
3
[ [ "solve", "strong_distance" ], [ "strong_distance", "floyd_warshall" ] ]
2
[]
false
[]
false
pytest
false
[]
true
9e013c3bde938d42f3de17b26d37344d1061e638
17687b27daf7a08b7c9ea94084743c40f6f4e7ed
v1.0
instruct
Taco
Taco_79873_I
Write a function that takes a list of integers and returns a new list where all the prime numbers are moved to the front, and the non-prime numbers are moved to the back, preserving their original order within their respective groups. ## Examples ```python For the input list: [10, 3, 4, 7, 6, 11, 13, 15] Output shoul...
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def move_primes_to_front(nums): ...
from solution import move_primes_to_front def test_move_primes_to_front(): assert move_primes_to_front([10, 3, 4, 7, 6, 11, 13, 15]) == [3, 7, 11, 13, 10, 4, 6, 15] assert move_primes_to_front([1, 2, 3, 5, 8, 9, 10]) == [2, 3, 5, 1, 8, 9, 10] assert move_primes_to_front([4, 6, 8, 10, 12]) == [4, 6, 8, 10, ...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new list where all the prime numbers are at the front and non-prime numbers at the back.", "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": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00079873", "row_id": 79873, "seed_ids": "[19170]" }
0.598762
Taco_79873
I
[ "is_prime", "move_primes_to_front" ]
2
[ [ "move_primes_to_front", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
93f09b97e6c3eade06845ce3338f5add1965a444
7e4ea46fcbee5a1ef45965567a51c7c9a58c1954