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_41155_I
You are given an undirected, weighted graph represented by its adjacency matrix. Your task is to determine the minimum spanning tree (MST) of the graph using Kruskal's algorithm and output the sum of the weights of the edges in the MST. To achieve this, follow these steps: 1. Extract all edges and their weights from ...
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_kruskal_mst(): n = 4 adjacency_matrix = [ [0, 1, 3, 0], [1, 0, 3, 6], [3, 3, 0, 2], [0, 6, 2, 0] ] assert calculate_mst_weight(n, adjacency_matrix) == 6 def test_kruskal_mst_single_edge(): n = 2 adjacency_matrix = [ [0, 1], [1, 0] ] ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041155", "row_id": 41155, "seed_ids": "[18337]" }
0.739515
Taco_41155
I
[ "find", "union", "kruskal_mst", "calculate_mst_weight" ]
4
[ [ "calculate_mst_weight", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
566fc1bc3c090b892f8e0b929635720af4973eec
a69989967f36b4dba8a9517fc8157c7d4389fd37
v1.0
instruct
Taco
Taco_41207_I
The students of the Russian School of Mathematics have developed a mathematical game which involves finding specific number patterns in sequences of integers. The game is played as follows: Given a sequence of integers, find if there exists a contiguous sub-sequence whose sum is divisible by a given integer k. The stu...
def has_subsequence_divisible_by_k(n, k, sequence): prefix_sum = 0 prefix_sums_mod_k = {0} for num in sequence: prefix_sum += num mod_k = prefix_sum % k if mod_k in prefix_sums_mod_k: return "YES" prefix_sums_mod_k.add(mod_k) return "NO...
from solution import find_subsequence def test_example1(): n = 5 k = 3 sequence = [1, 2, 3, 4, 5] assert find_subsequence(n, k, sequence) == "YES" def test_example2(): n = 4 k = 11 sequence = [1, 2, 4, 8] assert find_subsequence(n, k, sequence) == "NO" def test_example3(): n = 6 ...
[ { "docstring": null, "function_declaration": "def has_subsequence_divisible_by_k(n, k, sequence):", "function_name": "has_subsequence_divisible_by_k", "parameter_list": "(n, k, sequence)" }, { "docstring": null, "function_declaration": "def find_subsequence(n, k, sequence):", "functi...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence_divisible(n, k, sequence):\n \"\"\"\n Determines if there exists a contiguous sub-sequence in a sequence whose sum is divisible by k.\n\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00041207", "row_id": 41207, "seed_ids": "[15377]" }
0.685555
Taco_41207
I
[ "has_subsequence_divisible_by_k", "find_subsequence" ]
2
[ [ "find_subsequence", "has_subsequence_divisible_by_k" ] ]
1
[]
false
[]
false
pytest
true
[]
true
51216c319d3b7af02d4fe40e16530a4ecb680b3d
176a4a694b223c8d468b847275a874cf60aadd2d
v1.0
instruct
Taco
Taco_41215_I
In a given list of integers, you are required to find the sum of all the integers which are prime numbers. Your task is to implement a function to filter out the prime numbers from the list and calculate their sum. Recall that a prime number is a number greater than 1 that is not divisible by any number other than 1 a...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False ...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-3) == False assert is_prime(17) == True...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in the given list.", "function_declaration": "def sum_of_primes(number...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to check if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041215", "row_id": 41215, "seed_ids": "[19695]" }
0.660747
Taco_41215
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d20d0c0c71247d10e3284ba2438a1517ab49d6d0
cd85f33afdfa743e9ff0e2c1e737940ec0b0386b
v1.0
instruct
Taco
Taco_41235_I
Consider an online game where two players, Alice and Bob, take turns playing a game with an initial number of tokens, `n`. The game is played as follows: - On Alice's turn, she can remove a number of tokens that is a prime number. - On Bob's turn, he can remove a number of tokens that is a perfect square. If a player...
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return F...
def test_who_wins_alice(): assert who_wins(10) == "Alice" def test_who_wins_bob(): assert who_wins(15) == "Bob" def test_who_wins_small_number_alice(): assert who_wins(2) == "Alice" def test_who_wins_small_number_bob(): assert who_wins(1) == "Bob" def test_who_wins_large_number(): assert who_win...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Check if there is any prime number <= n.", "function_declaration": "def has_prime(n):", "function_n...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n ret...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00041235", "row_id": 41235, "seed_ids": "[648]" }
0.788493
Taco_41235
I
[ "is_prime", "has_prime", "has_perfect_square", "who_wins" ]
4
[ [ "has_prime", "is_prime" ], [ "who_wins", "has_perfect_square" ], [ "who_wins", "has_prime" ], [ "who_wins", "is_prime" ] ]
4
[]
false
[]
false
pytest
false
[]
true
127a280f78a7b079208e7cbf85130c1b10f6aae8
4125e71645bd83237a728265fd7a2cb3c2bc1011
v1.0
instruct
Taco
Taco_41240_I
A game developer is designing a rhythm game where players need to hit notes in time with the music. Each level of the game consists of a number of note sequences, each with specific timings and points. However, the developer wants to ensure that there are no overlapping notes within each sequence to make the game playa...
def max_points(levels): results = [] for level in levels: notes = level notes.sort(key=lambda x: x[1]) max_points = [0] * len(notes) for i in range(len(notes)): max_points[i] = notes[i][2] for j in range(i): if notes[...
def test_multiple_levels(): T = 2 sequence_data = [ 4, # Number of notes in level 1 (0, 3, 10), (1, 5, 5), (4, 6, 3), (5, 8, 8), 3, # Number of notes in level 2 (2, 4, 6), (1, 3, 4), (0, 2, 5) ] result = rhythm_game(T, se...
[ { "docstring": null, "function_declaration": "def max_points(levels):", "function_name": "max_points", "parameter_list": "(levels)" }, { "docstring": null, "function_declaration": "def rhythm_game(T, sequence_data):", "function_name": "rhythm_game", "parameter_list": "(T, sequenc...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_non_overlapping_points(levels):\n def max_points_for_level(notes):\n # Sort notes based on their end_time\n notes.sort(key=lambda note: no...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00041240", "row_id": 41240, "seed_ids": "[2405]" }
0.68974
Taco_41240
I
[ "max_points", "rhythm_game" ]
2
[ [ "rhythm_game", "max_points" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4ee6b7a4029a09e7c1c061c673ea32d0583a22d6
b7a7b7038fdfb1250198fef1f739691a1949cd90
v1.0
instruct
Taco
Taco_41323_I
You are tasked with creating a program that classifies tweets into one of three categories. We have access to a training set of tweets, each labeled with a category: 1 (sports), 2 (news), or 3 (entertainment). The training set includes tweets in CSV format, with each row containing a tweet identifier, the tweet text, a...
import re import csv from collections import defaultdict def preprocess_text(text): """ Preprocess tweet text by converting to lowercase and removing special characters. """ text = text.lower() text = re.sub(r'[^\w\s]', '', text) return text def train_model(training_data): """ Train a ...
from solution import preprocess_text, train_model, classify_tweets def test_preprocess_text(): assert preprocess_text("Just won a marathon!") == "just won a marathon" assert preprocess_text("Breaking: the stock market crashes!") == "breaking the stock market crashes" assert preprocess_text("Can't wait for ...
[ { "docstring": "Preprocess tweet text by converting to lowercase and removing special characters.", "function_declaration": "def preprocess_text(text):", "function_name": "preprocess_text", "parameter_list": "(text)" }, { "docstring": "Train a simple keyword-based classification model based ...
[ 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\nimport numpy as np\nimport pandas as pd\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.naive_bayes import MultinomialNB\nfro...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041323", "row_id": 41323, "seed_ids": "[14587]" }
0.5107
Taco_41323
I
[ "preprocess_text", "train_model", "classify_tweet", "classify_tweets", "main" ]
5
[ [ "classify_tweet", "preprocess_text" ], [ "classify_tweets", "classify_tweet" ], [ "train_model", "preprocess_text" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5beacf2e9dde58ee9f4fb3019038fc5ddc6a0a34
c500c8ddd4ff0e898d045749045ec0bc1cb3fdcb
v1.0
instruct
Taco
Taco_41337_I
A city has N intersections and M bidirectional roads connecting them. Each road has a unique ID and a travel time. The city's transportation department wants to rearrange the roads to minimize the maximum travel time between any two intersections. The following steps can be performed any number of times: 1. Remove a r...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
def test_find(): parent = [0, 1, 2, 3] assert find(parent, 0) == 0 assert find(parent, 1) == 1 parent[1] = 0 assert find(parent, 1) == 0 def test_union(): parent = [0, 1, 2, 3] rank = [0, 0, 0, 0] union(parent, rank, 0, 1) assert find(parent, 1) == 0 parent = [0, 1, 2, 3] ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def 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_5
{ "original_instruction": "", "prompt_id": "00041337", "row_id": 41337, "seed_ids": "[20375]" }
0.769382
Taco_41337
I
[ "find", "union", "kruskal", "min_max_travel_time", "main" ]
5
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "min_max_travel_time", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
c4ce00a037fbd66ed5353a3a8eaa16e51057df5b
93ae18d63ce7a500a9806ed1ac2696f3e0f70358
v1.0
instruct
Taco
Taco_41439_I
Divya wants to purchase a meal that costs M dollars at a restaurant. The restaurant has a promotion where if the cost of the meal is a prime number, Divya gets a 20% discount on the total cost. You need to calculate the final price Divya has to pay after applying the discount (if applicable). ------ Input Format -----...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i +...
from solution import calculate_final_price def test_prime_number_with_discount(): assert calculate_final_price(17) == 13.60 assert calculate_final_price(19) == 15.20 assert calculate_final_price(23) == 18.40 def test_non_prime_number_no_discount(): assert calculate_final_price(21) == 21.00 assert ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the final price Divya has to pay after applying discount if necessary.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041439", "row_id": 41439, "seed_ids": "[16607]" }
0.73141
Taco_41439
I
[ "is_prime", "calculate_final_price" ]
2
[ [ "calculate_final_price", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc3cda34bbbdabf0cf67326df67f6217cf5c32b0
7330a85acec654e31a9ce5818f4c9bec86688e87
v1.0
instruct
Taco
Taco_41461_I
A company has a set of n employees, each of whom has a unique ID number from 1 to n. Some employees are good friends and have established a communication network. The CEO wants to make sure that every employee can communicate with every other employee (directly or indirectly). It is the job of the IT department to dete...
def find_parent(parent, i): """ A utility function to find the parent of an element i. Utilizes path compression for efficiency. """ if parent[i] == i: return i else: parent[i] = find_parent(parent, parent[i]) return parent[i] def union(parent, rank, x, y): """ A...
def test_minimum_additional_connections(): assert minimum_additional_connections(5, 3, [(1, 2), (1, 3), (4, 5)]) == 1 assert minimum_additional_connections(3, 2, [(1, 2), (2, 3)]) == 0 assert minimum_additional_connections(4, 0, []) == 3 assert minimum_additional_connections(4, 1, [(1, 2)]) == 2 ass...
[ { "docstring": "A utility function to find the parent of an element i.\nUtilizes path compression for efficiency.", "function_declaration": "def find_parent(parent, i):", "function_name": "find_parent", "parameter_list": "(parent, i)" }, { "docstring": "A function that does union of two sets...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_parent(parent, i):\n \"\"\"\n A utility function to find the parent of an element i.\n Utilizes path compression for efficiency.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041461", "row_id": 41461, "seed_ids": "[13710]" }
0.679589
Taco_41461
I
[ "find_parent", "union", "minimum_additional_connections", "solve" ]
4
[ [ "minimum_additional_connections", "find_parent" ], [ "minimum_additional_connections", "union" ], [ "solve", "minimum_additional_connections" ], [ "union", "find_parent" ] ]
4
[]
false
[]
false
pytest
false
[]
true
1e9ac3cb8db76a23547fd2b21c12c5e523f275ca
8cefcb84ec160a415ed12160bf2ace2345ee2e83
v1.0
instruct
Taco
Taco_41465_I
A company has M employees (1 ≤ M ≤ 50) and N projects (1 ≤ N ≤ 50). Each employee i (1 ≤ i ≤ M) has a specific set of skills, represented as a list of integers ranging from 1 to 1000. Each project j (1 ≤ j ≤ N) requires certain skills, also represented as a list of integers from 1 to 1000. An employee can be assigned ...
from itertools import product def can_assign(employee_skills, project_requirement): """ Check if an employee can be assigned to a project based on skills. """ return set(project_requirement).issubset(employee_skills) def count_assignments(M, N, employees_skills, projects_requirements): """ Cou...
from solution import count_assignments, parse_input, main def test_count_assignments(): input_str = "3 2\n3 1 2 3\n2 2 3\n1 4\n2 1 2\n1 4" M, N, employees_skills, projects_requirements = parse_input(input_str) assert count_assignments(M, N, employees_skills, projects_requirements) == 2 def test_parse_inpu...
[ { "docstring": "Check if an employee can be assigned to a project based on skills.", "function_declaration": "def can_assign(employee_skills, project_requirement):", "function_name": "can_assign", "parameter_list": "(employee_skills, project_requirement)" }, { "docstring": "Counts the unique...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef can_assign(employee_skills, project_skills):\n \"\"\"\n Checks if an employee with `employee_skills` can be assigne...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00041465", "row_id": 41465, "seed_ids": "[15564]" }
0.714902
Taco_41465
I
[ "can_assign", "count_assignments", "parse_input", "main" ]
4
[ [ "count_assignments", "can_assign" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
5e02bf6a65b7921ec452b3c4af5bd7c8ab1c3120
2bc1834f6edeae188f241703ddfee19d8cb41c73
v1.0
instruct
Taco
Taco_41469_I
HackerMan has discovered a hidden treasure map. The map consists of a grid with cells, where each cell can either be empty (denoted by '.') or contain an obstacle (denoted by '#'). The treasure is hidden in a cell marked with a 'T', and HackerMan starts at a cell marked with an 'S'. HackerMan can move up, down, left,...
def can_hackerman_reach_treasure(grid, start, end): # Helper function for checking neighbors def is_safe(x, y): return 0 <= x < len(grid) and 0 <= y < len(grid[0]) and grid[x][y] != '#' from collections import deque M, N = len(grid), len(grid[0]) queue = deque([start]) visited ...
from solution import solve, parse_input def test_parse_input(): input_str = "2\n5 5\nS....\n.###.\n..#..\n.###.\n....T\n4 6\nS..##.\n.#..#.\n.#..#T\n.####." test_cases = parse_input(input_str) expected = [ ( [['S', '.', '.', '.', '.'], ['.', '#', '#', '#', '.'], ['.', '.', '#', '.', '.'...
[ { "docstring": null, "function_declaration": "def can_hackerman_reach_treasure(grid, start, end):", "function_name": "can_hackerman_reach_treasure", "parameter_list": "(grid, start, end)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solv...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_reach_treasure(test_cases):\n def bfs(grid, start, end):\n from collections import deque\n queue = deque([start])\n visited = set([...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00041469", "row_id": 41469, "seed_ids": "[23044]" }
0.656352
Taco_41469
I
[ "can_hackerman_reach_treasure", "solve", "parse_input" ]
3
[ [ "solve", "can_hackerman_reach_treasure" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
8680488432c9e3b2fb3d53a331d26e6b50b3b417
aa87fd59bb91187357fb594483a518f106ada9e8
v1.0
instruct
Taco
Taco_41483_I
Write a function that takes an array of integers and returns a new array containing only the prime numbers from the input array, preserving the order of their first occurrence. ``` input: [arrayOfIntegers] output: [arrayOfPrimes] example: [15, 3, 8, 11, 2, 5, 4, 2] --> [3, 11, 2, 5, 2] ``` All elements of the input ...
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 is_prime, get_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(17) == True assert is_prime(18) == False d...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a new array containing only the prime numbers from the input array,\npreserving the order of their first occurrence.", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041483", "row_id": 41483, "seed_ids": "[21719]" }
0.661801
Taco_41483
I
[ "is_prime", "get_primes" ]
2
[ [ "get_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
79a7a1d720d59d9322199994b0be833b436adf06
25bea629d2a2d8b2810957950178eec8fe6fe0a2
v1.0
instruct
Taco
Taco_41557_I
During the intergalactic trading season, a network of trade routes connects different planets. Each trade route has a certain value associated with it. The galactic council needs to determine the most profitable way to establish connections between these planets without forming any cycles (to prevent market monopolies)...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
def test_maximum_profit_simple(): V, E = 4, 5 edges = [ (0, 1, 10), (0, 2, 6), (0, 3, 5), (1, 3, 15), (2, 3, 4)] assert maximum_profit(V, E, edges) == 31 def test_maximum_profit_all_edges_include(): V, E = 3, 3 edges = [ (0, 1, 5), (1, 2, 4), ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00041557", "row_id": 41557, "seed_ids": "[3405]" }
0.630489
Taco_41557
I
[ "find", "union", "maximum_profit" ]
3
[ [ "maximum_profit", "find" ], [ "maximum_profit", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
2c78e5505c46f321d8fc505df71019a04a02aef1
04ea70da5598cc4d9428a218ef47ab5803c3d3a1
v1.0
instruct
Taco
Taco_41563_I
A company wants to optimize its network connection by installing a minimum number of cables to connect all the departments. Each department is represented as a node, and a possible cable connection between two departments is represented as an edge with a weight indicating the cost to install that cable. Given the costs...
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 root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif rank[root_x] < ...
def test_kruskal_min_cost_to_connect_departments(): test_case1 = (4, 5, [(1, 2, 1), (1, 3, 4), (1, 4, 3), (2, 3, 2), (3, 4, 5)]) result1 = kruskal_min_cost_to_connect_departments(test_case1[0], test_case1[2]) ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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 return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041563", "row_id": 41563, "seed_ids": "[20742]" }
0.734953
Taco_41563
I
[ "find", "union", "kruskal_min_cost_to_connect_departments", "minimum_cost_to_connect_all_departments" ]
4
[ [ "kruskal_min_cost_to_connect_departments", "find" ], [ "kruskal_min_cost_to_connect_departments", "union" ], [ "minimum_cost_to_connect_all_departments", "kruskal_min_cost_to_connect_departments" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
fe23e71943752b269089f42d81a9980878f25809
73891bfca47afb993efc6820a90c09d62f53e331
v1.0
instruct
Taco
Taco_41596_I
John is studying networks and their resilience. He is particularly interested in tree structures. A tree is a connected, undirected graph with n nodes and n-1 edges. He notices that removing some nodes can result in multiple isolated subtrees. John’s task is to find the maximum possible size of the smallest subtree aft...
from collections import defaultdict, deque def calculate_subtree_sizes(n, edges): """ Calculates the subtree sizes for each node in the tree. """ tree = defaultdict(list) for u, v in edges: tree[u].append(v) tree[v].append(u) # Calculate sizes using DFS sizes = [0] * (n + 1...
from solution import max_smallest_subtree def test_example1(): n = 5 edges = [(1, 2), (1, 3), (1, 4), (4, 5)] assert max_smallest_subtree(n, edges) == 2 def test_example2(): n = 3 edges = [(1, 2), (1, 3)] assert max_smallest_subtree(n, edges) == 1 def test_single_edge(): n = 2 edges =...
[ { "docstring": "Calculates the subtree sizes for each node in the tree.", "function_declaration": "def calculate_subtree_sizes(n, edges):", "function_name": "calculate_subtree_sizes", "parameter_list": "(n, edges)" }, { "docstring": "Finds the maximum size of the smallest subtree that can re...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_largest_min_subtree_size(n, edges):\n from collections import defaultdict, deque\n\n def bfs(start):\n visited = [False] * (n + 1)\n q...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00041596", "row_id": 41596, "seed_ids": "[4872]" }
0.728307
Taco_41596
I
[ "calculate_subtree_sizes", "max_smallest_subtree" ]
2
[ [ "max_smallest_subtree", "calculate_subtree_sizes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6b24d604f4f25d1d33d0e9cdc2819ac67dc9b41e
269605c5e659b9610cc5787955a5bd961292dad3
v1.0
instruct
Taco
Taco_41598_I
David is a traveling merchant who needs to transport his goods using his caravan. His caravan can carry a maximum weight of W units. He has a list of n types of goods, each type having a certain weight and value. David wants to maximize the value of the goods he can carry without exceeding the weight limit. As a skill...
def knapsack(n, W, items): # Create a DP table with dimensions (n+1) x (W+1) dp = [[0 for _ in range(W + 1)] for _ in range(n + 1)] # Populate the table for i in range(1, n + 1): weight, value = items[i - 1] for w in range(W + 1): if weight <= w: dp[i][w]...
from solution import merchant_max_value def test_example_case(): n = 3 W = 50 items = [(10, 60), (20, 100), (30, 120)] assert merchant_max_value(n, W, items) == 220 def test_single_item_just_fits(): n = 1 W = 10 items = [(10, 100)] assert merchant_max_value(n, W, items) == 100 def tes...
[ { "docstring": null, "function_declaration": "def knapsack(n, W, items):", "function_name": "knapsack", "parameter_list": "(n, W, items)" }, { "docstring": null, "function_declaration": "def merchant_max_value(n, W, items):", "function_name": "merchant_max_value", "parameter_list...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def knapsack(n, W, items):\n \"\"\"\n Returns the maximum value of the goods that can be carried without exceeding the weight limit.\n \n :param n: int...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041598", "row_id": 41598, "seed_ids": "[7212]" }
0.750409
Taco_41598
I
[ "knapsack", "merchant_max_value" ]
2
[ [ "merchant_max_value", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1fad2b7ecdcc58187f9172339a7e1a3701dfc89a
a244f725b697e1682883f4eb2ac0c1393b0f055f
v1.0
instruct
Taco
Taco_41647_I
You are given two long integers, $a$ and $b$, which represent the start and end of a range, respectively. Write a program to compute the smallest prime number that is greater than or equal to $a$ and less than or equal to $b$. If there is no such prime number, return -1. Input Format Two space-separated long integers...
def is_prime(n): """ Determines if the given number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(25) == False def test_smallest_prime_in_range(): assert smallest_prime_in_range(10, 20) == 11 assert smallest_prime_in_range(24, 28) == -1 a...
[ { "docstring": "Determines if the given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number in the inclusive range [a, b].\nReturns -1 if there is no such prime num...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if the given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n re...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041647", "row_id": 41647, "seed_ids": "[8603]" }
0.640462
Taco_41647
I
[ "is_prime", "smallest_prime_in_range" ]
2
[ [ "smallest_prime_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
58d95e53605068723abb9ed97a5c60a2a86f2948
c354f753a24453f975489cc539b74dc2a31af825
v1.0
instruct
Taco
Taco_41650_I
Rina loves playing with arrays and solving puzzles using them. She comes up with an interesting problem. Given a list of integers, she wants to find another list such that each element at index i of the new list is the product of all the numbers in the original list except the one at index i. Your task is to help Rina ...
def product_array(arr): """ Returns a list such that each element at index i is the product of all elements in the array except the one at index i. """ n = len(arr) if n == 0: return [] left_products = [1] * n right_products = [1] * n result = [1] * n # Calcula...
import pytest from solution import product_array, solve, parse_input, format_output def test_product_array(): assert product_array([1, 2, 3]) == [6, 3, 2] assert product_array([1, 2, 3, 4]) == [24, 12, 8, 6] assert product_array([-1, 1, 0, -3, 3]) == [0, 0, 9, 0, 0] def test_solve(): test_cases = [ ...
[ { "docstring": "Returns a list such that each element at index i is the product \nof all elements in the array except the one at index i.", "function_declaration": "def product_array(arr):", "function_name": "product_array", "parameter_list": "(arr)" }, { "docstring": null, "function_dec...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def product_array(arr):\n \"\"\"\n Returns a list such that each element at index i is the product \n of all elements in the array except the one at index...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041650", "row_id": 41650, "seed_ids": "[17931]" }
0.650375
Taco_41650
I
[ "product_array", "solve", "parse_input", "format_output" ]
4
[ [ "solve", "product_array" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
718cf062b84101fdb43db26f51399ab9f3fe99ac
65e7f1132ee6882ddfa3a349e36ed75521c13a8a
v1.0
instruct
Taco
Taco_41665_I
Anna is designing a computer network. The network consists of `n` computers connected by `m` directed cable links. Each connection `i` is described by three integers `u_i`, `v_i`, and `d_i` (1 ≤ `u_i`, `v_i` ≤ `n`), meaning there is a cable from computer `u_i` to computer `v_i` with a delay time of `d_i` milliseconds. ...
import heapq def shortest_path(n, m, edges, s, t): """ Find the shortest path from computer s to computer t in a network of n computers and m directed edges. """ graph = {i: [] for i in range(1, n + 1)} for u, v, d in edges: graph[u].append((v, d)) return dijkstra(graph, s, t) def di...
from solution import shortest_path def test_shortest_path_example1(): n, m = 5, 6 edges = [ (1, 2, 2), (2, 3, 3), (3, 5, 1), (4, 3, 4), (1, 4, 8), (5, 4, 2) ] s, t = 1, 5 assert shortest_path(n, m, edges, s, t) == 6 def test_shortest_path_example2():...
[ { "docstring": "Find the shortest path from computer s to computer t in a network of n computers and m directed edges.", "function_declaration": "def shortest_path(n, m, edges, s, t):", "function_name": "shortest_path", "parameter_list": "(n, m, edges, s, t)" }, { "docstring": "Dijkstra's al...
[ 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_shortest_path(n, m, connections, s, t):\n \"\"\"\n Function to find the shortest time for data to travel from computer s to computer...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041665", "row_id": 41665, "seed_ids": "[21990]" }
0.673478
Taco_41665
I
[ "shortest_path", "dijkstra" ]
2
[ [ "shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2a74f906a90fb1cd13759fff4d20adbcbeaa77aa
678519f53f1c3626ea65243ad6c03e92db9c8296
v1.0
instruct
Taco
Taco_41674_I
Given a directed graph with $n$ nodes and $m$ edges, your task is to determine if there exists a path from a node $u$ to a node $v$. -----Input----- The first line of input contains two integers $n$ $(1 \leq n \leq 10^5)$ and $m$ $(0 \leq m \leq 2 \cdot 10^5)$, representing the number of nodes and edges in the graph,...
from collections import defaultdict, deque def build_graph(n, edges): graph = defaultdict(list) for a, b in edges: graph[a].append(b) return graph def bfs(graph, start, end): visited = set() queue = deque([start]) while queue: node = queue.popleft() if node == end:...
def test_basic_graph(): n = 5 edges = [ (1, 2), (2, 3), (3, 4), (4, 5), (1, 5) ] queries = [ (1, 5), (1, 3), (2, 5), (5, 1) ] expected = ["YES", "YES", "YES", "NO"] assert has_path(n, edges, queries) == expected def tes...
[ { "docstring": null, "function_declaration": "def build_graph(n, edges):", "function_name": "build_graph", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def bfs(graph, start, end):", "function_name": "bfs", "parameter_list": "(graph, start, end)"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_reach(n, m, edges, queries):\n from collections import defaultdict, deque\n\n def bfs(start, target):\n queue = deque([start])\n visite...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041674", "row_id": 41674, "seed_ids": "[22166]" }
0.72677
Taco_41674
I
[ "build_graph", "bfs", "has_path" ]
3
[ [ "has_path", "bfs" ], [ "has_path", "build_graph" ] ]
2
[]
false
[]
false
pytest
false
[]
true
d32143fe9fe6b2b02fdd3b0e3987b6a6812f3cc6
63b6e83e2040c7c19e0f41e00ea44b7615ce74fe
v1.0
instruct
Taco
Taco_41699_I
Alice loves palindromic numbers. A palindromic number is a positive integer that remains the same when its digits are reversed. Examples of palindromic numbers are 121, 484, 545, etc. Alice is curious to know the sum of the minimum palindromic number which is greater than or equal to each integer in a given range [a, ...
def is_palindrome(n): return str(n) == str(n)[::-1] def min_pal(x): while not is_palindrome(x): x += 1 return x def sum_min_palindromes(a, b): total_sum = 0 for num in range(a, b+1): total_sum += min_pal(num) return total_sum # Example usage: # a, b = map(int, input().split())...
from solution import sum_min_palindromes, min_pal, is_palindrome def test_sum_min_palindromes_example1(): assert sum_min_palindromes(13, 20) == 176 def test_sum_min_palindromes_example2(): assert sum_min_palindromes(123, 127) == 655 def test_sum_min_palindromes_single_value(): assert sum_min_palindromes(...
[ { "docstring": null, "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def min_pal(x):", "function_name": "min_pal", "parameter_list": "(x)" }, { "docstring": null, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\ndef min_pal(x):\n while not is_palindrome(x):\n x += 1\n return x\n\ndef sum_min_palindrom...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00041699", "row_id": 41699, "seed_ids": "[4765]" }
0.664439
Taco_41699
I
[ "is_palindrome", "min_pal", "sum_min_palindromes" ]
3
[ [ "min_pal", "is_palindrome" ], [ "sum_min_palindromes", "min_pal" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d4131876ead56755a7ee2e7d449963a86efb1534
cb9e8ccddb3d67145bdee4a90d8408fb60462ea6
v1.0
instruct
Taco
Taco_41717_I
You are given an array of integers. Your task is to sort the array such that the sum of the absolute differences between consecutive elements is minimized. If there are multiple arrays that produce the same minimal sum of absolute differences, return the lexicographically smallest array. For example, given array [1, 5...
def minimize_absolute_differences(test_cases): results = [] for case in test_cases: array = case[1:] sorted_array = sorted(array) results.append(sorted_array) return results def format_output(results): return [' '.join(map(str, result)) for result in results] def solve_problem(...
from solution import minimize_absolute_differences, format_output, solve_problem def test_minimize_absolute_differences(): assert minimize_absolute_differences([[3, 1, 5, 3]]) == [[1, 3, 5]] assert minimize_absolute_differences([[4, 8, 3, 6, 1]]) == [[1, 3, 6, 8]] def test_format_output(): assert format_o...
[ { "docstring": null, "function_declaration": "def minimize_absolute_differences(test_cases):", "function_name": "minimize_absolute_differences", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def format_output(results):", "function_name": "format_ou...
[ 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 sort_min_sum_diff(arrays):\n \"\"\"\n Returns the sorted arrays such that the sum of the absolute differences \n between consecutive elements is minim...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00041717", "row_id": 41717, "seed_ids": "[11104]" }
0.717937
Taco_41717
I
[ "minimize_absolute_differences", "format_output", "solve_problem" ]
3
[ [ "solve_problem", "format_output" ], [ "solve_problem", "minimize_absolute_differences" ] ]
2
[ "format_output" ]
false
[]
false
pytest
true
[]
true
24f0f244d305b2f2bb1e84b9ed2afc984eec7253
9e9c2aa55af3fde1e4ab72dc6e0c265d20aace6c
v1.0
instruct
Taco
Taco_41756_I
You are given a river represented by a 2D binary grid where '1' represents land and '0' represents water. You need to find the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are surrounded by water. --...
def num_islands(grid): def dfs(x, y): if x < 0 or x >= len(grid) or y < 0 or y >= len(grid[0]) or grid[x][y] == '0': return grid[x][y] = '0' # Mark the land as visited dfs(x - 1, y) dfs(x + 1, y) dfs(x, y - 1) dfs(x, y + 1) islands_count = 0 ...
def test_num_islands(): assert num_islands([ ["1","1","0","0","0"], ["1","1","0","0","1"], ["0","0","0","1","1"], ["0","0","0","1","0"] ]) == 2 assert num_islands([ ["1","1","1","0"], ["1","1","0","0"], ["1","0","0","1"], ["0","0","1","1"] ...
[ { "docstring": null, "function_declaration": "def num_islands(grid):", "function_name": "num_islands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def number_of_islands(T, test_cases):", "function_name": "number_of_islands", "parameter_list": "(T, ...
[ 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 num_islands(grid):\n \"\"\"\n Counts the number of islands in a given grid.\n \"\"\"\n if not grid:\n return 0\n\n m, n = len(grid), len(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041756", "row_id": 41756, "seed_ids": "[14951]" }
0.68563
Taco_41756
I
[ "num_islands", "number_of_islands", "process_input" ]
3
[ [ "number_of_islands", "num_islands" ], [ "process_input", "number_of_islands" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
e25af7a9ecf102c51298637111ab6015629b00c9
14a424a25ce03588fa9758418ff0bb3459f68453
v1.0
instruct
Taco
Taco_41820_I
Alice loves palindrome numbers, but she finds it challenging to identify the smallest larger palindrome for a given number. Therefore, she has come up with the following problem for practice. Given a positive integer `n`, produce the smallest palindrome number `p` such that `p > n`. A palindrome number reads the same...
def is_palindrome(num): """ Checks if the given number is a palindrome. """ return str(num) == str(num)[::-1] def next_palindrome(n): """ Finds the smallest palindrome number greater than n. """ n += 1 # Start checking the next number while not is_palindrome(n): n += 1 ...
from solution import is_palindrome, next_palindrome, find_next_palindromes def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(12321) == True assert is_palindrome(123) == False def test_next_palindrome(): assert next_palindrome(123) == 131 assert next_palindrome(808) =...
[ { "docstring": "Checks if the given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Finds the smallest palindrome number greater than n.", "function_declaration": "def next_palindr...
[ 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_palindrome(num):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef next_palin...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041820", "row_id": 41820, "seed_ids": "[5994]" }
0.797431
Taco_41820
I
[ "is_palindrome", "next_palindrome", "find_next_palindromes" ]
3
[ [ "find_next_palindromes", "next_palindrome" ], [ "next_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f2b731c83f82238aba76ddf0bbd46f468f8d5b91
70e9b93ac1aee009cc14a911d70bfbbc93fdfe00
v1.0
instruct
Taco
Taco_41824_I
Sara loves playing with numbers and creating new number sequences. She recently came up with a sequence where each term is the sum of the squares of its digits. She calls this sequence "Digit Square Sum Sequence". She wants to find out if a number is a "Happy Number" or not based on this sequence. A "Happy Number" is d...
def sum_of_squares_of_digits(n): """ Helper function to calculate the sum of the squares of the digits of a number. """ return sum(int(digit) ** 2 for digit in str(n)) def is_happy_number(n): """ Determine if the number 'n' is a Happy Number. """ seen = set() while n != 1 and n not ...
from solution import happy_number_test_cases def test_happy_number_test_cases(): assert happy_number_test_cases([19]) == ["HAPPY"] assert happy_number_test_cases([2]) == ["UNHAPPY"] assert happy_number_test_cases([7]) == ["HAPPY"] assert happy_number_test_cases([1]) == ["HAPPY"] assert happy_number...
[ { "docstring": "Helper function to calculate the sum of the squares of the digits of a number.", "function_declaration": "def sum_of_squares_of_digits(n):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(n)" }, { "docstring": "Determine if the number 'n' is a Happy Number."...
[ 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_happy_number(n):\n \"\"\"\n Determines if the given number n is a Happy Number.\n \"\"\"\n def sum_of_squares(num):\n return sum(int(digi...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00041824", "row_id": 41824, "seed_ids": "[17931]" }
0.594059
Taco_41824
I
[ "sum_of_squares_of_digits", "is_happy_number", "happy_number_test_cases" ]
3
[ [ "happy_number_test_cases", "is_happy_number" ], [ "is_happy_number", "sum_of_squares_of_digits" ] ]
2
[ "happy_number_test_cases" ]
false
[]
false
pytest
true
[]
true
5d5dcf98b4d354aa32b856ada333c8494cbbddf0
aa0273d53dd5f3b38ab2faafa0b36fbc8ce77f79
v1.0
instruct
Taco
Taco_41849_I
Create a seating arrangement for a wedding. You are given the names of the guests and the number of guests. Your task is to arrange the guests in alphabetical order by their first names using Merge Sort and Quick Sort algorithms respectively. Both algorithms should adhere to the following pseudocode: MergeSort(A) 1 if...
def merge_sort(guests): if len(guests) <= 1: return guests mid = len(guests) // 2 left = merge_sort(guests[:mid]) right = merge_sort(guests[mid:]) return merge(left, right) def merge(left, right): result = [] while left and right: if left[0].lower() <= right[0].lower(): ...
from solution import merge_sort, quick_sort, wedding_seating_arrangement def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single(): assert merge_sort(["Alice"]) == ["Alice"] def test_merge_sort_multiple(): assert merge_sort(["Charlie", "Alice", "Bob"]) == ["Alice", "Bob", "Cha...
[ { "docstring": null, "function_declaration": "def merge_sort(guests):", "function_name": "merge_sort", "parameter_list": "(guests)" }, { "docstring": null, "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" }, { ...
[ 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 merge_sort(guests):\n if len(guests) <= 1:\n return guests\n\n mid = len(guests) // 2\n left = merge_sort(guests[:mid])\n right = merge_sort...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041849", "row_id": 41849, "seed_ids": "[5667]" }
0.572857
Taco_41849
I
[ "merge_sort", "merge", "quick_sort", "wedding_seating_arrangement" ]
4
[ [ "merge_sort", "merge" ], [ "wedding_seating_arrangement", "merge_sort" ], [ "wedding_seating_arrangement", "quick_sort" ] ]
3
[]
false
[]
false
pytest
true
[]
true
3bdf49a8bccda1d1fde00ec75e93ebf6f652e1d3
0e1aaa6e9cf32b09698801bb5d74b5adbab9e57e
v1.0
instruct
Taco
Taco_41895_I
The students in a programming class are learning about prime numbers and sequences. They need your help to generate a specific sequence based on prime numbers. Given a number N, generate a sequence of the first N prime numbers followed by their sum. -----Input:----- - The first-line will contain T, the number of test...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True d...
import pytest from solution import generate_prime_sequences_from_input def test_generate_prime_sequences_sample(): input_data = "3\n2\n3\n5\n" expected_output = [ "2 3 5", "2 3 5 10", "2 3 5 7 11 28" ] assert generate_prime_sequences_from_input(input_data) == expected_output de...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generate the first N prime numbers and their sum.", "function_declaration": "def generate_primes_se...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n re...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041895", "row_id": 41895, "seed_ids": "[20077]" }
0.641918
Taco_41895
I
[ "is_prime", "generate_primes_sequence", "process_test_cases", "generate_prime_sequences_from_input" ]
4
[ [ "generate_prime_sequences_from_input", "process_test_cases" ], [ "generate_primes_sequence", "is_prime" ], [ "process_test_cases", "generate_primes_sequence" ] ]
3
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
5a537aee33997a03fdecb538a2e344c1836ebde5
f4b79652fa7abdd92dcc6e814646f7b3f2c97173
v1.0
instruct
Taco
Taco_41926_I
Your task is to write a program that generates and validates a sequence of Lychrel numbers starting from a given integer n up to the maximum number of iterations m. Note: A Lychrel number is a natural number that cannot form a palindrome through the iterative process of repeatedly reversing its digits and adding the r...
def is_palindrome(n): return str(n) == str(n)[::-1] def reverse_number(n): return int(str(n)[::-1]) def find_lychrel(n, m): for _ in range(m): reversed_n = reverse_number(n) n += reversed_n if is_palindrome(n): return n return "LYCHREL" # Example usage: if __name__...
from solution import find_lychrel def test_find_lychrel_palindrome_found(): assert find_lychrel(56, 3) == 121 assert find_lychrel(47, 1) == 121 assert find_lychrel(349, 3) == 7337 def test_find_lychrel_no_palindrome(): assert find_lychrel(196, 10) == "LYCHREL" assert find_lychrel(295, 50) == "LYCH...
[ { "docstring": null, "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def reverse_number(n):", "function_name": "reverse_number", "parameter_list": "(n)" }, { "docst...
[ 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 reverse_number(num):\n return int(str(num)[::-1])\n\ndef is_palindrome(num):\n return str(num) == str(num)[::-1]\n\ndef lychrel_number(n, m):\n for _ ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00041926", "row_id": 41926, "seed_ids": "[2836]" }
0.666862
Taco_41926
I
[ "is_palindrome", "reverse_number", "find_lychrel" ]
3
[ [ "find_lychrel", "is_palindrome" ], [ "find_lychrel", "reverse_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c958bf699748da3fc20bb27871c10e4f9820fe60
8dfd4a95ccdbd327c465512a3540aa95556a43ce
v1.0
instruct
Taco
Taco_41946_I
You are given an array of integers. The following algorithm needs to be applied to find a special type of subsequence: 1. Find the longest subsequence where every element is a prime number. 2. If there are multiple subsequences of the same maximum length, choose the one with the smallest sum. 3. If there is still a ti...
import math def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def longest_prime...
from solution import longest_prime_subsequence def test_example_case_1(): assert longest_prime_subsequence([1, 3, 5, 4, 9, 11, 13, 6, 7, 17]) == [3, 5, 11, 13, 7, 17] def test_example_case_2(): assert longest_prime_subsequence([4, 6, 8, 10, 12, 14]) == [] def test_custom_case_1(): assert longest_prime_su...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def longest_prime_subsequence(arr):", "function_name": "longest_prime_subsequence", "parameter_list": "(arr)"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n ret...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041946", "row_id": 41946, "seed_ids": "[3933]" }
0.770396
Taco_41946
I
[ "is_prime", "longest_prime_subsequence" ]
2
[ [ "longest_prime_subsequence", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b949b24ea1ed405adecff1a4f6d9fd855121f3ed
012751deea2e8c46c738aac45fefa43f4295dc42
v1.0
instruct
Taco
Taco_41957_I
Aria loves reading books and she has a large collection of them. Each of her books has a unique serial number from 1 to n. She decides to organize her books in such a way that the difference between the serial numbers of any two consecutive books in a row is a prime number. Aria wants to organize her books in the longe...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def longest_prime_row(n): ""...
from solution import longest_prime_row def test_example_1(): n = 10 k, sequence = longest_prime_row(n) assert k >= 3 and set(sequence).issubset(set(range(1, n+1))) def test_example_2(): n = 15 k, sequence = longest_prime_row(n) assert k >= 5 and set(sequence).issubset(set(range(1, n+1))) def ...
[ { "docstring": "Check if a number is prime. ", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Calculate the longest row of books with consecutive prime differences. ", "function_declaration": "def longest_prime_row(...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\" Check if a number is prime. \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 ==...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00041957", "row_id": 41957, "seed_ids": "[7433]" }
0.627981
Taco_41957
I
[ "is_prime", "longest_prime_row" ]
2
[ [ "longest_prime_row", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f9cbc9a4d1af6712e78e653eb319ac8809e6a2b3
76e74f9408a36877d67c77ae4f530348e758e4d6
v1.0
instruct
Taco
Taco_41987_I
Given two strings, `A` and `B`, find the length of the smallest string that contains both `A` and `B` as subsequences. That means their letters appear in order, but do not need to be contiguous. You have to determine the length of the smallest possible string that includes both `A` and `B` as subsequences. Input: - Th...
def lcs_length(A, B): """ Helper function to find the length of the Longest Common Subsequence (LCS) of A and B. """ m = len(A) n = len(B) dp = [[0] * (n + 1) for _ in range(m + 1)] for i in range(1, m + 1): for j in range(1, n + 1): if A[i - 1] == B[j - 1]: ...
from solution import smallest_supersequence_length, smallest_supersequence_lengths def test_single_case_1(): assert smallest_supersequence_length('abc', 'ac') == 3 def test_single_case_2(): assert smallest_supersequence_length('horizon', 'noz') == 8 def test_multiple_cases(): test_cases = [('abc', 'ac'),...
[ { "docstring": "Helper function to find the length of the Longest Common Subsequence (LCS) of A and B.", "function_declaration": "def lcs_length(A, B):", "function_name": "lcs_length", "parameter_list": "(A, B)" }, { "docstring": "Function to find the length of the smallest string that conta...
[ 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 lcs_length(A, B):\n \"\"\"\n Helper function to find the length of the Longest Common Subsequence (LCS) of A and B.\n \"\"\"\n m = len(A)\n n = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00041987", "row_id": 41987, "seed_ids": "[20158]" }
0.761661
Taco_41987
I
[ "lcs_length", "smallest_supersequence_length", "smallest_supersequence_lengths" ]
3
[ [ "smallest_supersequence_length", "lcs_length" ], [ "smallest_supersequence_lengths", "smallest_supersequence_length" ] ]
2
[]
false
[]
false
pytest
true
[]
true
bf1d4362e30720e0d8643b3ad06f8f2f4e1b08b3
5783118123bad2579a6a9c55eda13126246fa471
v1.0
instruct
Taco
Taco_42054_I
You are given a list of integers representing the number of pages in each chapter of a book. You need to read the entire book within a given number of days, with the constraint that each day you must read a contiguous sequence of chapters and the total number of pages you read each day should be approximately the same....
def can_split(chapters, days, max_pages_per_day): current_sum = 0 days_needed = 1 for pages in chapters: if current_sum + pages > max_pages_per_day: days_needed += 1 current_sum = pages if days_needed > days: return False else: ...
from solution import min_max_pages def test_min_max_pages_case1(): assert min_max_pages([10, 20, 30, 40, 50], 2) == 90 def test_min_max_pages_case2(): assert min_max_pages([10, 30, 40, 20], 3) == 40 def test_min_max_pages_case3(): assert min_max_pages([5, 5, 5, 5, 5], 5) == 5 def test_min_max_pages_case...
[ { "docstring": null, "function_declaration": "def can_split(chapters, days, max_pages_per_day):", "function_name": "can_split", "parameter_list": "(chapters, days, max_pages_per_day)" }, { "docstring": null, "function_declaration": "def min_max_pages(chapters, days):", "function_name...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_pages(chapters, days):\n def can_read_in_days(max_pages, days):\n current_sum = 0\n required_days = 1\n for pages in chapters:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042054", "row_id": 42054, "seed_ids": "[24552]" }
0.684887
Taco_42054
I
[ "can_split", "min_max_pages" ]
2
[ [ "min_max_pages", "can_split" ] ]
1
[]
false
[]
false
pytest
true
[]
true
389bc3d4646a57a33040c32970a2ff30b8965c25
200443471a825e30efc807e4c909d70f835207f0
v1.0
instruct
Taco
Taco_42063_I
A company has developed a new scheduling application to manage the tasks and meetings of its employees. A meeting or a task can be represented as an event with a start time and an end time in minutes. Each employee has a list of events they need to attend or complete for the day. Two events do not overlap if one ends b...
def min_meeting_rooms(events): """ Returns the minimum number of rooms required to accommodate all events. """ if not events: return 0 start_times = sorted([start for start, end in events]) end_times = sorted([end for start, end in events]) start_ptr, end_ptr = 0, 0 num_rooms, ...
from solution import min_meeting_rooms, min_rooms_for_employees def test_min_meeting_rooms_no_overlap(): assert min_meeting_rooms([(100, 120), (150, 200), (210, 220)]) == 1 def test_min_meeting_rooms_with_overlap(): assert min_meeting_rooms([(60, 150), (30, 120), (200, 220), (100, 200), (140, 180), (180, 210)...
[ { "docstring": "Returns the minimum number of rooms required to accommodate all events.", "function_declaration": "def min_meeting_rooms(events):", "function_name": "min_meeting_rooms", "parameter_list": "(events)" }, { "docstring": "Given the number of employees and their schedules, return ...
[ 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 min_rooms_required(n, schedules):\n events = []\n for employee_schedule in schedules:\n for event in employee_schedule:\n events.append...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00042063", "row_id": 42063, "seed_ids": "[16308]" }
0.724265
Taco_42063
I
[ "min_meeting_rooms", "min_rooms_for_employees" ]
2
[ [ "min_rooms_for_employees", "min_meeting_rooms" ] ]
1
[]
false
[]
false
pytest
true
[]
true
259d37613ef845a2be5b2d27f29f361f5e2a047b
1c99883486a1800f3b12771e82af1d2fa783e610
v1.0
instruct
Taco
Taco_42092_I
Maya loves to play with words and numbers. Recently, she came across a puzzle involving prime numbers and palindromes. She decided to combine both concepts and created a challenging problem for her friends. The task is to find the smallest palindrome that is a prime number and greater than a given number N. As you kno...
def is_palindrome(number): return str(number) == str(number)[::-1] def is_prime(number): if number <= 1: return False if number <= 3: return True if number % 2 == 0 or number % 3 == 0: return False i = 5 while i * i <= number: if number % i == 0 or number % (i + ...
from solution import is_palindrome, is_prime, smallest_prime_palindrome_greater_than def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1) == True assert is_palindrome(22) == True def test_is_prime(): assert is_prime(2) == True a...
[ { "docstring": null, "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n return str(number) == str(number)[::-1]\n\ndef is_prime(number):\n if number <= 1:\n return False\n if number <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00042092", "row_id": 42092, "seed_ids": "[4210]" }
0.726928
Taco_42092
I
[ "is_palindrome", "is_prime", "smallest_prime_palindrome_greater_than", "main" ]
4
[ [ "smallest_prime_palindrome_greater_than", "is_palindrome" ], [ "smallest_prime_palindrome_greater_than", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9f305fa8cf8cd6ee94843ec5f7b8800652530789
84de22f599e09b897ed95ca08ca51db3e2251f3b
v1.0
instruct
Taco
Taco_42106_I
A group of friends loves playing a game called "Magic Words". They believe that some words have magical properties, such as those that can be read the same backward and forward, known as palindromes. They want to create a new version of the game where a sequence of operations can modify words by inserting characters wi...
def is_palindrome(word): """ Returns True if the provided word is a palindrome, False otherwise. """ return word == word[::-1] def process_operations(s, operations): """ Processes the given operations on the string s and checks if the resulting string is a palindrome after each operation. ...
from solution import is_palindrome, process_operations # Test the is_palindrome function def test_is_palindrome(): assert is_palindrome("aba") == True assert is_palindrome("abba") == True assert is_palindrome("abc") == False assert is_palindrome("a") == True assert is_palindrome("") == True # Test...
[ { "docstring": "Returns True if the provided word is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docstring": "Processes the given operations on the string s and checks if the resulting...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(word):\n return word == word[::-1]\n\ndef magic_words_game(s, operations):\n results = []\n for char, pos in operations:\n s = s[...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042106", "row_id": 42106, "seed_ids": "[9003]" }
0.788735
Taco_42106
I
[ "is_palindrome", "process_operations", "main" ]
3
[ [ "process_operations", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dc2cc8fcd36bd9a84d255dd6e3167d0cb9ce27fc
82627c5ced612fc14e43ce50e1cdd4c9e1db4fc3
v1.0
instruct
Taco
Taco_42117_I
Alice is developing a new feature for her text editor that supports syntax highlighting for nested brackets. She has defined three types of brackets: `()`, `[]`, and `{}`. The editor should be able to verify if a string composed of these brackets is properly nested and balanced. A string is considered properly nested i...
def is_balanced(s): """ Helper function that checks if a single string s is properly nested and balanced. """ stack = [] matching_bracket = {')': '(', '}': '{', ']': '['} for char in s: if char in '({[': stack.append(char) elif char in ')}]': if not s...
from solution import check_brackets def test_check_brackets_single_valid_case(): assert check_brackets(1, ["([]{})"]) == ["YES"] def test_check_brackets_single_invalid_case(): assert check_brackets(1, ["([)]"]) == ["NO"] def test_check_brackets_multiple_cases(): assert check_brackets(3, ["([]{})", "([)]"...
[ { "docstring": "Helper function that checks if a single string s is properly nested and balanced.", "function_declaration": "def is_balanced(s):", "function_name": "is_balanced", "parameter_list": "(s)" }, { "docstring": "Returns a list of \"YES\" or \"NO\" for each string, \nindicating if t...
[ 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_balanced_brackets(string):\n \"\"\"\n Check if the brackets in the given string are properly nested and balanced.\n \"\"\"\n stack = []\n bra...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042117", "row_id": 42117, "seed_ids": "[17550]" }
0.771566
Taco_42117
I
[ "is_balanced", "check_brackets" ]
2
[ [ "check_brackets", "is_balanced" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a65d992c8b33c5675f724df8e90d640e4a3e33a6
cfe3d738422ca0f115ca96c0f671f3f3410681b9
v1.0
instruct
Taco
Taco_42120_I
You are tasked with implementing a system that manages a company's supply chain. The company deals in different products, each identified by a unique product code. They have several suppliers who provide these products, and each supplier has a unique supplier code. Each supplier provides certain products at specific pr...
def build_supplier_dict(n, supplier_data): supplier_dict = {} index = 0 for i in range(n): supplier_code = supplier_data[index] index += 1 m = supplier_data[index] index += 1 products = {} for _ in range(m): product_code, price = supplier_data[inde...
def test_build_supplier_dict(): supplier_data = [ 1, 2, 1002, 150, 1003, 200, 2, 3, 1001, 300, 1002, 250, 1003, 350 ] n = 2 expected = { 1: {1002: 150, 1003: 200}, 2: {1001: 300, 1002: 250, 1003: 350} } assert build_supplier_dict(n, supplier_data) == expected def...
[ { "docstring": null, "function_declaration": "def build_supplier_dict(n, supplier_data):", "function_name": "build_supplier_dict", "parameter_list": "(n, supplier_data)" }, { "docstring": null, "function_declaration": "def query_prices(n, q, supplier_data, queries):", "function_name"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def manage_supply_chain(suppliers, queries):\n supply_data = {}\n \n for supplier in suppliers:\n supplier_code, products = supplier[0], supplier[1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042120", "row_id": 42120, "seed_ids": "[19970]" }
0.718057
Taco_42120
I
[ "build_supplier_dict", "query_prices" ]
2
[ [ "query_prices", "build_supplier_dict" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9dee6384f120c26e94142683f37c84f638244496
908936759c34df3e8ca754992e00ee9069a1c581
v1.0
instruct
Taco
Taco_42183_I
Megan wants to determine the smallest multiple of all the integers in a given array. Your task is to devise an efficient algorithm to compute the least common multiple (LCM) of an array of unique positive integers. All inputs will be valid. Passing [4, 6, 8] should return 24, as 24 is the smallest number that all given...
from math import gcd from functools import reduce def lcm(a, b): """ Helper function to compute the Least Common Multiple (LCM) of two integers. """ return a * b // gcd(a, b) def smallest_multiple(arr): """ Returns the smallest multiple (Least Common Multiple) of all the unique positive intege...
from solution import smallest_multiple def test_smallest_multiple_example1(): assert smallest_multiple([5, 7, 11]) == 385 def test_smallest_multiple_example2(): assert smallest_multiple([2, 3, 4, 5]) == 60 def test_smallest_multiple_example3(): assert smallest_multiple([12, 15, 18, 20]) == 180 def test_...
[ { "docstring": "Helper function to compute the Least Common Multiple (LCM) of two integers.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest multiple (Least Common Multiple) of all the unique positive integ...
[ 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 math\nfrom functools import reduce\n\ndef lcm(a, b):\n \"\"\"\n Calculate the Least Common Multiple of two integers a and b.\n \"\"\"\n return a...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00042183", "row_id": 42183, "seed_ids": "[10540]" }
0.60251
Taco_42183
I
[ "lcm", "smallest_multiple" ]
2
[ [ "smallest_multiple", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e286c24a56e689f55e86ff9f69d47d7fc9719ccc
cde1589e53c7211759820bf2f17f6a7c2e56738e
v1.0
instruct
Taco
Taco_42253_I
You are given a string $s$ of length $n$ consisting of lowercase English letters. You want to make the string a palindrome by adding the minimum number of characters to it. You need to determine the length of the shortest palindrome that can be obtained. To achieve this, you can insert characters only at the beginning...
def shortest_palindrome_length(s): """ Returns the length of the shortest palindrome that can be obtained by adding the minimum number of characters at the beginning or end of the string. """ n = len(s) # Check if the string is already a palindrome if s == s[::-1]: return n ...
from solution import solve def test_example_1(): assert solve(2, [(3, 'abc'), (4, 'aabb')]) == [5, 6] def test_single_character(): assert solve(1, [(1, 'a')]) == [1] assert solve(1, [(1, 'z')]) == [1] def test_already_palindrome(): assert solve(1, [(3, 'aba')]) == [3] assert solve(1, [(4, 'abba')...
[ { "docstring": "Returns the length of the shortest palindrome that can be obtained by adding the minimum\nnumber of characters at the beginning or end of the string.", "function_declaration": "def shortest_palindrome_length(s):", "function_name": "shortest_palindrome_length", "parameter_list": "(s)"...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def shortest_palindrome_length(s):\n \"\"\"\n Returns the length of the shortest palindrome that can be obtained by adding the minimum\n number of charact...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00042253", "row_id": 42253, "seed_ids": "[11307]" }
0.848847
Taco_42253
I
[ "shortest_palindrome_length", "solve_palindrome_case", "solve" ]
3
[ [ "solve", "solve_palindrome_case" ], [ "solve_palindrome_case", "shortest_palindrome_length" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e4cc8474dca8e8b467cc31c8f0e4bf5b17b8dfa0
703db2f004c62e9ae8d2b94a8bbd43f0375ea4db
v1.0
instruct
Taco
Taco_42255_I
You are in charge of developing software to balance chemical reactions. A chemical reaction consists of a set of reactants and a set of products. Each reactant and product is represented by a chemical formula, which consists of elements and their respective counts. The goal is to determine if the given reaction is bala...
import re from collections import defaultdict def parse_formula(formula): element_counts = defaultdict(int) elements = re.findall(r'([A-Z][a-z]?)(\d*)', formula) for element, count in elements: count = int(count) if count else 1 element_counts[element] += count return element_counts de...
from solution import balance_reactions def test_single_atomic_element(): reactions = ["H2 -> H2"] assert balance_reactions(1, reactions) == ["Balanced"] def test_simple(): reactions = ["H2 + O2 -> H2O"] assert balance_reactions(1, reactions) == ["Unbalanced"] def test_glucose_reaction(): reaction...
[ { "docstring": null, "function_declaration": "def parse_formula(formula):", "function_name": "parse_formula", "parameter_list": "(formula)" }, { "docstring": null, "function_declaration": "def parse_side(side):", "function_name": "parse_side", "parameter_list": "(side)" }, { ...
[ 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 re\nfrom collections import defaultdict\n\ndef parse_formula(formula):\n \"\"\"\n Parses the chemical formula into a dictionary of element counts.\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00042255", "row_id": 42255, "seed_ids": "[15312]" }
0.593351
Taco_42255
I
[ "parse_formula", "parse_side", "is_balanced_reaction", "balance_reactions" ]
4
[ [ "balance_reactions", "is_balanced_reaction" ], [ "is_balanced_reaction", "parse_side" ], [ "parse_side", "parse_formula" ] ]
3
[]
false
[]
false
pytest
true
[]
true
01e443e9882c65af4278eb446df98fdf96e5daf9
45828e572c90c7f86108ae60d2b163d03e997007
v1.0
instruct
Taco
Taco_42343_I
Given a list of integers, write a function that returns the sum of all prime numbers in the list. Input The first line contains an integer n, which is the number of elements in the list. The second line contains n integers separated by a space. Output Print a single integer, which is the sum of all prime numbers in ...
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True ...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(-5) == Fal...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers in the given list.", "function_declaration": "def sum_of_prime...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Helper function to determine if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042343", "row_id": 42343, "seed_ids": "[24188]" }
0.68972
Taco_42343
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
178217b9506ab9b2811be314a50be230c4ba2e29
0bdc5c732a2b11a6457ad8e16a61c03bf81ab4b8
v1.0
instruct
Taco
Taco_42523_I
A local artist wants to create a unique sculpture consisting of several geometric shapes arranged together. The sculpture should be anchored to the ground with pegs placed at specified coordinates. Given n pegs, the artist needs to use the shortest possible rope to connect the pegs in a closed loop in a way that it pas...
import itertools import math def euclidean_distance(point1, point2): """ Calculates the Euclidean distance between two points. """ return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def minimum_rope_length(pegs): """ Computes the minimum length of rope required to co...
def test_euclidean_distance(): assert round(euclidean_distance((0, 0), (3, 4)), 2) == 5.00 assert round(euclidean_distance((1, 1), (1, 1)), 2) == 0.00 assert round(euclidean_distance((0, 0), (0, 0)), 2) == 0.00 assert round(euclidean_distance((-1, -1), (2, 3)), 2) == 5.00 def test_minimum_rope_length_c...
[ { "docstring": "Calculates the Euclidean distance between two points.", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Computes the minimum length of rope required to connect al...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom scipy.spatial.distance import pdist, squareform\nfrom scipy.optimize import linear_sum_assignment\n\ndef calculate_distance_matrix(coords)...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00042523", "row_id": 42523, "seed_ids": "[14178]" }
0.615627
Taco_42523
I
[ "euclidean_distance", "minimum_rope_length", "read_input" ]
3
[ [ "minimum_rope_length", "euclidean_distance" ] ]
1
[ "read_input" ]
false
[]
false
pytest
false
[]
true
38535953d4f6831762d5ed4deb86e2dd109f648c
7858cd11921641179b09bc261b3ae094c9134008
v1.0
instruct
Taco
Taco_42557_I
A group of friends wants to participate in a relay race. The race track is divided into N segments, each segment potentially having a different terrain and thus, a different time to traverse. The team consists of K runners, and each runner can only cover contiguous segments. The task is to minimize the maximum time tak...
def can_divide_with_max_time(time, N, K, max_time): """ Helper function to decide if it is possible to divide the segments such that no runner has to cover more than max_time. """ current_sum = 0 required_runners = 1 for t in time: if current_sum + t > max_time: requ...
from solution import minimize_max_time, process_input def test_minimize_max_time(): # Test Case 1 input_data = '''2 5 2 1 2 3 4 5 4 3 2 1 4 2''' T, test_cases = process_input(input_data) results = minimize_max_time(T, test_cases) assert results == [9, 4] # Test Case 2 input_data = '''1...
[ { "docstring": "Helper function to decide if it is possible to divide the segments such that\nno runner has to cover more than max_time.", "function_declaration": "def can_divide_with_max_time(time, N, K, max_time):", "function_name": "can_divide_with_max_time", "parameter_list": "(time, N, K, max_t...
[ 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 minimize_max_time(T, cases):\n def is_possible(mid, K, time):\n current_sum = 0\n required_runners = 1\n for t in time:\n if...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00042557", "row_id": 42557, "seed_ids": "[1224]" }
0.664964
Taco_42557
I
[ "can_divide_with_max_time", "minimize_max_time", "process_input", "main" ]
4
[ [ "minimize_max_time", "can_divide_with_max_time" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
6a0bf46ab279cf535dc14bc5fcda0be641acebfb
722bfa81f8ede7c0ea8b0e86c615e7217599fedb
v1.0
instruct
Taco
Taco_42580_I
Write a program which determines if a given year is a leap year. Constraints * The year is a positive integer not greater than 10,000. Input The input consists of multiple datasets. Each dataset consists of a single integer year. The input ends with a single 0 (when the year is zero). Output For each dataset, pr...
def is_leap_year(year): """ Determines if a given year is a leap year. Returns "Yes" if the year is a leap year, otherwise "No". """ if year == 0: return None # Special case for input ending if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): return "Yes" else: ...
def test_is_leap_year(): assert is_leap_year(2000) == "Yes" assert is_leap_year(1996) == "Yes" assert is_leap_year(1900) == "No" assert is_leap_year(2001) == "No" assert is_leap_year(0) == None def test_process_years(): assert process_years([2000, 1996, 1900, 2001, 0]) == ["Yes", "Yes", "No", "...
[ { "docstring": "Determines if a given year is a leap year.\nReturns \"Yes\" if the year is a leap year, otherwise \"No\".", "function_declaration": "def is_leap_year(year):", "function_name": "is_leap_year", "parameter_list": "(year)" }, { "docstring": "Process a list of years and return a l...
[ 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_leap_year(year):\n \"\"\"\n Determines if a given year is a leap year.\n A year is a leap year if:\n 1. It is divisible by 4, but not divisible ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042580", "row_id": 42580, "seed_ids": "[22834]" }
0.544514
Taco_42580
I
[ "is_leap_year", "process_years" ]
2
[ [ "process_years", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2924e45857b1eebc379a8a2613d3c34f3580c754
b0ff94fd553933c3979ccd3e6f111f04776ce4e0
v1.0
instruct
Taco
Taco_42588_I
In a country far, far away, there exists a rectangular maze consisting of $N$ rows and $M$ columns. Each cell in the maze is either free (denoted by '.') or blocked (denoted by '#'). You are given the dimensions of the maze and the maze itself. Your task is to determine if there exists a path from the top-left corner (...
from collections import deque def can_escape(grid, n, m): directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] # Down, Right, Up, Left visited = [[False] * m for _ in range(n)] queue = deque([(0, 0)]) # Start from the top-left corner while queue: x, y = queue.popleft() if x == n - 1 and y...
def test_is_path_exists_sample_1(): n, m, q = 4, 4, 2 grid = [ "....", ".#..", "..#.", "...." ] operations = [(1, 3), (3, 4)] assert is_path_exists(n, m, q, grid, operations) == "YES" def test_is_path_exists_sample_2(): n, m, q = 3, 3, 1 grid = [ ".#....
[ { "docstring": null, "function_declaration": "def can_escape(grid, n, m):", "function_name": "can_escape", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def is_path_exists(n, m, q, grid, operations):", "function_name": "is_path_exists", "parame...
[ 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 swap_rows(maze, x, y):\n \"\"\"\n Swaps the x-th row with y-th row in the maze.\n \"\"\"\n maze[x], maze[y] = maze[y], maze[x]\n\ndef find_path_bfs...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00042588", "row_id": 42588, "seed_ids": "[18216]" }
0.681328
Taco_42588
I
[ "can_escape", "is_path_exists" ]
2
[ [ "is_path_exists", "can_escape" ] ]
1
[]
false
[]
false
pytest
false
[]
true
35e6ae9071ae6d77b6ebe58e128075c939400ee4
4fbfa64a92edd25dff0110869a93db8391bf7471
v1.0
instruct
Taco
Taco_42613_I
In a small town, there is a unique tradition where town members form a queue for a festival and each person wears a unique hat with a number on it. The Festival Committee wants to find a way to identify a specific order in which people can be picked such that each person in this sub-sequence has a hat number that is st...
def longest_increasing_subsequence(arr): """ Returns the length of the longest increasing subsequence in the given array. """ if not arr: return 0 n = len(arr) dp = [1] * n # dp[i] will be the length of the LIS ending at index i for i in range(1, n): for j in range...
def test_longest_increasing_subsequence(): assert max_people_picked(5, [1, 3, 2, 5, 4]) == 3 assert max_people_picked(6, [10, 20, 10, 30, 20, 50]) == 4 assert max_people_picked(1, [1]) == 1 assert max_people_picked(2, [5, 5]) == 1 assert max_people_picked(8, [1, 2, 1, 3, 2, 4, 3, 5]) == 5 assert...
[ { "docstring": "Returns the length of the longest increasing subsequence in the given array.", "function_declaration": "def longest_increasing_subsequence(arr):", "function_name": "longest_increasing_subsequence", "parameter_list": "(arr)" }, { "docstring": "Returns the maximum number of peo...
[ 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 longest_increasing_subsequence_length(n, hat_numbers):\n if n == 0:\n return 0\n \n # Initialize the DP array\n lis = [1] * n\n \n for...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00042613", "row_id": 42613, "seed_ids": "[23650]" }
0.66714
Taco_42613
I
[ "longest_increasing_subsequence", "max_people_picked" ]
2
[ [ "max_people_picked", "longest_increasing_subsequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d3479f367d4d6430450e5e43981db2aada4d793f
52b201f547c7cf0f484709b160e014df2be3cdb3
v1.0
instruct
Taco
Taco_42615_I
A "Magic Square" is an n × n matrix of distinct integers such that the sum of the integers in each row, each column, and the two main diagonals is the same. You are given an integer n (odd and 3 ≤ n ≤ 9). Output the **n × n matrix** that forms a magic square. Input The only line of input contains an integer n. Outpu...
def generate_magic_square(n): if n < 3 or n > 9 or n % 2 == 0: raise ValueError("n must be an odd integer between 3 and 9 inclusive.") magic_square = [[0] * n for _ in range(n)] num = 1 i, j = 0, n // 2 while num <= n * n: magic_square[i][j] = num num += 1 ...
from solution import generate_magic_square, format_magic_square, magic_square def test_generate_magic_square(): assert generate_magic_square(3) == [ [8, 1, 6], [3, 5, 7], [4, 9, 2] ] assert generate_magic_square(5) == [ [17, 24, 1, 8, 15], [23, 5, 7, 14, 16], ...
[ { "docstring": null, "function_declaration": "def generate_magic_square(n):", "function_name": "generate_magic_square", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def format_magic_square(matrix):", "function_name": "format_magic_square", "parameter_l...
[ 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 generate_magic_square(n):\n \"\"\"\n Generates and returns an n x n magic square.\n \n Parameters:\n n (int): The size of the magic square (...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00042615", "row_id": 42615, "seed_ids": "[22564]" }
0.723054
Taco_42615
I
[ "generate_magic_square", "format_magic_square", "magic_square" ]
3
[ [ "magic_square", "format_magic_square" ], [ "magic_square", "generate_magic_square" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fa9b5777d6a80d6bf5d97ecfa1b6d40df2c92841
b77144d357da406f16610e91f08fa11c398695f3
v1.0
instruct
Taco
Taco_42637_I
In a grid of size `M x N`, each cell is either black or white. A rectangle is defined as an area bounded by four sides, and a filled rectangle is one where all cells inside it are black. You need to determine the size of the largest filled rectangle in the grid, i.e., the rectangle that contains the maximum number of b...
def largest_filled_rectangle(grid): """ Returns the size of the largest filled rectangle in a grid. """ if not grid or not grid[0]: return 0 M = len(grid) N = len(grid[0]) max_area = 0 # Create an array to store the heights of each column heights = [0] * N for row in r...
def test_largest_filled_rectangle(): assert largest_filled_rectangle([[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]]) == 6 assert largest_filled_rectangle([[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0 assert largest_filled_rectangle([[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]]) ==...
[ { "docstring": "Returns the size of the largest filled rectangle in a grid.", "function_declaration": "def largest_filled_rectangle(grid):", "function_name": "largest_filled_rectangle", "parameter_list": "(grid)" }, { "docstring": "Helper function to calculate the maximum rectangle area in a...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef largest_filled_rectangle(grid: List[List[int]]) -> int:\n if not grid:\n return 0\n \n M, N = len(grid), len(grid[0]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042637", "row_id": 42637, "seed_ids": "[23629]" }
0.726696
Taco_42637
I
[ "largest_filled_rectangle", "max_histogram_area" ]
2
[ [ "largest_filled_rectangle", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ed5a36cf17d96355fbf9e340a9655d21327fa61f
8f4ef96bf28d94584ec31d7ae5a7b1d31c3499cd
v1.0
instruct
Taco
Taco_42641_I
Chris is designing a password checker for a new software application. The goal is to ensure that the password meets specific criteria for security purposes. The password must adhere to the following rules: 1. The password must be at least 8 characters long. 2. The password must include at least one lowercase and one ...
def is_valid_password(password): if len(password) < 8: return False has_lower = has_upper = has_digit = has_special = False special_characters = set("!@#$%^&*()_+") for char in password: if char.islower(): has_lower = True elif char.isupper(): has_upper ...
from solution import password_checker def test_valid_passwords(): assert password_checker(3, ["Password1@", "GoodPa$$word123!", "V4l!d*Pwd"]) == ["Valid", "Valid", "Valid"] def test_invalid_passwords(): assert password_checker(3, ["short1!", "NoSpecialChar123", "lowercase123!"]) == ["Invalid", "Invalid", "Inv...
[ { "docstring": null, "function_declaration": "def is_valid_password(password):", "function_name": "is_valid_password", "parameter_list": "(password)" }, { "docstring": null, "function_declaration": "def password_checker(t, passwords):", "function_name": "password_checker", "param...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_password(password):\n \"\"\"\n Checks if the given password is valid based on the specified criteria.\n \"\"\"\n if len(password) < 8:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042641", "row_id": 42641, "seed_ids": "[11814]" }
0.674283
Taco_42641
I
[ "is_valid_password", "password_checker" ]
2
[ [ "password_checker", "is_valid_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef871d189e5d88e2ccab86d5035d3ffafb1d292e
6b8f679c4b7aca5b25d67c14a8ce380695e43083
v1.0
instruct
Taco
Taco_42677_I
Maximum Binary Tree Problem Statement Given an integer array with distinct values, the maximum binary tree is defined as follows: 1. The root is the maximum number in the array. 2. The left subtree is the maximum tree constructed from the left part subarray divided by the maximum number. 3. The right subtree is the ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def construct_maximum_binary_tree(nums): if not nums: return None # Find the maximum number and its index max_index = nums.index(max(nums)) max_value...
from solution import solve def test_example_1(): input_string = "3 2 1 6 0 5" assert solve(input_string) == "6 3 2 1 5 0" def test_example_2(): input_string = "10 9 8 7 6" assert solve(input_string) == "10 9 8 7 6" def test_single_element(): input_string = "42" assert solve(input_string) == "...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef construct_maximum_binary_tr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042677", "row_id": 42677, "seed_ids": "[14331]" }
0.607681
Taco_42677
I
[ "construct_maximum_binary_tree", "preorder_traversal", "maximum_binary_tree_preorder", "solve" ]
4
[ [ "maximum_binary_tree_preorder", "construct_maximum_binary_tree" ], [ "maximum_binary_tree_preorder", "preorder_traversal" ], [ "solve", "maximum_binary_tree_preorder" ] ]
3
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
f9c253b1b317a4b55032334736845927c41dd006
3a10e42846672e042e341bfc80f6508331156b9c
v1.0
instruct
Taco
Taco_42691_I
You are given a grid of size n x m, where each cell contains a positive integer representing the elevation at that point. You are also given two points (sx, sy) and (tx, ty) which represent the starting and target points on the grid, respectively. You want to determine the minimum cost to travel from the starting point...
import heapq def min_cost_path(n, m, grid, sx, sy, tx, ty): """ Computes the minimum cost to travel from (sx, sy) to (tx, ty) in a grid. """ directions = [(1, 0), (0, 1), (-1, 0), (0, -1)] cost = [[float('inf')] * m for _ in range(n)] cost[sx-1][sy-1] = 0 pq = [(0, sx-1, sy-1)] whi...
from solution import min_cost_path, solve def test_example_1(): grid = [ [1, 2, 2], [3, 8, 2], [5, 3, 5] ] start = (1, 1) end = (3, 3) assert solve(grid, start, end) == 4 def test_example_2(): grid = [ [1, 1000], [1000, 1] ] start = (1, 1) en...
[ { "docstring": "Computes the minimum cost to travel from (sx, sy) to (tx, ty) in a grid.", "function_declaration": "def min_cost_path(n, m, grid, sx, sy, tx, ty):", "function_name": "min_cost_path", "parameter_list": "(n, m, grid, sx, sy, tx, ty)" }, { "docstring": null, "function_declar...
[ 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 min_cost_travel(grid, sx, sy, tx, ty):\n n = len(grid)\n m = len(grid[0])\n \n def is_valid(x, y):\n return 0 <= x < n and 0...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042691", "row_id": 42691, "seed_ids": "[21159]" }
0.717849
Taco_42691
I
[ "min_cost_path", "solve" ]
2
[ [ "solve", "min_cost_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22d9ce8b8c6c5cde5d2818abe33c1d257fc4c833
7e2a7589095ef4216e47718ceba483437f017bf6
v1.0
instruct
Taco
Taco_42705_I
Anna loves trees and paths. She has a binary tree with N nodes. Each node of the tree has a unique integer value assigned to it. Anna is particularly interested in two types of paths: "Z-paths" and "O-paths." - A "Z-path" is a path from one leaf to another leaf passing through their lowest common ancestor (LCA). - An ...
import sys from collections import defaultdict, deque sys.setrecursionlimit(200000) def find_diameter(tree, N): def bfs(node): visited = [-1] * (N + 1) queue = deque([node]) visited[node] = 0 max_dist, farthest_node = 0, node while queue: cur = queue.po...
import pytest from solution import binary_tree_paths def test_sample_case_1(): N = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] result = binary_tree_paths(N, edges) assert result == (3, 3) def test_linear_case(): N = 4 edges = [(1, 2), (2, 3), (3, 4)] result = binary_tree_paths(N, edges) ...
[ { "docstring": null, "function_declaration": "def find_diameter(tree, N):", "function_name": "find_diameter", "parameter_list": "(tree, N)" }, { "docstring": null, "function_declaration": "def binary_tree_paths(N, edges):", "function_name": "binary_tree_paths", "parameter_list": ...
[ 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_max_path_lengths(N, edges):\n from collections import defaultdict, deque\n \n if N == 1:\n return 0, 0\n \n # Build the graph\n g...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00042705", "row_id": 42705, "seed_ids": "[8982]" }
0.632103
Taco_42705
I
[ "find_diameter", "binary_tree_paths" ]
2
[ [ "binary_tree_paths", "find_diameter" ] ]
1
[]
false
[]
false
pytest
true
[]
true
169f79f670147a436f656ae38099ceb0b9db3b50
9c61e4bde7d1642ad8b71db4ae5cf7f347b92f32
v1.0
instruct
Taco
Taco_42719_I
Rashmi is fascinated with arrays of integers and their sums. She has an array of size n and wants to divide the array into k non-empty contiguous subarrays such that the maximum sum among these subarrays is minimized. She seeks your help to find the minimized value of the maximum sum among the k subarrays for the giv...
def can_split(nums, n, k, max_sum): current_sum = 0 required_subarrays = 1 for num in nums: if current_sum + num > max_sum: required_subarrays += 1 current_sum = num if required_subarrays > k: return False else: current_sum...
from solution import minimize_max_sum, process_input def test_minimize_max_sum_case1(): n, k = 5, 2 nums = [1, 2, 3, 4, 5] assert minimize_max_sum(n, k, nums) == 9 def test_minimize_max_sum_case2(): n, k = 3, 1 nums = [1, 2, 3] assert minimize_max_sum(n, k, nums) == 6 def test_minimize_max_su...
[ { "docstring": null, "function_declaration": "def can_split(nums, n, k, max_sum):", "function_name": "can_split", "parameter_list": "(nums, n, k, max_sum)" }, { "docstring": null, "function_declaration": "def minimize_max_sum(n, k, nums):", "function_name": "minimize_max_sum", "p...
[ 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 minimize_maximum_sum(T, test_cases):\n def can_split(nums, max_sum, k):\n current_sum, parts = 0, 1\n for num in nums:\n if current...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042719", "row_id": 42719, "seed_ids": "[2299]" }
0.780112
Taco_42719
I
[ "can_split", "minimize_max_sum", "process_input" ]
3
[ [ "minimize_max_sum", "can_split" ], [ "process_input", "minimize_max_sum" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
3e86dc4d8b0698837233afb61623112c045ebafa
94fe703478ca01bbb2b46ee278d9ed3795e7ac83
v1.0
instruct
Taco
Taco_42724_I
Mia loves solving puzzles. One day she came across an interesting problem related to binary trees and permutations. She decided to challenge her friend Tom with the following problem: Tom needs to construct a binary tree from a given preorder traversal list of distinct integers. The tree should also satisfy the follow...
class TreeNode: def __init__(self, key=0, left=None, right=None): self.key = key self.left = left self.right = right def construct_bst_from_preorder(preorder): if not preorder: return None def build_bst(preorder, index, bound): if index[0] == len(preorder) or preord...
def test_construct_bst_from_preorder(): preorder = [8, 5, 1, 7, 10] expected_inorder = [1, 5, 7, 8, 10] n = len(preorder) assert inorder_from_preorder(n, preorder) == expected_inorder def test_single_element(): preorder = [5] expected_inorder = [5] n = len(preorder) assert inorder_from_...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, key=0, left=None, right=None):\n self.key = key\n self.left = left\n self.right = right\n\ndef constru...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00042724", "row_id": 42724, "seed_ids": "[18878]" }
0.573849
Taco_42724
I
[ "construct_bst_from_preorder", "inorder_traversal", "inorder_from_preorder" ]
3
[ [ "inorder_from_preorder", "construct_bst_from_preorder" ], [ "inorder_from_preorder", "inorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
4b4799d3a4cbafe5a1ef128181f0dd9815dd23b1
d345cb3685dc7d610437d35ffab57844039e9af6
v1.0
instruct
Taco
Taco_42725_I
Adam has a favorite number sequence where each number is the sum of the squares of the digits of the previous number. He starts with a given number and follows this sequence. Sometimes the sequence gets stuck in a cycle, repeating the same numbers indefinitely. Given a starting number, determine if the sequence will e...
def sum_of_squares_of_digits(n): return sum(int(digit) ** 2 for digit in str(n)) def detect_cycle(n): seen_numbers = set() while n not in seen_numbers: if n == 1: return "No Cycle" seen_numbers.add(n) n = sum_of_squares_of_digits(n) return "Cycle"
from solution import detect_cycle def test_no_cycle(): assert detect_cycle(19) == "No Cycle" def test_cycle(): assert detect_cycle(116) == "Cycle" assert detect_cycle(4) == "Cycle" def test_no_cycle_for_1(): assert detect_cycle(1) == "No Cycle" def test_large_number(): assert detect_cycle(123456...
[ { "docstring": null, "function_declaration": "def sum_of_squares_of_digits(n):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def detect_cycle(n):", "function_name": "detect_cycle", "parameter_list": "(n)" ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_squares_of_digits(n):\n return sum(int(digit) ** 2 for digit in str(n))\n\ndef detect_cycle(start):\n seen = set()\n while start != 1:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042725", "row_id": 42725, "seed_ids": "[8053]" }
0.553058
Taco_42725
I
[ "sum_of_squares_of_digits", "detect_cycle" ]
2
[ [ "detect_cycle", "sum_of_squares_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b611c2d2ef743498174a894c5c329a216281338
e3aadf9c7beb9a233b9ea5a274cb089f969d2168
v1.0
instruct
Taco
Taco_42730_I
Write a function that takes in a list of integers and returns a new list that contains only the prime numbers from the original list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. -----Constraints----- - The input list will have at most length 1000. - Each int...
def is_prime(n): """ Helper function to check if a given number n is prime. """ if n <= 1: return False if n == 2: return True # 2 is the only even prime number if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): i...
from solution import filter_primes def test_filter_primes_with_sample_input(): assert filter_primes([2, 3, 4, 5, 28, 29, 30]) == [2, 3, 5, 29] def test_filter_primes_with_no_primes(): assert filter_primes([4, 6, 8, 10, 12, 14]) == [] def test_filter_primes_with_all_primes(): assert filter_primes([2, 3, 5...
[ { "docstring": "Helper function to check if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list containing only the prime numbers from the original list.\n\nArgs:\nnumbers (list of int...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00042730", "row_id": 42730, "seed_ids": "[9014]" }
0.700434
Taco_42730
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
09467d52423be3df0b27a9181b12a115f6bce94d
a3f9ea6bf8b9b9f1d473dcb1790d536c8b006d79
v1.0
instruct
Taco
Taco_42810_I
Johnny loves playing with numbers. He recently learned about prime numbers and now he wants to explore how many prime numbers he can find in various ranges. A number is considered prime if it has no divisors other than 1 and itself. Given a list of ranges, Johnny wants to count the number of prime numbers within each...
def sieve_of_eratosthenes(n): """ Creates a list of boolean values, where True denotes that the index is a prime number. Uses the Sieve of Eratosthenes algorithm. """ sieve = [True] * (n + 1) sieve[0] = sieve[1] = False # 0 and 1 are not prime numbers p = 2 while (p * p <= n): i...
from solution import count_primes_in_ranges def test_simple_case(): assert count_primes_in_ranges(2, [(1, 10), (11, 20)]) == [4, 4] def test_single_element_prime(): assert count_primes_in_ranges(2, [(2, 2), (19, 19)]) == [1, 1] def test_single_element_non_prime(): assert count_primes_in_ranges(2, [(4, 4)...
[ { "docstring": "Creates a list of boolean values, where True denotes that the index is a prime number.\nUses the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Fo...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00042810", "row_id": 42810, "seed_ids": "[23978]" }
0.659747
Taco_42810
I
[ "sieve_of_eratosthenes", "count_primes_in_ranges" ]
2
[ [ "count_primes_in_ranges", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
804c168dc3e4ba6e13024d1b12469d34f14c2286
10559514f9c3eaae8dad7fa6ad994ccb8dd10015
v1.0
instruct
Taco
Taco_42828_I
Using the given array of positive integers, determine the length of the longest subarray in which the absolute difference between the maximum and minimum values is less than or equal to a given limit. Input format: - The first input line contains an integer `n` representing the number of elements in the array. - The s...
def longest_subarray_with_limit(arr, limit): """ Determines the length of the longest subarray in which the absolute difference between the maximum and minimum values is less than or equal to the given limit. """ from collections import deque max_deque, min_deque = deque(), deque() left = 0...
def test_longest_subarray_sample(): input_str = """7 8 2 4 7 10 6 5 5""" assert longest_subarray_with_limit_from_input(input_str) == 4 def test_longest_subarray_single_element(): input_str = """1 10 0""" assert longest_subarray_with_limit_from_input(input_str) == 1 def test_longest_subarray_all_elemen...
[ { "docstring": "Determines the length of the longest subarray in which the absolute difference between\nthe maximum and minimum values is less than or equal to the given limit.", "function_declaration": "def longest_subarray_with_limit(arr, limit):", "function_name": "longest_subarray_with_limit", "...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef longest_subarray_with_limit(arr, limit):\n max_deque = deque() # holds elements in decreasing order to track the max in th...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00042828", "row_id": 42828, "seed_ids": "[24961]" }
0.777034
Taco_42828
I
[ "longest_subarray_with_limit", "longest_subarray_with_limit_from_input" ]
2
[ [ "longest_subarray_with_limit_from_input", "longest_subarray_with_limit" ] ]
1
[]
false
[]
false
pytest
false
[]
true
65f673a60b7305e874afec1172b765f337271264
ac099232520f23f69929bf9cd8e3cfaa221c8fd3
v1.0
instruct
Taco
Taco_42863_I
A popular online game involves players forming a huge circle and engaging in a unique elimination process. Each player is assigned a number from 1 to N. Starting from player 1, every Kth player is removed from the circle, and the game continues from the next player after the removed one. This elimination process goes o...
def josephus(n, k): """ Given the number of players n and the step rate k, this function returns the position of the winning player. """ if n == 1: return 1 else: return (josephus(n - 1, k) + k - 1) % n + 1 def solve(test_cases): """ Given a list of test cases, this func...
def test_josephus(): assert josephus(5, 2) == 3 assert josephus(7, 3) == 4 assert josephus(10, 4) == 5 assert josephus(1, 1) == 1 assert josephus(2, 1) == 2 assert josephus(5, 1) == 5 def test_solve(): assert solve([(5, 2), (7, 3), (10, 4)]) == [3, 4, 5] assert solve([(1, 1), (2, 1)]) =...
[ { "docstring": "Given the number of players n and the step rate k,\nthis function returns the position of the winning player.", "function_declaration": "def josephus(n, k):", "function_name": "josephus", "parameter_list": "(n, k)" }, { "docstring": "Given a list of test cases, this function ...
[ 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 josephus(n, k):\n \"\"\"\n Solves the Josephus problem for n players and step rate k.\n \"\"\"\n if n == 1:\n return 1\n else:\n r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00042863", "row_id": 42863, "seed_ids": "[11911]" }
0.708642
Taco_42863
I
[ "josephus", "solve", "parse_input", "format_output" ]
4
[ [ "solve", "josephus" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
3f937c68540b22ed7c6056d9a7ac82d5649c2fe8
493287e7bb5a8eb997461e9d678e2d1cdeda6a6f
v1.0
instruct
Taco
Taco_42885_I
You are given a list of integers representing a collection of books and the number of pages in each book. Your task is to determine whether it is possible to allocate all books to M students such that each student gets at least one book and the maximum number of pages assigned to a student is minimized. ------- Input ...
def is_possible(books, n, m, curr_min): students_required = 1 curr_sum = 0 for i in range(n): if books[i] > curr_min: return False if curr_sum + books[i] > curr_min: students_required += 1 curr_sum = books[i] if students_required ...
from solution import distribute_books def test_distribute_books_case1(): test_cases = [ ((4, 2), [12, 34, 67, 90]) ] assert distribute_books(test_cases) == [113] def test_distribute_books_case2(): test_cases = [ ((5, 3), [10, 20, 30, 40, 50]) ] assert distribute_books(test_case...
[ { "docstring": null, "function_declaration": "def is_possible(books, n, m, curr_min):", "function_name": "is_possible", "parameter_list": "(books, n, m, curr_min)" }, { "docstring": null, "function_declaration": "def find_minimum_pages(books, n, m):", "function_name": "find_minimum_p...
[ 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 canAllocate(pages, n, m, max_pages):\n student_count = 1\n current_sum = 0\n \n for page in pages:\n if page > max_pages:\n retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00042885", "row_id": 42885, "seed_ids": "[1627]" }
0.775032
Taco_42885
I
[ "is_possible", "find_minimum_pages", "distribute_books" ]
3
[ [ "distribute_books", "find_minimum_pages" ], [ "find_minimum_pages", "is_possible" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fd17df230ee995981fb30f09996e168d065ed115
6ffc6c02295005a114429c757f73afe57d408de6
v1.0
instruct
Taco
Taco_42903_I
Write a function `prime_rearrangement()` (JS: `primeRearrangement`) that takes an integer array as input and returns a new array where all the prime numbers are at the beginning and the rest of the numbers follow in the same order they appeared in the original array. Maintain the order of the prime numbers as they were...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def prime_rearrangement(arr): ...
import pytest from solution import prime_rearrangement def test_prime_rearrangement(): assert prime_rearrangement([11, 4, 7, 10, 2, 9]) == [11, 7, 2, 4, 10, 9] assert prime_rearrangement([2, 3, 5, 7, 11, 13]) == [2, 3, 5, 7, 11, 13] assert prime_rearrangement([4, 6, 8, 9, 10, 15]) == [4, 6, 8, 9, 10, 15] ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def prime_rearrangement(arr):", "function_name": "prime_rearrangement", "parameter_list": "(arr)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00042903", "row_id": 42903, "seed_ids": "[10001]" }
0.551612
Taco_42903
I
[ "is_prime", "prime_rearrangement" ]
2
[ [ "prime_rearrangement", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfd8c2c30d6aa9be8f31a6329b0b1a85cce5f532
be1b1b2400bcd28daa712bd0131f0180c6f744f3
v1.0
instruct
Taco
Taco_42934_I
## Preface A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A prime number is only divisible by 1 and itself. ## The Problem Create a function `nearest_prime` that takes a positive integer `n` as an argument and returns the nearest prime number to `n...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def nearest_prime(n): if i...
from solution import nearest_prime def test_nearest_prime(): assert nearest_prime(10) == 11 assert nearest_prime(14) == 13 assert nearest_prime(21) == 19 assert nearest_prime(20) == 19 assert nearest_prime(1) == 2 assert nearest_prime(2) == 2 assert nearest_prime(3) == 3 assert nearest_...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def nearest_prime(n):", "function_name": "nearest_prime", "parameter_list": "(n)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00042934", "row_id": 42934, "seed_ids": "[4482]" }
0.64748
Taco_42934
I
[ "is_prime", "nearest_prime" ]
2
[ [ "nearest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7baca95d711cc94caaad2717c30a2e8eb650b35
e36d8c89c83dd421f19018819ef0c58b5667188b
v1.0
instruct
Taco
Taco_42956_I
Sam loves coding challenges and has currently taken an interest in number theory. One day, while reading about prime numbers, he stumbled upon an interesting property of prime numbers called "prime gaps". The gap between two successive prime numbers is defined as the difference between the latter prime and the former p...
def find_prime_gaps(N): def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return ...
from solution import find_prime_gaps, format_prime_gaps def test_find_prime_gaps_small_range(): assert find_prime_gaps(20) == [1, 2, 4] def test_find_prime_gaps_larger_range(): assert find_prime_gaps(50) == [1, 2, 4, 6] def test_find_prime_gaps_one_prime_gap(): assert find_prime_gaps(5) == [1] def test_...
[ { "docstring": null, "function_declaration": "def find_prime_gaps(N):", "function_name": "find_prime_gaps", "parameter_list": "(N)" }, { "docstring": null, "function_declaration": "def format_prime_gaps(N):", "function_name": "format_prime_gaps", "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 find_prime_gaps(N):\n def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00042956", "row_id": 42956, "seed_ids": "[9223]" }
0.646294
Taco_42956
I
[ "find_prime_gaps", "format_prime_gaps" ]
2
[ [ "format_prime_gaps", "find_prime_gaps" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d761b9ac3635e93e4d377dd9e2249b9901d64c5d
7a4a44d5ac1e5a0c9717fba8147476a7b341489c
v1.0
instruct
Taco
Taco_42963_I
Create a function that takes a list of strings and returns the length of the longest subsequence where each string is a subsequence of the next string. Examples: `longestSubsequenceLength(["a", "abc", "ab", "abcd", "b"])` returns 4 Explanation: "a" → "abc" → "abcd", "ab" → "abcd" form valid subsequences. `longestSu...
def is_subsequence(s1, s2): """ Checks if s1 is a subsequence of s2. """ it = iter(s2) return all(char in it for char in s1) def longestSubsequenceLength(strings): """ Returns the length of the longest subsequence where each string is a subsequence of the next string. """ n = len(st...
from solution import longestSubsequenceLength def test_example_1(): assert longestSubsequenceLength(["a", "abc", "ab", "abcd", "b"]) == 4 def test_example_2(): assert longestSubsequenceLength(["x", "xyz", "xy", "zxy", "a"]) == 3 def test_example_3(): assert longestSubsequenceLength(["car", "cat", "cart",...
[ { "docstring": "Checks if s1 is a subsequence of s2.", "function_declaration": "def is_subsequence(s1, s2):", "function_name": "is_subsequence", "parameter_list": "(s1, s2)" }, { "docstring": "Returns the length of the longest subsequence where each string is a subsequence of the next string...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(small, large):\n \"\"\"Helper function to check if small is a subsequence of large.\"\"\"\n it = iter(large)\n return all(char in it fo...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00042963", "row_id": 42963, "seed_ids": "[8658]" }
0.732672
Taco_42963
I
[ "is_subsequence", "longestSubsequenceLength" ]
2
[ [ "longestSubsequenceLength", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e6fe65094876e21609b723914be19a70508d1386
9beb1f29f5ca51ef3c1e6eafc0e0c4a47c2c4e98
v1.0
instruct
Taco
Taco_43002_I
Given an array arr[] of integers and a positive integer k. The task is to find the k-th smallest element in the array using Quickselect algorithm. Example 1: Input: arr[] = [7, 10, 4, 3, 20, 15] k = 3 Output: 7 Example 2: Input: arr[] = [7, 10, 4, 3, 20, 15] k = 4 Output: 10 Your Task: You only need to implement the...
import random def partition(arr, low, high): pivot_index = random.randint(low, high) arr[pivot_index], arr[high] = arr[high], arr[pivot_index] pivot = arr[high] i = low - 1 for j in range(low, high): if arr[j] <= pivot: i = i + 1 arr[i], arr[j] = arr[j], arr[i] a...
from solution import kthSmallest def test_kth_smallest_example1(): assert kthSmallest([7, 10, 4, 3, 20, 15], 3) == 7 def test_kth_smallest_example2(): assert kthSmallest([7, 10, 4, 3, 20, 15], 4) == 10 def test_kth_smallest_single_element(): assert kthSmallest([25], 1) == 25 def test_kth_smallest_sorted...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quickselect(arr, low, high, k):", "function_name": "quickselect", "parameter_list...
[ 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 partition(arr, low, high):\n pivot = arr[high]\n i = low - 1 # index of smaller element\n for j in range(low, high):\n if arr[j] <= pivot:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043002", "row_id": 43002, "seed_ids": "[20098]" }
0.562602
Taco_43002
I
[ "partition", "quickselect", "kthSmallest" ]
3
[ [ "kthSmallest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cdce31c2386ad2986867c87d538789091586053f
5615794f5f3dd06f77c5b895bde0a752d512a3d2
v1.0
instruct
Taco
Taco_43030_I
A robot is designed to navigate a grid-based warehouse, starting at the top-left corner (position (1,1)) and needs to reach the bottom-right corner (position (n,m)). The robot can move in four possible directions: up, down, left, and right. However, some cells in the grid are marked as obstacles that the robot cannot e...
def can_reach_goal(n, m, grid): from collections import deque start = (0, 0) goal = (n-1, m-1) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] if grid[0][0] == '#' or grid[n-1][m-1] == '#': return "NO" queue = deque([start]) visited = set([start]) while queue:...
from solution import can_robot_navigate def test_example_1(): input_data = '''4 4 . . . # . # . . . # # . . . . .''' assert can_robot_navigate(input_data) == "YES" def test_example_2(): input_data = '''4 4 . # # # # # # . # # # # . . . #''' assert can_robot_navigate(input_data) == "NO" def test_singl...
[ { "docstring": null, "function_declaration": "def can_reach_goal(n, m, grid):", "function_name": "can_reach_goal", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def can_robot_navigate(input_data):", "function_name": "can_robot_navigate", "param...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_path_exist(n, m, grid):\n def dfs(x, y):\n if x < 0 or x >= n or y < 0 or y >= m or grid[x][y] == '#' or visited[x][y]:\n return False\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00043030", "row_id": 43030, "seed_ids": "[9045]" }
0.692624
Taco_43030
I
[ "can_reach_goal", "can_robot_navigate" ]
2
[ [ "can_robot_navigate", "can_reach_goal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
831eeaa113e3e2426ce3d916f12e68b5841f8faa
035f9ece54bf58be4bbc49203087c0bf76f4d439
v1.0
instruct
Taco
Taco_43067_I
You are given an array of integers, and you must check if there exists a subsequence such that the subsequence is a permutation of a palindrome. A palindrome is a string that reads the same forward and backward, and a permutation of a palindrome is a re-arrangement of letters to form a palindrome. For example, the stri...
def is_permutation_of_palindrome(arr): """ Checks if any subsequence of the array can be rearranged to form a palindrome. """ from collections import Counter # Count frequencies of each number freq = Counter(arr) # Count how many numbers have an odd frequency odd_count = sum(1 ...
import pytest from solution import solve def test_solve(): input_data = """2 3 1 2 2 4 1 2 2 3""" expected_output = "YES\nNO" assert solve(input_data) == expected_output def test_solve_single_element(): input_data = """1 1 1""" expected_output = "YES" assert solve(input_data) == expected_outpu...
[ { "docstring": "Checks if any subsequence of the array can be rearranged to form a palindrome.", "function_declaration": "def is_permutation_of_palindrome(arr):", "function_name": "is_permutation_of_palindrome", "parameter_list": "(arr)" }, { "docstring": "Takes in a list of test cases and r...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome_permutation_possible(arr):\n from collections import Counter\n \n count = Counter(arr)\n odd_count = sum(1 for value in count.values(...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00043067", "row_id": 43067, "seed_ids": "[13250]" }
0.769991
Taco_43067
I
[ "is_permutation_of_palindrome", "check_permutation_of_palindrome", "solve" ]
3
[ [ "check_permutation_of_palindrome", "is_permutation_of_palindrome" ], [ "solve", "check_permutation_of_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f4678cc363bd2093a0b32cc3ef79a5276c842d32
67589a05fb28b083193c8d17c9e00b82f1439f24
v1.0
instruct
Taco
Taco_43097_I
Let's consider a two-dimensional grid consisting of uppercase English letters. We say that a contiguous subgrid is a "palindromic subgrid" if the sequence of letters it contains reads the same forwards and backwards in both its rows and columns. Your task is to determine the size of the largest palindromic subgrid in ...
def is_palindromic_subgrid(grid, i1, j1, i2, j2): for i in range(i1, i2 + 1): if grid[i][j1:j2 + 1] != grid[i][j1:j2 + 1][::-1]: return False for j in range(j1, j2 + 1): col = ''.join(grid[i][j] for i in range(i1, i2 + 1)) if col != col[::-1]: return False ret...
import pytest from solution import find_largest_palindromic_subgrid def test_example_1(): n = 3 m = 3 grid = [ "ABA", "BAB", "ABA" ] assert find_largest_palindromic_subgrid(n, m, grid) == 3 def test_example_2(): n = 4 m = 4 grid = [ "AAAA", "ABBA...
[ { "docstring": null, "function_declaration": "def is_palindromic_subgrid(grid, i1, j1, i2, j2):", "function_name": "is_palindromic_subgrid", "parameter_list": "(grid, i1, j1, i2, j2)" }, { "docstring": null, "function_declaration": "def largest_palindromic_subgrid(n, m, grid):", "fun...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindromic_subgrid(grid, i1, j1, i2, j2):\n for i in range(i1, i2 + 1):\n if grid[i][j1:j2 + 1] != grid[i][j1:j2 + 1][::-1]:\n return ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00043097", "row_id": 43097, "seed_ids": "[19835]" }
0.725813
Taco_43097
I
[ "is_palindromic_subgrid", "largest_palindromic_subgrid", "find_largest_palindromic_subgrid" ]
3
[ [ "find_largest_palindromic_subgrid", "largest_palindromic_subgrid" ], [ "largest_palindromic_subgrid", "is_palindromic_subgrid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6182a438a12f20e154496d4ca9f0340d64425548
a1996bcac34ff1086f3cf0c4dd8220f57a0b071f
v1.0
instruct
Taco
Taco_43201_I
Given a binary tree, write a function to check whether it is a mirror of itself (i.e., symmetric around its center). Input: First line of input contains number of testcases T. For each testcase, there will be two lines of input. First line contains the number of nodes N in the binary tree, and the second line contains...
class TreeNode: def __init__(self, val=0): self.val = val self.left = None self.right = None def is_symmetric_tree(root): if not root: return True def is_mirror(t1, t2): if not t1 and not t2: return True if not t1 or not t2: return Fa...
import pytest from solution import isSymmetric def test_is_symmetric(): # First Test Case N1 = 7 values1 = [1, 2, 2, 3, 4, 4, 3] assert isSymmetric(N1, values1) == "Yes" # Second Test Case N2 = 5 values2 = [1, 2, 2, -1, 3, -1, 3] assert isSymmetric(N2, values2) == "No" # T...
[]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef isSymme...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043201", "row_id": 43201, "seed_ids": "[7855]" }
0.665461
Taco_43201
I
[ "is_symmetric_tree", "construct_tree_from_level_order", "isSymmetric" ]
3
[ [ "isSymmetric", "construct_tree_from_level_order" ], [ "isSymmetric", "is_symmetric_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
29955c6bc3ce3670e8abc746fee0d29c7a48f5ec
c5c631ffcbe00a01427df044f87e02daa9ede262
v1.0
instruct
Taco
Taco_43234_I
Farmer John has a rectangular farm divided into a grid of size n x m. Each cell of the grid represents a piece of the land that can either be fertile or barren. Farmer John wants to find all the rectangular sub-grids that consist solely of fertile land, and among them, identify the one with the largest area. Given a g...
def max_histogram_area(histogram): stack = [] max_area = 0 index = 0 while index < len(histogram): if not stack or histogram[stack[-1]] <= histogram[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (histog...
from solution import largest_fertile_rectangle def test_sample_input(): n = 4 m = 5 grid = [ "10100", "10111", "11111", "10010" ] assert largest_fertile_rectangle(n, m, grid) == 6 def test_all_fertile(): n = 3 m = 3 grid = [ "111", "111",...
[ { "docstring": null, "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def max_rectangle(matrix):", "function_name": "max_rectangle", "parameter_lis...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_histogram_area(histogram):\n stack = []\n max_area = 0\n index = 0\n \n while index < len(histogram):\n if not stack or histogram[sta...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00043234", "row_id": 43234, "seed_ids": "[21749]" }
0.641946
Taco_43234
I
[ "max_histogram_area", "max_rectangle", "largest_fertile_rectangle" ]
3
[ [ "largest_fertile_rectangle", "max_rectangle" ], [ "max_rectangle", "max_histogram_area" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2d81d091270a2278fa9394c5c668c1ccd2f7f0c5
80d31b1e2ecc30566f091c2acbe67fb9d2f4bb82
v1.0
instruct
Taco
Taco_43254_I
problem A group of friends likes to play a card game every weekend. The game is played with a standard deck of 52 cards. They have recently decided to adopt a new scoring method to make the game more interesting. Each card has a point value associated with it: - Cards 2 through 10 score points equal to their face val...
def score_hand(cards): """ Calculate the total score for a hand of cards. :param cards: List of cards as strings. :return: Total score as an integer. """ card_values = { '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 10, 'Q': 10, 'K': 10, 'A': 11 ...
from solution import score_hand, score_players_hands def test_score_hand(): assert score_hand(['10', 'J', 'Q', '9', 'A']) == 50 assert score_hand(['9', '8', '3', '2', 'K']) == 32 assert score_hand(['A', 'A', 'A', '5', '5']) == 43 assert score_hand(['2', '3', '4', '5', '6']) == 20 assert score_hand(...
[ { "docstring": "Calculate the total score for a hand of cards.\n\n:param cards: List of cards as strings.\n:return: Total score as an integer.", "function_declaration": "def score_hand(cards):", "function_name": "score_hand", "parameter_list": "(cards)" }, { "docstring": "Compute the total s...
[ 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 card_value(card):\n \"\"\"\n Returns the point value of a given card.\n \"\"\"\n if card in {'J', 'Q', 'K'}:\n return 10\n elif card == '...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043254", "row_id": 43254, "seed_ids": "[6105]" }
0.648218
Taco_43254
I
[ "score_hand", "score_players_hands" ]
2
[ [ "score_players_hands", "score_hand" ] ]
1
[]
false
[]
false
pytest
true
[]
true
25c244a6e4d04b5d6521c471537db1aee33e3562
4983848598373009a939c6c0993424afb6a8f684
v1.0
instruct
Taco
Taco_43458_I
Given a binary tree, determine if it is height-balanced. A height-balanced binary tree is defined as a tree in which the depth of the two subtrees of every node never differs by more than 1. Input Format The first line contains an integer $n$, the number of nodes in the binary tree. If $n$ is not 0, the next line con...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert_nodes(nodes, edges): if not nodes: return None node_dict = {val: TreeNode(val) for val in nodes} for parent_val, child_val in edges: parent = node_dict[parent_val] ...
from solution import is_tree_balanced def test_example_0(): assert is_tree_balanced(7, [1, 2, 3, 4, 5, 6, 7], [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)]) == "YES" def test_example_1(): assert is_tree_balanced(5, [1, 2, 3, 4, 5], [(1, 2), (1, 3), (2, 4), (4, 5)]) == "NO" def test_empty_tree(): asser...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef insert_nodes(nodes, edges):\n if n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00043458", "row_id": 43458, "seed_ids": "[11440]" }
0.739448
Taco_43458
I
[ "insert_nodes", "is_balanced", "is_tree_balanced" ]
3
[ [ "is_tree_balanced", "insert_nodes" ], [ "is_tree_balanced", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
13a263994bca9bc02f2f9c7008958f2fd5e98713
3ff52574a612d4d330f23436cfe47102648747f8
v1.0
instruct
Taco
Taco_43522_I
Given a city grid represented as an NxM matrix, each cell in the grid can either be '1' representing a building or '0' representing an empty space. The mayor wants to build the largest possible park in the city. A park can only be built on empty spaces (cells with '0') and must be rectangular in shape, and it should no...
def max_histogram_area(heights): stack = [] max_area = 0 index = 0 while index < len(heights): if not stack or heights[stack[-1]] <= heights[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (heights[top_of...
import pytest from solution import largest_rectangle def test_example_case(): grid = [ ['1', '0', '1', '0'], ['1', '0', '0', '1'], ['1', '1', '1', '0'], ['0', '0', '0', '0'] ] assert largest_rectangle(grid) == 4 def test_all_buildings(): grid = [ ['1', '1'], ...
[ { "docstring": null, "function_declaration": "def max_histogram_area(heights):", "function_name": "max_histogram_area", "parameter_list": "(heights)" }, { "docstring": null, "function_declaration": "def largest_rectangle(grid):", "function_name": "largest_rectangle", "parameter_l...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_histogram_area(heights):\n stack = []\n max_area = 0\n index = 0\n \n while index < len(heights):\n if not stack or heights[stack[-1]...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00043522", "row_id": 43522, "seed_ids": "[22209]" }
0.588805
Taco_43522
I
[ "max_histogram_area", "largest_rectangle" ]
2
[ [ "largest_rectangle", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7786d4eb5579b6b9b7cc90b4014d5074e5e2064b
8d8db089c1a33cd36b6b9a7934eb864e5d3b28e2
v1.0
instruct
Taco
Taco_43598_I
Write a program that processes a sequence of positive integers and determines for each, whether they are a prime number, a composite number, or neither. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. A composite number is a number greater than 1 that is not a prime numb...
def is_prime(n): """ Determine if a number is a prime. :param n: An integer number to check. :return: True if n is a prime number, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in rang...
from solution import is_prime, classify_number, process_numbers def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-3) == False assert is_prime(17) == True assert ...
[ { "docstring": "Determine if a number is a prime.\n\n:param n: An integer number to check.\n:return: True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Classify a number as prime,...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determine if a number is a prime.\n \n :param n: An integer number to check.\n :return: True if n is a prime number, Fal...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00043598", "row_id": 43598, "seed_ids": "[2657]" }
0.669652
Taco_43598
I
[ "is_prime", "classify_number", "process_numbers" ]
3
[ [ "classify_number", "is_prime" ], [ "process_numbers", "classify_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a5413f0502952fcfcb9c66df9d963431eb0f705a
41b2ed95cea565f3eb6603e5545c1f4265db02f8
v1.0
instruct
Taco
Taco_43617_I
A certain university has recently transitioned to a new grading system. For each student, based on their scores in 5 subjects, grades are determined. The grades comply with the following rules: - A student’s final grade is computed based on the average of the 5 scores. - If the average score is greater than or equal t...
def calculate_grade(scores): """ Returns the final grade based on the average of five scores """ average = sum(scores) / 5 if average >= 90: return 'A' elif average >= 80: return 'B' elif average >= 70: return 'C' elif average >= 60: return 'D' else: ...
from solution import calculate_grade, determine_grades def test_calculate_grade_A(): assert calculate_grade([95, 96, 97, 94, 98]) == 'A' def test_calculate_grade_B(): assert calculate_grade([85, 90, 78, 92, 88]) == 'B' def test_calculate_grade_C(): assert calculate_grade([75, 70, 65, 80, 75]) == 'C' def...
[ { "docstring": "Returns the final grade based on the average of five scores", "function_declaration": "def calculate_grade(scores):", "function_name": "calculate_grade", "parameter_list": "(scores)" }, { "docstring": "Takes a list of student scores and returns a list of their final grades", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_grade(scores):\n \"\"\"\n Returns the final grade based on the average of five scores\n \"\"\"\n average = sum(scores) / 5\n if averag...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00043617", "row_id": 43617, "seed_ids": "[13448]" }
0.736191
Taco_43617
I
[ "calculate_grade", "determine_grades" ]
2
[ [ "determine_grades", "calculate_grade" ] ]
1
[]
false
[]
false
pytest
true
[]
true
814df23ece8277d74fcde5053faa0bbf194f6be2
4513e6c35b419e7d8a7c38bfd93c18628e981e33
v1.0
instruct
Taco
Taco_43628_I
A magic square is a grid of distinct positive integers arranged in a square such that the sum of the numbers in each row, each column, and both main diagonals are all the same. You are given an n x n grid where some cells may already contain numbers. Complete the grid to form a magic square if possible. You need to de...
import itertools def is_magic(square): n = len(square) target_sum = sum(square[0]) # Check rows for row in square: if sum(row) != target_sum: return False # Check columns for col in range(n): if sum(square[row][col] for row in range(n)) != target_sum: ...
import pytest from solution import is_magic, complete_magic_square def test_is_magic(): assert is_magic([ [2, 7, 6], [9, 5, 1], [4, 3, 8] ]) == True assert is_magic([ [8, 1, 6], [3, 5, 7], [4, 9, 2] ]) == True assert is_magic([ [3, 7...
[ { "docstring": null, "function_declaration": "def is_magic(square):", "function_name": "is_magic", "parameter_list": "(square)" }, { "docstring": null, "function_declaration": "def complete_magic_square(n, grid):", "function_name": "complete_magic_square", "parameter_list": "(n, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_magic_square(grid, n):\n target_sum = n * (n * n + 1) // 2\n\n # Check rows\n for row in grid:\n if sum(row) != target_sum:\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043628", "row_id": 43628, "seed_ids": "[10209]" }
0.722563
Taco_43628
I
[ "is_magic", "complete_magic_square", "solve" ]
3
[ [ "complete_magic_square", "is_magic" ], [ "solve", "complete_magic_square" ] ]
2
[]
false
[]
false
pytest
true
[]
true
db0942c256b407fc84c860beeb032c91ead4d453
28f7aa796a2c31ddd05a09cd54185fa46d696899
v1.0
instruct
Taco
Taco_43733_I
Write a function that checks if it is possible to find a permutation of the given sequence of integers such that the sum of any two consecutive numbers is a perfect square. Input The first line of the input consists of a single integer $ N $, the length of the sequence. The second line contains $ N $ integers $ A_1, ...
from itertools import permutations import math def is_perfect_square(n): """ Helper function to check if a number is a perfect square. """ root = int(math.sqrt(n)) return root * root == n def can_form_perfect_square_sum_sequence(N, sequence): """ Check if there exists a permutation of the ...
from solution import perfect_square_sum_sequence def test_case_1(): assert perfect_square_sum_sequence(3, [1, 17, 8]) == "YES" def test_case_2(): assert perfect_square_sum_sequence(4, [1, 14, 2, 3]) == "NO" def test_case_3(): assert perfect_square_sum_sequence(1, [16]) == "YES" def test_case_4(): as...
[ { "docstring": "Helper function to check if a number is a perfect square.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Check if there exists a permutation of the sequence such that the sum of \nany two...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(x):\n return int(math.isqrt(x)) ** 2 == x\n\ndef can_form_perfect_square_permutation(nums):\n def dfs(path):\n if...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043733", "row_id": 43733, "seed_ids": "[24674]" }
0.633958
Taco_43733
I
[ "is_perfect_square", "can_form_perfect_square_sum_sequence", "perfect_square_sum_sequence" ]
3
[ [ "can_form_perfect_square_sum_sequence", "is_perfect_square" ], [ "perfect_square_sum_sequence", "can_form_perfect_square_sum_sequence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
92981c21d4c6e568bd4a02d594e369b12d39269b
ed1fce7f7d7ef8691ab1c577ec12da4a7f80a0e3
v1.0
instruct
Taco
Taco_43738_I
A large amusement park is planning to develop a new attraction with interconnected zones. Each zone is connected to at least one other zone. However, due to safety regulations, the park needs to ensure that there is exactly one evacuation route (or path) between any two zones, which means that the zones should form a t...
def find_parent(parent, i): if parent[i] == -1: return i return find_parent(parent, parent[i]) def union(parent, x, y): xroot = find_parent(parent, x) yroot = find_parent(parent, y) if xroot != yroot: parent[xroot] = yroot def is_valid_tree(n, m, edges): # A tree should have n-...
from solution import is_valid_tree def test_valid_tree(): assert is_valid_tree(4, 3, [(1, 2), (2, 3), (3, 4)]) == "YES" def test_cycle_present(): assert is_valid_tree(4, 3, [(1, 2), (2, 3), (3, 1)]) == "NO" def test_main_root_valid_tree(): assert is_valid_tree(5, 4, [(1, 2), (1, 3), (1, 4), (4, 5)]) == "...
[ { "docstring": null, "function_declaration": "def find_parent(parent, i):", "function_name": "find_parent", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_tree(n, m, edges):\n \"\"\"\n Determines if the given connections form a valid tree.\n \"\"\"\n if m != n - 1:\n return \"NO\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043738", "row_id": 43738, "seed_ids": "[17866]" }
0.644603
Taco_43738
I
[ "find_parent", "union", "is_valid_tree" ]
3
[ [ "is_valid_tree", "find_parent" ], [ "is_valid_tree", "union" ], [ "union", "find_parent" ] ]
3
[]
false
[]
false
pytest
true
[]
true
edfc605659d9f51526ff0020984fa514408c6885
4ac0eec25b63b3eeb31567f86f2ff6bf995eb760
v1.0
instruct
Taco
Taco_43741_I
In a distant galaxy, there is a planet named Zog where the inhabitants speak a language consisting of binary strings. A binary string is considered "balanced" if the number of '0's equals the number of '1's, and no prefix of the string has more '1's than '0's. For example, the strings "0101" and "0011" are balanced, wh...
MOD = 10**9 + 7 def mod_inv(a, m): return pow(a, m-2, m) def catalan_number(n, mod): if n == 0: return 1 fact = [1] * (2 * n + 1) for i in range(2, 2 * n + 1): fact[i] = fact[i - 1] * i % mod return (fact[2 * n] * mod_inv(fact[n + 1], mod) % mod * mod_inv(fact[n], mod) % mod) ...
def test_balanced_binary_strings(): assert balanced_binary_strings(1) == 1 assert balanced_binary_strings(2) == 2 assert balanced_binary_strings(3) == 5 assert balanced_binary_strings(4) == 14 assert balanced_binary_strings(5) == 42 def test_balanced_binary_strings_large(): assert balanced_bina...
[ { "docstring": null, "function_declaration": "def mod_inv(a, m):", "function_name": "mod_inv", "parameter_list": "(a, m)" }, { "docstring": null, "function_declaration": "def catalan_number(n, mod):", "function_name": "catalan_number", "parameter_list": "(n, mod)" }, { "d...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 10**9 + 7\n\ndef mod_inv(a, m):\n return pow(a, m-2, m)\n\ndef catalan_number(n, mod):\n if n == 0:\n return 1\n fact = [1] * (2 * n + 1)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00043741", "row_id": 43741, "seed_ids": "[4472]" }
0.68225
Taco_43741
I
[ "mod_inv", "catalan_number", "balanced_binary_strings" ]
3
[ [ "balanced_binary_strings", "catalan_number" ], [ "catalan_number", "mod_inv" ] ]
2
[]
false
[]
false
pytest
false
[]
true
c044ade03f17ab39056521b237e5da025ea8e0ee
dcfb8e2402cc1cf164570e3d7463639dc22de986
v1.0
instruct
Taco
Taco_43797_I
You are given N elements in an array A, where each element represents a soldier's strength. There are M commands that you need to execute. Each command is one of two types: 1. `1 X Y`: Update the value of the soldier at position X to Y. 2. `2 L R`: Compute the total number of soldiers with prime number strength in the...
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 execute_commands(n, m, soldie...
from solution import main def test_example_case(): input_str = """6 5 6 10 3 5 7 15 2 1 6 1 4 11 2 3 5 2 1 3 2 2 4""" expected_output = [3, 3, 1, 2] assert main(input_str) == expected_output def test_single_prime(): input_str = """3 2 1 3 1 2 1 3 2 2 2""" expected_output = [1, 1] ass...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def execute_commands(n, m, soldiers, commands):", "function_name": "execute_commands", "parameter_list": "(n, m, ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00043797", "row_id": 43797, "seed_ids": "[24206]" }
0.65699
Taco_43797
I
[ "is_prime", "execute_commands", "process_input", "main" ]
4
[ [ "execute_commands", "is_prime" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
39f243c90be0115075c664f00f6eb8b2d18f17fe
2ddbaac932cff3795b76a322566efa9179e239a0
v1.0
instruct
Taco
Taco_43803_I
In an ancient civilization, a system of water canals was used to transport water from a central reservoir to various farms. The farms are scattered and connected by a series of interconnected canals forming a network. Each canal segment has a flow capacity and there may be multiple routes to direct water from the reser...
from collections import defaultdict, deque def bfs_capacity(graph, source, sink, parent): """ Breadth-First Search to find if there is a path from source to sink in residual graph. If there is a path, return True and fills parent to store the path. """ visited = [False] * len(graph) queue = deq...
from solution import max_water_delivery def test_max_water_delivery_example_1(): assert max_water_delivery(4, 5, [(1, 2, 40), (1, 3, 20), (2, 3, 10), (2, 4, 30), (3, 4, 20)], 4) == 50 def test_max_water_delivery_example_2(): assert max_water_delivery(3, 3, [(1, 2, 100), (1, 3, 50), (2, 3, 50)], 3) == 100 def...
[ { "docstring": "Breadth-First Search to find if there is a path from source to sink in residual graph.\nIf there is a path, return True and fills parent to store the path.", "function_declaration": "def bfs_capacity(graph, source, sink, parent):", "function_name": "bfs_capacity", "parameter_list": "...
[ 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 bfs(residual_graph, source, sink, parent):\n visited = [False] * len(residual_graph)\n queue = [source]\n visited[source] = True\n \n while queu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043803", "row_id": 43803, "seed_ids": "[24748]" }
0.662325
Taco_43803
I
[ "bfs_capacity", "edmonds_karp_max_flow", "max_water_delivery" ]
3
[ [ "edmonds_karp_max_flow", "bfs_capacity" ], [ "max_water_delivery", "edmonds_karp_max_flow" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dfbf139061e615c81ab8b96c9009d3d90c7a4162
77a8a6707fa930042f044ad93c4bfc8ac703ee3b
v1.0
instruct
Taco
Taco_43818_I
You are given a rectangular grid of N x M cells. Each cell of the grid contains either a '0' (an empty cell) or a '1' (a wall). The grid has exactly one entrance at the top-left corner (cell (1,1)) and exactly one exit at the bottom-right corner (cell (N, M)). You are allowed to move up, down, left, or right from one c...
from collections import deque def min_steps_to_exit(grid): """ Determine the minimum number of steps required to move from the entrance to the exit. """ N = len(grid) M = len(grid[0]) # Check if the entrance or exit is a wall if grid[0][0] == '1' or grid[N-1][M-1] == '1': retur...
from solution import solve def test_solve_example_1(): N = 3 M = 3 grid = [ '000', '010', '000' ] assert solve(N, M, grid) == 4 def test_solve_example_2(): N = 3 M = 3 grid = [ '010', '111', '000' ] assert solve(N, M, grid) == -1 ...
[ { "docstring": "Determine the minimum number of steps required to move from the entrance to the exit.", "function_declaration": "def min_steps_to_exit(grid):", "function_name": "min_steps_to_exit", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve(N, M...
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_steps_to_exit(grid):\n N = len(grid)\n M = len(grid[0])\n \n if grid[0][0] == '1' or grid[N-1][M-1] == '1':\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00043818", "row_id": 43818, "seed_ids": "[18060]" }
0.731066
Taco_43818
I
[ "min_steps_to_exit", "solve" ]
2
[ [ "solve", "min_steps_to_exit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
66f7864141013995eee3bbfb27ffbab43fe16d08
46a0a495fac18f03a5193061385d65b3d32db1a7
v1.0
instruct
Taco
Taco_43895_I
A group of friends are planning a treasure hunt and need your help to determine the optimal way to hide their treasure using locations in the forest. Here’s how the game works: They have a map of the forest divided into a grid of cells. Each cell is identified by a pair of coordinates (x, y) where 1 ≤ x, y ≤ N (N ≤ 50...
def is_adjacent(x1, y1, x2, y2): """ Checks if two coordinates are adjacent. """ return abs(x1 - x2) <= 1 and abs(y1 - y2) <= 1 def max_non_adjacent_treasures(N, locations): """ Returns the maximum number of non-adjacent treasures that can be hidden. """ from itertools import combinatio...
def test_is_adjacent(): assert is_adjacent(1, 1, 1, 2) == True assert is_adjacent(1, 1, 2, 1) == True assert is_adjacent(1, 1, 2, 2) == True assert is_adjacent(1, 1, 3, 3) == False assert is_adjacent(1, 1, 1, 1) == True def test_max_non_adjacent_treasures(): assert max_non_adjacent_treasures(4,...
[ { "docstring": "Checks if two coordinates are adjacent.", "function_declaration": "def is_adjacent(x1, y1, x2, y2):", "function_name": "is_adjacent", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": "Returns the maximum number of non-adjacent treasures that can be hidden.", "functi...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_adjacent(x1, y1, x2, y2):\n \"\"\"\n Checks if two coordinates (x1, y1) and (x2, y2) are adjacent horizontally,\n vertical...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043895", "row_id": 43895, "seed_ids": "[19178]" }
0.657987
Taco_43895
I
[ "is_adjacent", "max_non_adjacent_treasures", "solve_treasure_hunt" ]
3
[ [ "max_non_adjacent_treasures", "is_adjacent" ], [ "solve_treasure_hunt", "max_non_adjacent_treasures" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0cf098f1e48216466b3550a21187ca7bec313b02
92419d2d3cf02d7f593b6333d430c909f0f8e3c1
v1.0
instruct
Taco
Taco_43908_I
The city of Gridland is designed in a grid format with dimensions NxN. Mayor Patel wants to plant trees in Gridland such that no two trees fall in the same row or the same column. To achieve this, he has decided to plant exactly one tree in each row and each column. One day, he notices that some plots in the grid are a...
def plant_trees(grid): """ This function takes an NxN grid and determines if it is possible to plant one tree ('T') in each row and each column without placing a tree on an occupied plot ('X'). """ def find_place(row, col_occupied, grid, N): if row == N: return True for c...
def test_plant_trees_possible(): grid_values = [ "0 0 X".split(), "X 0 0".split(), "0 X 0".split() ] assert solve(3, grid_values) == [ 'T 0 X', 'X T 0', '0 X T' ] def test_plant_trees_not_possible(): grid_values = [ "X X 0".split(), "0...
[ { "docstring": "This function takes an NxN grid and determines if it is possible to plant one tree ('T') in each row and each column\nwithout placing a tree on an occupied plot ('X').", "function_declaration": "def plant_trees(grid):", "function_name": "plant_trees", "parameter_list": "(grid)" }, ...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def plant_trees(n, grid):\n def is_valid(row, col, solution):\n for r in range(row):\n if solution[r][col] == 'T':\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00043908", "row_id": 43908, "seed_ids": "[21481]" }
0.718239
Taco_43908
I
[ "plant_trees", "solve" ]
2
[ [ "solve", "plant_trees" ] ]
1
[]
false
[]
false
pytest
false
[]
true
75677b1c180a5096de4f9694e7d28c3acc59b446
8713cc93ef3165a424c587c7a841710827a191d6
v1.0
instruct
Taco
Taco_43922_I
Three friends, John, Wendy, and Chris, are playing a number guessing game. John says he will think of three different numbers, all greater than or equal to 1. He announces to Wendy what the sum of these three numbers is, and to Chris what the product of these three numbers is. However, John only whispers this informati...
from itertools import combinations def find_sum_triplets(total_sum): triplets = [] for x in range(1, total_sum - 1): for y in range(x + 1, total_sum - x): z = total_sum - x - y if z > y: triplets.append((x, y, z)) return triplets def find_product_triplets(to...
from solution import statement1, statement2, statement3, statement4, find_numbers def test_statement1(): # In the case of sum 6, we have possible sets of (1, 2, 3) assert statement1(6) == False # In the case of sum 10, we have possible sets of (1, 3, 6) and (2, 3, 5) assert statement1(10) == True def ...
[ { "docstring": null, "function_declaration": "def find_sum_triplets(total_sum):", "function_name": "find_sum_triplets", "parameter_list": "(total_sum)" }, { "docstring": null, "function_declaration": "def find_product_triplets(total_product):", "function_name": "find_product_triplets...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def statement1(s):\n \"\"\"\n Wendy cannot determine the three numbers given the sum.\n There should be multiple sets of (a, b, c) that add up to s.\n ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00043922", "row_id": 43922, "seed_ids": "[14409]" }
0.554755
Taco_43922
I
[ "find_sum_triplets", "find_product_triplets", "statement1", "statement2", "statement3", "statement4", "find_numbers" ]
7
[ [ "find_numbers", "find_sum_triplets" ], [ "statement1", "find_sum_triplets" ], [ "statement2", "find_product_triplets" ], [ "statement3", "find_sum_triplets" ], [ "statement3", "statement2" ], [ "statement4", "find_product_triplets" ], [ "...
7
[]
false
[]
false
pytest
true
[]
true
fd2152b7c172c30fcdb450348c3ccff8f4e813af
2c56f4a6304fe851d1d47ba752fdebec6e70acab
v1.0
instruct
Taco
Taco_43926_I
A palindrome is a sequence that reads the same backward as forward. Given an integer `N`, your task is to find the smallest palindrome that is greater than `N`. Input: The first line contains the number of test cases. Each test case is a single integer `N`. Output: Print the smallest palindrome greater than `N` for ...
def is_palindrome(num): """ Checks if a number is a palindrome. """ return str(num) == str(num)[::-1] def next_palindrome(N): """ Finds the smallest palindrome greater than N. """ N += 1 # Start checking from the next number while not is_palindrome(N): N += 1 return N ...
from solution import is_palindrome, next_palindrome, find_next_palindromes def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1221) == True assert is_palindrome(12321) == True assert is_palindrome(12331) == False def test_next_palind...
[ { "docstring": "Checks if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Finds the smallest palindrome greater than N.", "function_declaration": "def next_palindrome(N):", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"Helper function to check if a number is a palindrome.\"\"\"\n return str(n) == str(n)[::-1]\n\ndef next_palindrome(n):\n \"\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00043926", "row_id": 43926, "seed_ids": "[13443]" }
0.854137
Taco_43926
I
[ "is_palindrome", "next_palindrome", "find_next_palindromes" ]
3
[ [ "find_next_palindromes", "next_palindrome" ], [ "next_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
92acc522abd549f009683e97bcd0ae7ed5216453
a346675ba862ea246e20cb90aebdb031ba4b24ab
v1.0
instruct
Taco
Taco_43952_I
You are asked to create a program that can generate all unique permutations of a given word's characters and then filter out only those permutations that are palindromes. A palindrome is a word that reads the same backward as forward. The result should display the total number of unique palindrome permutations possible...
from itertools import permutations def is_palindrome(s): """ Check if the given string s is a palindrome. """ return s == s[::-1] def unique_palindrome_permutations(word): """ Generate all unique permutations of the given word and count how many of them are palindromes. """ permut_set ...
from solution import is_palindrome, unique_palindrome_permutations, count_palindrome_permutations def test_is_palindrome(): assert is_palindrome("aba") assert is_palindrome("racecar") assert not is_palindrome("abc") assert is_palindrome("a") assert is_palindrome("") def test_unique_palindrome_perm...
[ { "docstring": "Check if the given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Generate all unique permutations of the given word and count how many of them are palindromes.", "f...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef is_palindrome(word):\n return word == word[::-1]\n\ndef unique_palindromic_permutations(word):\n unique_permutation...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043952", "row_id": 43952, "seed_ids": "[11545]" }
0.807378
Taco_43952
I
[ "is_palindrome", "unique_palindrome_permutations", "count_palindrome_permutations" ]
3
[ [ "count_palindrome_permutations", "unique_palindrome_permutations" ], [ "unique_palindrome_permutations", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cc55c7681261c90cedc1641ab669fdbba01ad9d2
189e2ec2554e9f2f7edbe8638feec4a5fae64b60
v1.0
instruct
Taco
Taco_43973_I
You are given a binary tree where each node contains a digit (0-9). The path sum of a binary tree is the sum of all the values from the root to a leaf node. Write a program to find out the maximum path sum from the root to a leaf. A binary tree is represented using the following structure: class TreeNode: def __i...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(node_list): if not node_list: return None nodes = {val: TreeNode(val) for val, left, right in node_list} for val, left, right in node...
from solution import TreeNode, build_tree, max_path_sum, find_max_path_sum def test_max_path_sum(): node_list = [(1, 2, 3), (2, 4, 5), (3, None, None), (4, None, None), (5, None, None)] assert find_max_path_sum(node_list) == 8 def test_single_node(): node_list = [(1, None, None)] assert find_max_path_...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00043973", "row_id": 43973, "seed_ids": "[7163]" }
0.650042
Taco_43973
I
[ "build_tree", "max_path_sum", "find_max_path_sum" ]
3
[ [ "find_max_path_sum", "build_tree" ], [ "find_max_path_sum", "max_path_sum" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
f0dedd3db9457fb30249c92333065e1536eaf010
3a741fad0cdf618eed822aff443c72dbd2472564
v1.0
instruct
Taco
Taco_44041_I
An earthquake shook the city of Anagramland, causing some string mix-ups! You have a list of pairs of strings; each pair represents two possible anagrams. Your task is to determine if each pair of strings can be rearranged to form an exact match of one another. Write a function to check these pairs and output the resul...
def are_anagrams(str1, str2): """ Check if two strings are anagrams. """ return sorted(str1) == sorted(str2) def check_anagram_pairs(pairs): """ Given a list of pairs of strings, determine if each pair are anagrams. """ results = [] for str1, str2 in pairs: if are_anagrams(s...
from solution import are_anagrams, check_anagram_pairs def test_are_anagrams_yes(): assert are_anagrams("listen", "silent") == True assert are_anagrams("triangle", "integral") == True def test_are_anagrams_no(): assert are_anagrams("apple", "pale") == False assert are_anagrams("hello", "world") == Fal...
[ { "docstring": "Check if two strings are anagrams.", "function_declaration": "def are_anagrams(str1, str2):", "function_name": "are_anagrams", "parameter_list": "(str1, str2)" }, { "docstring": "Given a list of pairs of strings, determine if each pair are anagrams.", "function_declaratio...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def are_anagrams(a, b):\n \"\"\"\n Check if the two strings a and b are anagrams of each other.\n \"\"\"\n return sorted(a) == sorted(b)\n\ndef check_a...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00044041", "row_id": 44041, "seed_ids": "[14710]" }
0.634484
Taco_44041
I
[ "are_anagrams", "check_anagram_pairs" ]
2
[ [ "check_anagram_pairs", "are_anagrams" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3010a893b0de7eb9686648893cbe42763a6da62f
b6a108d2a667272f843cc46e3a8c4649b5d6b2a7
v1.0
instruct
Taco
Taco_44087_I
Alien Keyboard In a distant galaxy, humans have discovered an alien civilization with a different keyboard layout. Instead of letters and numbers, their keyboard has symbols and special characters. The alien keyboard has N rows and M columns, forming a rectangular grid. Each key on the keyboard could be one of a set o...
def can_type_word(n, m, keyboard, word): directions = [(-1, 0), (1, 0), (0, -1), (0, 1), (-1, -1), (-1, 1), (1, -1), (1, 1)] def is_valid(x, y): return 0 <= x < n and 0 <= y < m def dfs(x, y, word_idx): if word_idx == len(word): return True temp = keyboard[x][y] ...
def test_can_type_word(): assert can_type_word(4, 5, [ ['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['k', 'l', 'm', 'n', 'o'], ['p', 'q', 'r', 's', 't'] ], 'hello') == False assert can_type_word(3, 3, [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g',...
[ { "docstring": null, "function_declaration": "def can_type_word(n, m, keyboard, word):", "function_name": "can_type_word", "parameter_list": "(n, m, keyboard, word)" }, { "docstring": null, "function_declaration": "def read_and_solve():", "function_name": "read_and_solve", "param...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_type_word(n, m, keyboard, word):\n directions = [(-1, 0), (1, 0), (0, -1), (0, 1), (-1, -1), (-1, 1), (1, -1), (1, 1)]\n\n def is_valid(x, y):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00044087", "row_id": 44087, "seed_ids": "[12742]" }
0.653972
Taco_44087
I
[ "can_type_word", "read_and_solve" ]
2
[ [ "read_and_solve", "can_type_word" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1396595720ee83753e5ef468e24f17b6cfbf992b
b5a7212b2f15fdd7d0210318a8db2b00d88bfd14
v1.0
instruct
Taco
Taco_44099_I
Alice is participating in a game where she needs to create a sequence of numbers based on specific rules. The game starts with a sequence of integers `1, 2, ..., N`. She can perform some operations to transform the sequence in order to achieve the highest possible value for the sum of the sequence after all operations....
import math from functools import reduce from itertools import combinations def lcm(x, y): return (x * y) // math.gcd(x, y) def max_sum_after_operations(N): """ Function to compute the maximum possible sum of the sequence after performing the allowed operations. """ # Initial sequence sequence...
from solution import max_sum_after_operations def test_max_sum_after_operations_1(): assert max_sum_after_operations(4) == 12 def test_max_sum_after_operations_2(): assert max_sum_after_operations(6) == 60 def test_max_sum_after_operations_single(): assert max_sum_after_operations(1) == 1 def test_max_s...
[ { "docstring": null, "function_declaration": "def lcm(x, y):", "function_name": "lcm", "parameter_list": "(x, y)" }, { "docstring": "Function to compute the maximum possible sum of the sequence after performing the allowed operations.", "function_declaration": "def max_sum_after_operatio...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef max_sum_after_operations(N):\n \"\"\"\n Returns the maximum possible sum of the ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00044099", "row_id": 44099, "seed_ids": "[12438]" }
0.658555
Taco_44099
I
[ "lcm", "max_sum_after_operations" ]
2
[ [ "max_sum_after_operations", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8e35ed55ffe7e9fe132af3f0419ddb23bd76298c
6e9a17a4c11f04eace793e4f53678e0ef44ab617
v1.0
instruct
Taco
Taco_44111_I
A company is looking to implement a simple payroll system and needs your expertise. First, write a function that, given the hourly wage (as a float), the total number of hours worked (as a float), and a boolean indicating whether overtime pay applies, will calculate the total salary. The company policy states that sta...
def calculate_salary(hourly_wage, hours_worked, overtime): """ Calculate the total salary based on hourly wage, hours worked and overtime policy. Args: hourly_wage (float): The hourly wage of the employee. hours_worked (float): The number of hours worked by the employee. overtime (bool): Wh...
from solution import calculate_salary, sort_employees_by_salary def test_calculate_salary_no_overtime(): assert calculate_salary(15.00, 40, False) == 600.00 assert calculate_salary(15.00, 35, False) == 525.00 def test_calculate_salary_with_overtime(): assert calculate_salary(15.00, 45, True) == 712.50 ...
[ { "docstring": "Calculate the total salary based on hourly wage, hours worked and overtime policy.\n\nArgs:\nhourly_wage (float): The hourly wage of the employee.\nhours_worked (float): The number of hours worked by the employee.\novertime (bool): Whether overtime pay applies.\n\nReturns:\nfloat: The total sala...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_total_salary(hourly_wage, hours_worked, overtime_applicable):\n \"\"\"\n Calculate the total salary given the hourly wage, total hours worked a...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00044111", "row_id": 44111, "seed_ids": "[2290]" }
0.529424
Taco_44111
I
[ "calculate_salary", "sort_employees_by_salary" ]
2
[ [ "sort_employees_by_salary", "calculate_salary" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7edf0010078e6d545e2b4ba73e0042d013324389
66088b095b96ba7cb5bf72ceff234c6266aa4d7b
v1.0
instruct
Taco
Taco_44136_I
John is participating in a treasure hunt and there are $n$ islands connected by $m$ bridges. Each bridge $i$ connects island $a_i$ to island $b_i$ and has a resistance level $r_i$. John starts on island $1$ and needs to reach island $n$ with the minimum fatigue possible. John's fatigue is defined by the highest resista...
from collections import deque def can_reach_with_max_resistance(graph, n, max_resistance): visited = [False] * (n + 1) queue = deque([1]) visited[1] = True while queue: current = queue.popleft() if current == n: return True for neighbor, resistance in graph[curr...
def test_case_1(): n = 4 m = 5 bridges = [ (1, 2, 7), (1, 3, 3), (2, 3, 2), (2, 4, 9), (3, 4, 8) ] assert min_fatigue(n, m, bridges) == 8 def test_case_2(): n = 3 m = 3 bridges = [ (1, 2, 2), (2, 3, 2), (1, 3, 5) ] ...
[ { "docstring": null, "function_declaration": "def can_reach_with_max_resistance(graph, n, max_resistance):", "function_name": "can_reach_with_max_resistance", "parameter_list": "(graph, n, max_resistance)" }, { "docstring": null, "function_declaration": "def min_fatigue(n, m, bridges):",...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom collections import defaultdict\n\ndef minimize_max_resistance(n, m, bridges):\n graph = defaultdict(list)\n for a, b, r in bridges:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00044136", "row_id": 44136, "seed_ids": "[20266]" }
0.743544
Taco_44136
I
[ "can_reach_with_max_resistance", "min_fatigue" ]
2
[ [ "min_fatigue", "can_reach_with_max_resistance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2b1d7bfa6e28fb3c6ff303f64daad906b8caa193
2854da06c76a82a1ab0441f2726953595e8ccda9
v1.0
instruct
Taco
Taco_44171_I
Little Chandu loves palindromes and symmetry. Recently, he discovered a series of numbers that when converted to strings create a palindrome. Right now, he wants to find the smallest palindrome greater than a given number. You being his elder sibling, are asked to help him write a program to find this smallest palindro...
def is_palindrome(s): return s == s[::-1] def next_palindrome(N): N = str(int(N) + 1) while not is_palindrome(N): N = str(int(N) + 1) return N def smallest_palindromes(test_cases): results = [] for N in test_cases: results.append(next_palindrome(N)) return results def proc...
from solution import process_input, next_palindrome, is_palindrome def test_is_palindrome(): assert is_palindrome("121") == True assert is_palindrome("123") == False assert is_palindrome("1221") == True assert is_palindrome("12321") == True def test_next_palindrome(): assert next_palindrome("123")...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def next_palindrome(N):", "function_name": "next_palindrome", "parameter_list": "(N)" }, { "doc...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def next_palindrome(n):\n \"\"\"\n Find the smallest palindrome greater than a given number n.\n \"\"\"\n def is_palindrome(s):\n return s == s[...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00044171", "row_id": 44171, "seed_ids": "[477]" }
0.826875
Taco_44171
I
[ "is_palindrome", "next_palindrome", "smallest_palindromes", "process_input" ]
4
[ [ "next_palindrome", "is_palindrome" ], [ "process_input", "smallest_palindromes" ], [ "smallest_palindromes", "next_palindrome" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
a3764bdc6339c855c1a51be934630d391f99e199
4110fd6d2e9a0d25956108c23a64e1079066ec4e
v1.0
instruct
Taco
Taco_44184_I
A group of friends are planning a "Secret Santa" gift exchange for the holidays. Each friend buys a gift for another randomly assigned friend. However, because the group takes their holiday fun very seriously, they have imposed some strict rules to ensure fairness and mystery: 1. No one can receive more than one gift....
import random def secret_santa(names): total_friends = len(names) givers = names[:] receivers = names[:] random.shuffle(receivers) # Ensure no one receives their own gift while any(giver == receiver for giver, receiver in zip(givers, receivers)): random.shuffle(receivers) ...
from solution import parse_input, generate_assignments, secret_santa, format_output def test_secret_santa(): names = ['alice', 'bob', 'charlie'] assignments = secret_santa(names) givers = [assignment.split(" -> ")[0] for assignment in assignments] receivers = [assignment.split(" -> ")[1] for assignment...
[ { "docstring": null, "function_declaration": "def secret_santa(names):", "function_name": "secret_santa", "parameter_list": "(names)" }, { "docstring": null, "function_declaration": "def generate_assignments(test_cases):", "function_name": "generate_assignments", "parameter_list"...
[ 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 random\n\ndef secret_santa_assignment(num_cases, cases):\n results = []\n for case in cases:\n N = case[0]\n friends = case[1]\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00044184", "row_id": 44184, "seed_ids": "[3772]" }
0.658673
Taco_44184
I
[ "secret_santa", "generate_assignments", "parse_input", "format_output" ]
4
[ [ "generate_assignments", "secret_santa" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
c0d9cdbfd24354f7e2a305125143afea592a9546
9ab4f3fb6bd7a1f1f8add7c7faa917dd7b6ddaba
v1.0
instruct
Taco
Taco_44204_I
An archaic language, which is unfortunately becoming extinct, is written using unique alphabets. In an attempt to preserve it, a group of linguists is interested in keeping track of all unique words formatted according to the following rules: 1. Each word must be of a fixed length `L`. 2. Each word can only contain an...
def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) def count_unique_words(A, L): """ Returns the number of unique words of length L that can be formed using the first A letters of the alphabet, with no letter used more than once. """ if L > A: retu...
from solution import count_unique_words, unique_words_from_cases def test_count_unique_words_basic(): assert count_unique_words(3, 2) == 6 assert count_unique_words(4, 3) == 24 def test_count_unique_words_edge_cases(): assert count_unique_words(1, 1) == 1 assert count_unique_words(15, 15) == 130767436...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns the number of unique words of length L that can be formed using\nthe first A letters of the alphabet, with no letter used more than once.", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef count_unique_words(A, L):\n \"\"\"\n Returns the number of unique words of length L that can be formed using A letters,\n with no lette...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00044204", "row_id": 44204, "seed_ids": "[2583]" }
0.660734
Taco_44204
I
[ "factorial", "count_unique_words", "unique_words_from_cases" ]
3
[ [ "count_unique_words", "factorial" ], [ "unique_words_from_cases", "count_unique_words" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0f3693c77657bb5366acd26ed37a299e5b413299
18e47ff69a1ca256c51f575a020132326a3456b5
v1.0
instruct
Taco
Taco_44272_I
Emma is planning her garden and wants to allocate space optimally for her plants. She has a plot that is divided into n rows and m columns, forming an n × m grid. Some cells might be blocked due to rocks or other obstacles, and Emma cannot use these for planting. A cell is denoted as blocked if it contains a '1' and av...
def can_place(garden, n, m, r, c, x, y): if x + r > n or y + c > m: return False for i in range(r): for j in range(c): if garden[x + i][y + j] == '1': return False return True def mark_taken(garden, r, c, x, y): for i in range(r): for j in range(c): ...
from solution import garden_planner def test_garden_planner_case1(): n = 5 m = 6 q = 2 grid = [ "001000", "000100", "010000", "000000", "100010" ] plants = [(2, 3), (3, 2)] assert garden_planner(n, m, q, grid, plants) == "YES" def test_garden_planner...
[ { "docstring": null, "function_declaration": "def can_place(garden, n, m, r, c, x, y):", "function_name": "can_place", "parameter_list": "(garden, n, m, r, c, x, y)" }, { "docstring": null, "function_declaration": "def mark_taken(garden, r, c, x, y):", "function_name": "mark_taken", ...
[ 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 can_place_plants(grid, plants):\n n = len(grid)\n m = len(grid[0])\n \n def can_place(r, c, x, y):\n if x + r > n or y + c > m:\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00044272", "row_id": 44272, "seed_ids": "[24103]" }
0.748084
Taco_44272
I
[ "can_place", "mark_taken", "garden_planner" ]
3
[ [ "garden_planner", "can_place" ], [ "garden_planner", "mark_taken" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e5965903af36f0a37f04aaeeb6a26545573cb8d5
cfa7254d7ab816d4a6807d89ef99303820c40138
v1.0
instruct
Taco
Taco_44298_I
"The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers of this sequence are 0, 1, 1, 2, 3, 5, 8, and so on. You need to find the N-th Fibonacci number. However, since Fibonacci numbers grow very fast, the ...
MOD = 10**9 + 7 def matrix_multiply(A, B): return [ [ (A[0][0]*B[0][0] + A[0][1]*B[1][0]) % MOD, (A[0][0]*B[0][1] + A[0][1]*B[1][1]) % MOD ], [ (A[1][0]*B[0][0] + A[1][1]*B[1][0]) % MOD, (A[1][0]*B[0][1] + A[1][1]*B[1][1]) % MOD ] ...
from solution import nth_fibonacci, process_test_cases def test_nth_fibonacci_basic(): assert nth_fibonacci(0) == 0 assert nth_fibonacci(1) == 1 assert nth_fibonacci(2) == 1 assert nth_fibonacci(10) == 55 def test_nth_fibonacci_large(): # Test for large input, manually computed assert nth_fibo...
[ { "docstring": null, "function_declaration": "def matrix_multiply(A, B):", "function_name": "matrix_multiply", "parameter_list": "(A, B)" }, { "docstring": null, "function_declaration": "def matrix_power(matrix, n):", "function_name": "matrix_power", "parameter_list": "(matrix, n...
[ 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": "MOD = 10**9 + 7\n\ndef fibonacci(n):\n if n == 0:\n return 0\n if n == 1:\n return 1\n\n def multiply_matrices(m1, m2):\n return [\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00044298", "row_id": 44298, "seed_ids": "[21526]" }
0.673523
Taco_44298
I
[ "matrix_multiply", "matrix_power", "nth_fibonacci", "process_test_cases" ]
4
[ [ "matrix_power", "matrix_multiply" ], [ "nth_fibonacci", "matrix_power" ], [ "process_test_cases", "nth_fibonacci" ] ]
3
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
24dd3425965d599f83beeafe94467c4eb5f631af
a94419cef96ce12cc6e7ba657152ca9340f5d0d1
v1.0
instruct
Taco
Taco_44347_I
In a small village, there is a river running through it, dividing the village into two halves. The villagers have decided to build a series of bridges to connect the two halves, but they want to do it in such a way that no two bridges intersect when viewed from above. You're given two lists, each containing $n$ integ...
def max_bridges(n, A, B): bridges = sorted(zip(A, B)) LIS = [] for bridge in bridges: pos = binary_search(LIS, bridge[1]) if pos == len(LIS): LIS.append(bridge[1]) else: LIS[pos] = bridge[1] return len(LIS) def binary_search(LIS, value): low, hi...
from solution import max_bridges def test_example(): assert max_bridges(5, [1, 3, 5, 2, 4], [2, 4, 1, 5, 3]) == 2 def test_all_same_position(): assert max_bridges(3, [1, 2, 3], [4, 5, 6]) == 3 def test_increasing_order(): assert max_bridges(4, [1, 2, 3, 4], [1, 2, 3, 4]) == 4 def test_decreasing_order()...
[ { "docstring": null, "function_declaration": "def max_bridges(n, A, B):", "function_name": "max_bridges", "parameter_list": "(n, A, B)" }, { "docstring": null, "function_declaration": "def binary_search(LIS, value):", "function_name": "binary_search", "parameter_list": "(LIS, val...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_bridges(n, A, B):\n \"\"\"\n Determine the maximum number of bridges that can be built without any two bridges intersecting.\n \n Args:\n n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00044347", "row_id": 44347, "seed_ids": "[7435]" }
0.678772
Taco_44347
I
[ "max_bridges", "binary_search" ]
2
[ [ "max_bridges", "binary_search" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ff6fcda7764926e4d2571f53476849ff6fb40291
4e863a2b3242b7cf330373d6a4361e7fb5750448
v1.0
instruct
Taco
Taco_44360_I
Chef is an expert in strings and loves to solve problems related to string manipulation. One day, he came across a problem that he found particularly interesting and challenging. He wants to find out whether a given string is a "mirror" string. A "mirror" string is a string that looks the same even if it is reversed af...
def is_mirror_string(s): """ Determines if the given string is a "mirror" string. A "mirror" string is one that appears the same when reversed and characters are replaced by their mirror counterparts. Only the characters {'A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y'} are mirror cha...
from solution import is_mirror_string, check_mirror_strings def test_is_mirror_string(): # Test cases where the output should be True assert is_mirror_string("AHA") == True assert is_mirror_string("YXY") == True assert is_mirror_string("A") == True # Test cases where the output should be False ...
[ { "docstring": "Determines if the given string is a \"mirror\" string.\n\nA \"mirror\" string is one that appears the same when reversed and\ncharacters are replaced by their mirror counterparts.\nOnly the characters {'A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y'}\nare mirror characters.\n\nParameters:\...
[ 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_mirror_string(s):\n mirror_chars = set('AHIMOTUVWXY')\n for char in s:\n if char not in mirror_chars:\n return \"NO\"\n return \"...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00044360", "row_id": 44360, "seed_ids": "[16135]" }
0.77586
Taco_44360
I
[ "is_mirror_string", "check_mirror_strings" ]
2
[ [ "check_mirror_strings", "is_mirror_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
56e56581fdb872a48da6c29a9fb1678dde83fd8f
8e0e64d56a62891369132ac7fd10106c5e9fa87c