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_73192_I
You are given a binary tree where each node contains an integer value. Your task is to determine if the tree is balanced. A balanced tree is defined as one where the depth of the two subtrees of every node never differs by more than 1. Input The input consists of a binary tree in the form of a single string. Each nod...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def list_to_tree(lst): if not lst: return None def inner(index): if index >= len(lst) or lst[index] == "None": return None node = ...
from solution import solution def test_example_1(): assert solution("1,2,2,3,3,None,None,4,4") == False def test_example_2(): assert solution("3,9,20,None,None,15,7") == True def test_single_node(): assert solution("1") == True def test_none_tree(): assert solution("None") == True def test_balanced...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import Optional\nimport collections\n\n# Define TreeNode class\nclass TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073192", "row_id": 73192, "seed_ids": "[13633]" }
0.821338
Taco_73192
I
[ "list_to_tree", "isBalanced", "solution" ]
3
[ [ "solution", "isBalanced" ], [ "solution", "list_to_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
b6cdf523e17d9833757e71908c4ecef27662d787
9deda3a838cade4b7a4417c081d31438409c1c3c
v1.0
instruct
Taco
Taco_73200_I
Write a program to determine whether a number is a prime number and also a palindrome. A prime number is a number greater than 1 that has no positive divisors other than 1 and itself. A palindrome is a number that reads the same forward and backward. ------ Input Format ------ - The first line contains an integer N, ...
def is_prime(n): """ Determines if a number is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def is_palindrome(n): ...
from solution import is_prime, is_palindrome, is_prime_palindrome, process_test_cases 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(13) == True assert is_prime(15)...
[ { "docstring": "Determines if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Determines if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "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 is_prime(n):\n \"\"\"\n Determines if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00073200", "row_id": 73200, "seed_ids": "[6814]" }
0.698712
Taco_73200
I
[ "is_prime", "is_palindrome", "is_prime_palindrome", "process_test_cases" ]
4
[ [ "is_prime_palindrome", "is_palindrome" ], [ "is_prime_palindrome", "is_prime" ], [ "process_test_cases", "is_prime_palindrome" ] ]
3
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
dd093a798e23e14b0a73de798e50931824e09a7a
d56daa95b3d9a21380c828b570f3613efbcc9eaa
v1.0
instruct
Taco
Taco_73207_I
Given a list of integers, we can define its "uniqueness score" as the number of unique prime factors across all the integers in the list. Write a function to compute the uniqueness score of a given list of integers. ### Input - A single line containing space-separated integers. Each integer is positive and does not e...
from math import isqrt def prime_factors(n): factors = set() # Divide by 2 until n is odd while n % 2 == 0: factors.add(2) n //= 2 # Check for odd factors from 3 up to sqrt(n) for i in range(3, isqrt(n) + 1, 2): while n % i == 0: factors.add(i) n //= ...
from solution import compute_uniqueness_score def test_single_number(): assert compute_uniqueness_score("6") == 2 # Prime factors: 2, 3 def test_multiple_numbers(): assert compute_uniqueness_score("6 10 15") == 3 # Prime factors: 2, 3, 5 def test_unique_prime(): assert compute_uniqueness_score("2 3 5 7...
[ { "docstring": null, "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def uniqueness_score(numbers):", "function_name": "uniqueness_score", "parameter_list": "(numbers)" }...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef sieve(limit):\n is_prime = [True] * (limit + 1)\n p = 2\n while p * p <= limit:\n if is_prime[p]:\n for i in range(p ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00073207", "row_id": 73207, "seed_ids": "[16319]" }
0.641539
Taco_73207
I
[ "prime_factors", "uniqueness_score", "compute_uniqueness_score" ]
3
[ [ "compute_uniqueness_score", "uniqueness_score" ], [ "uniqueness_score", "prime_factors" ] ]
2
[]
false
[]
false
pytest
true
[]
true
530a006c153dd545d3b2173809ae4ccddbf5627d
19cf0d24e40703c6ed78ab7e3c5309a219af3db0
v1.0
instruct
Taco
Taco_73221_I
Hey, I need some help with a programming challenge that I found on a competitive coding website. It's a bit tricky and my solution keeps failing for the larger test cases. Could you help me write a more efficient version? The problem is called "Rectangle Query". I’m attaching the problem statement and my solution b...
def prefix_sum(array, n, m): """ Computes the prefix sum array for a given 2D array. """ ps = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): ps[i][j] = array[i-1][j-1] + ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1] return ps def rectangle...
from solution import rectangle_query def test_rectangle_query_single_query(): A = [ [2, 1, 4], [3, 0, 5], [7, 2, 2] ] queries = [(1, 1, 2, 2)] assert rectangle_query(A, queries) == [6] def test_rectangle_query_multiple_queries(): A = [ [2, 1, 4], [3, 0, 5], ...
[ { "docstring": "Computes the prefix sum array for a given 2D array.", "function_declaration": "def prefix_sum(array, n, m):", "function_name": "prefix_sum", "parameter_list": "(array, n, m)" }, { "docstring": "Handles rectangle queries using a prefix sum array.", "function_declaration": ...
[ 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 prefix_sum(array, n, m):\n \"\"\"\n Computes the prefix sum array for a given 2D array.\n \"\"\"\n ps = [[0] * (m + 1) for _ in range(n + 1)]\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00073221", "row_id": 73221, "seed_ids": "[2220]" }
0.627073
Taco_73221
I
[ "prefix_sum", "rectangle_query" ]
2
[ [ "rectangle_query", "prefix_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6b70651e856902eb9bba4ed0007902d56d8528fa
7ffe839be3ac85b7403460dd050c3b5fc99a4e04
v1.0
instruct
Taco
Taco_73346_I
A group of researchers is studying the migratory patterns of a certain species of birds. They have tracked the paths taken by several birds using a set of waypoints for each bird's journey. Each bird's path is defined as a series of straight line segments connecting these waypoints in sequence. To help analyze the dat...
import math def calculate_distance(x1, y1, x2, y2): return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def bird_journeys(m, data): results = [] index = 0 for i in range(m): ki = data[index] index += 1 waypoints = data[index: index + ki*2] index += ki*2 total_dist...
from solution import bird_journeys def test_bird_journeys(): # Test case 1 m = 2 data = [3, 0, 0, 3, 4, 6, 0, 4, 1, 1, 2, 2, 3, 3, 4, 4] result = bird_journeys(m, data) expected = [10.0000000000, 4.2426406871] assert len(result) == len(expected) for r, e in zip(result, expected): as...
[ { "docstring": null, "function_declaration": "def calculate_distance(x1, y1, x2, y2):", "function_name": "calculate_distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def bird_journeys(m, data):", "function_name": "bird_journeys", "pa...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef bird_journey_lengths(m: int, birds_data: list):\n \"\"\"\n This function takes the number of birds and their waypoint data and returns\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00073346", "row_id": 73346, "seed_ids": "[11684]" }
0.634351
Taco_73346
I
[ "calculate_distance", "bird_journeys" ]
2
[ [ "bird_journeys", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ef4ccab03ccbe90bb627bcac557813666f2b382
97c32d22591b93a013e4e304e057811a11a70fbf
v1.0
instruct
Taco
Taco_73363_I
You are tasked with organizing a series of workshops for a conference. Each workshop takes place in a separate room, and each room has a specific capacity and a list of time slots when it is available. You want to find out if it is possible to schedule all the workshops such that no two workshops overlap in time within...
def can_schedule_workshops(rooms, workshops): """ Function to determine if all workshops can be scheduled without time overlaps and within room capacity constraints. Params: - rooms (list of tuples): (roomName, capacity, timeSlots) - workshops (list of tuples): (workshopName, requiredCapaci...
from solution import can_schedule_workshops, parse_input, schedule_conference def test_parse_input(): input_string = """2 roomA 50 3 0 30 60 roomB 100 2 30 60 3 workshop1 50 0 workshop2 50 30 workshop3 50 60""" expected_rooms = [('roomA', 50, [0, 30, 60]), ('roomB...
[ { "docstring": "Function to determine if all workshops can be scheduled without time overlaps\nand within room capacity constraints.\n\nParams:\n- rooms (list of tuples): (roomName, capacity, timeSlots)\n- workshops (list of tuples): (workshopName, requiredCapacity, preferredTimeSlot)\n\nReturns:\n- (str): \"po...
[ 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_schedule_workshops(rooms, workshops):\n \"\"\"\n Function to determine if all workshops can be scheduled without time overlaps\n and within room c...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00073363", "row_id": 73363, "seed_ids": "[19683]" }
0.684263
Taco_73363
I
[ "can_schedule_workshops", "parse_input", "schedule_conference" ]
3
[ [ "schedule_conference", "can_schedule_workshops" ], [ "schedule_conference", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
d06923e2a50d2dac3ac830abb98a3489e863f813
b1ca966c954a7c4b9f75fd85b9072bf0d1b2e68b
v1.0
instruct
Taco
Taco_73411_I
You are given a grid-based maze composed of cells where each cell is either empty (denoted by '.') or contains an obstacle (denoted by '#'). You're tasked with finding the shortest path from a starting point to a destination point without stepping on obstacles. The maze allows four possible moves from a cell: up, down,...
from collections import deque def bfs(maze, start, end): n = len(maze) m = len(maze[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(start[0], start[1], 0)]) # (x, y, distance) visited = set() visited.add((start[0], start[1])) # Finding all portals portals = {} ...
def test_sample_1(): n, m = 5, 5 maze = [ ['.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.'], ['.', '.', 'P', '.', '.'], ['.', '#', '.', '#', '.'] ] start = (0, 0) end = (4, 4) assert shortest_path_with_portals(n, m, maze, star...
[ { "docstring": null, "function_declaration": "def bfs(maze, start, end):", "function_name": "bfs", "parameter_list": "(maze, start, end)" }, { "docstring": null, "function_declaration": "def shortest_path_with_portals(n, m, maze, start, end):", "function_name": "shortest_path_with_po...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_maze(n, m, maze, start, end):\n directions = [(1, 0), (-1, 0), (0, 1), (0, -1)] # down, up, right, and le...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00073411", "row_id": 73411, "seed_ids": "[3038]" }
0.695682
Taco_73411
I
[ "bfs", "shortest_path_with_portals" ]
2
[ [ "shortest_path_with_portals", "bfs" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6ebbe79f815dbff52154a0aa97d275cfa20d6e80
25253325ae01798bb493e7abaaf8edf3d4e16ca9
v1.0
instruct
Taco
Taco_73504_I
Bob is building a machine that requires the use of special numbers. A number is considered special if it is an odd number and all of its digits are distinct. Given an integer N, Bob wants to know the smallest special number that is greater than N. Input: The first line contains an integer T, the number of test cases....
def is_special(number): """ Check if a number is special: odd and all digits are unique. """ str_num = str(number) if number % 2 == 0: # Not an odd number return False if len(set(str_num)) != len(str_num): # Digits are not unique return False return True def find_smallest_...
import pytest from solution import is_special, find_smallest_special_number_greater_than, process_test_cases def test_is_special(): assert is_special(125) == True assert is_special(1023457) == True assert is_special(1234) == False # Even number assert is_special(112) == False # Repeated digit ass...
[ { "docstring": "Check if a number is special: odd and all digits are unique.", "function_declaration": "def is_special(number):", "function_name": "is_special", "parameter_list": "(number)" }, { "docstring": "Find the smallest special number greater than N.", "function_declaration": "def...
[ 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_special_number(num):\n \"\"\"\n Check if a number is special: consists of distinct digits and is odd.\n \"\"\"\n num_str = str(num)\n return ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00073504", "row_id": 73504, "seed_ids": "[21412]" }
0.695053
Taco_73504
I
[ "is_special", "find_smallest_special_number_greater_than", "process_test_cases" ]
3
[ [ "find_smallest_special_number_greater_than", "is_special" ], [ "process_test_cases", "find_smallest_special_number_greater_than" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
6d025d4325543f65fbb88d75f38ecd4a6e45b33c
94e8f208311f85ae633b49a4e8f38427ffbc3b5b
v1.0
instruct
Taco
Taco_73506_I
Given a collection of words, determine the number of words that can be typed using letters of only one row of a standard QWERTY keyboard. A standard QWERTY keyboard can be visualized as follows: ``` QWERTYUIOP ASDFGHJKL ZXCVBNM ``` You can assume the input words will only contain alphabetic characters. ------ Input -...
def can_be_typed_on_one_row(word, rows): for row in rows: if all(char in row for char in word.lower()): return True return False def count_one_row_words(words): rows = [ set("qwertyuiop"), set("asdfghjkl"), set("zxcvbnm") ] count = 0 for word in ...
from solution import count_one_row_words def test_count_one_row_words(): assert count_one_row_words(["Hello", "Alaska", "Dad", "Peace", "Quiz"]) == 2 def test_count_one_row_words_empty(): assert count_one_row_words([]) == 0 def test_count_one_row_words_single_row(): assert count_one_row_words(["qwerty", ...
[ { "docstring": null, "function_declaration": "def can_be_typed_on_one_row(word, rows):", "function_name": "can_be_typed_on_one_row", "parameter_list": "(word, rows)" }, { "docstring": null, "function_declaration": "def count_one_row_words(words):", "function_name": "count_one_row_wor...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_typed_on_one_row(word, rows):\n for row in rows:\n if all(char in row for char in word.lower()):\n return True\n return False\n\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00073506", "row_id": 73506, "seed_ids": "[5454]" }
0.650085
Taco_73506
I
[ "can_be_typed_on_one_row", "count_one_row_words" ]
2
[ [ "count_one_row_words", "can_be_typed_on_one_row" ] ]
1
[]
false
[]
false
pytest
true
[]
true
67ee5a108c133da1a0660938d5f23ac7d24a9c82
f7698db9342e377d53d437ecb07910235fc5e05d
v1.0
instruct
Taco
Taco_73548_I
The kingdom of Lynaria is famous for its beautiful landscapes and unique transportation network. The transportation network consists of $n$ cities connected by $n-1$ bidirectional roads forming a tree. Each road has a certain travel time associated with it. The citizens of Lynaria want to organize a festival. They pla...
from collections import deque, defaultdict def bfs_farthest(start, n, adj): """ Utilizes BFS to find the farthest node from the starting node, along with its distance. """ distance = [-1] * (n + 1) distance[start] = 0 queue = deque([start]) farthest_node = start max_distance = 0 ...
def test_find_festival_city(): assert find_festival_city(4, [(1, 2, 4), (2, 3, 2), (2, 4, 6)]) == 2 assert find_festival_city(3, [(1, 2, 1), (1, 3, 1)]) == 1 assert find_festival_city(5, [(1, 2, 5), (1, 3, 1), (2, 4, 2), (3, 5, 3)]) == 1 def test_example_cases(): test_cases = [ (4, [(1, 2, 4), ...
[ { "docstring": "Utilizes BFS to find the farthest node from the starting node, along with its distance.", "function_declaration": "def bfs_farthest(start, n, adj):", "function_name": "bfs_farthest", "parameter_list": "(start, n, adj)" }, { "docstring": "Finds the city that should be chosen a...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef bfs_farthest(start, n, adj):\n \"\"\"\n Utilizes BFS to find the farthest node from the starting node, alon...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00073548", "row_id": 73548, "seed_ids": "[3500]" }
0.793127
Taco_73548
I
[ "bfs_farthest", "find_festival_city", "process_test_cases" ]
3
[ [ "find_festival_city", "bfs_farthest" ], [ "process_test_cases", "find_festival_city" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
c19a087caa2cab8ca23e260bd40a404542181b58
edd0ebb27a8ef55f97cf2bcd7a164afdc7079da3
v1.0
instruct
Taco
Taco_73559_I
A software development company is working on a new feature for auto-validation of passwords. The passwords need to meet several criteria in order to be considered valid. The criteria are as follows: 1. The password must be at least 8 characters long. 2. The password must contain at least one uppercase letter. 3. The p...
import re def is_password_valid(password): """ Validate the password based on the given criteria: 1. at least 8 characters long 2. contains at least one uppercase letter 3. contains at least one lowercase letter 4. contains at least one digit 5. contains at least one special character from ...
from solution import is_password_valid, validate_passwords def test_is_password_valid(): assert is_password_valid("Passw0rd!") == "valid" assert is_password_valid("password") == "invalid" assert is_password_valid("P@ssw0rd") == "valid" assert is_password_valid("short!") == "invalid" assert is_passw...
[ { "docstring": "Validate the password based on the given criteria:\n1. at least 8 characters long\n2. contains at least one uppercase letter\n3. contains at least one lowercase letter\n4. contains at least one digit\n5. contains at least one special character from the set: !@#$%^&*()-+", "function_declarati...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_password_valid(password):\n \"\"\"\n Validate the password based on the given criteria:\n 1. at least 8 characters long\n 2. contai...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00073559", "row_id": 73559, "seed_ids": "[3204]" }
0.629265
Taco_73559
I
[ "is_password_valid", "validate_passwords" ]
2
[ [ "validate_passwords", "is_password_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
35e0b4fa508595b0bc33680be8257665b71ce400
c48279ce22c8ae9206e40f01269039a0709048e3
v1.0
instruct
Taco
Taco_73572_I
You are given an m x n grid representing a maze. Each cell in the maze can either be a wall (#) or a path (.). You want to escape the maze starting from the top-left corner (0, 0) to the bottom-right corner (m-1, n-1). You can move up, down, left, or right, but not diagonally. Determine the minimum number of steps requ...
from collections import deque def min_steps_to_escape_maze(m, n, maze): # Directions for movement: up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] def is_valid(x, y): return 0 <= x < m and 0 <= y < n and maze[x][y] == '.' # BFS from the top-left corner queue ...
from solution import solve_maze_escape_problem def test_maze_escape_example1(): m = 5 n = 5 maze = [ "...#.", "#..#.", "#..#.", ".#..#", "#.#.." ] assert solve_maze_escape_problem(m, n, maze) == 8 def test_maze_escape_example2(): m = 5 n = 5 maze...
[ { "docstring": null, "function_declaration": "def min_steps_to_escape_maze(m, n, maze):", "function_name": "min_steps_to_escape_maze", "parameter_list": "(m, n, maze)" }, { "docstring": null, "function_declaration": "def solve_maze_escape_problem(m, n, maze):", "function_name": "solv...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 ]
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_escape_maze(m, n, maze):\n \"\"\"\n Returns the minimum number of steps required to escape the maze from to...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00073572", "row_id": 73572, "seed_ids": "[11793]" }
0.699926
Taco_73572
I
[ "min_steps_to_escape_maze", "solve_maze_escape_problem" ]
2
[ [ "solve_maze_escape_problem", "min_steps_to_escape_maze" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9abef4452537f5085e6525d811aece2624e45a4c
6cde4d2016f116d1ecd2309f998d2c72c8db53b3
v1.0
instruct
Taco
Taco_73652_I
Alice loves to play a puzzle game in which she has a grid of characters and words hidden within the grid. Words can appear in the grid in horizontal or vertical directions, either forwards or backwards. Given a grid and a list of words, Alice wants to know if each word from the list can be found within the grid. -----...
def find_word_in_grid(grid, word): """ Returns 'yes' if the word can be found in the grid in horizontal or vertical directions, either forwards or backwards. Otherwise returns 'no'. """ n = len(grid) word_len = len(word) # Check horizontally and vertically for i in range(n): ...
import pytest from solution import find_words_in_grid def test_case_sample_1(): n = 4 grid = [ "abcd", "efgh", "ijkl", "mnop" ] k = 2 words = ["abc", "ponm"] expected = ["yes", "yes"] assert find_words_in_grid(n, grid, k, words) == expected def test_case_sam...
[ { "docstring": "Returns 'yes' if the word can be found in the grid in horizontal or vertical directions, either forwards or backwards.\nOtherwise returns 'no'.", "function_declaration": "def find_word_in_grid(grid, word):", "function_name": "find_word_in_grid", "parameter_list": "(grid, word)" }, ...
[ 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_word_in_grid(grid, word):\n n = len(grid)\n word_len = len(word)\n \n def check_word(r, c, dr, dc):\n for i in range(word_len):\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00073652", "row_id": 73652, "seed_ids": "[10383]" }
0.687125
Taco_73652
I
[ "find_word_in_grid", "find_words_in_grid" ]
2
[ [ "find_words_in_grid", "find_word_in_grid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
117e354994b33aba15eb2bcbcd1e9c5183eca77f
df23e680e222479bbcc8bc7fa432e38ed10f0bd5
v1.0
instruct
Taco
Taco_73723_I
A large corporation has $N$ departments and $M$ employees. The company wants to implement a new policy to equally distribute workload among departments. Each employee can work in multiple departments and each department has a different minimum number of employees required to function efficiently. Your task is to determ...
def can_distribute_workload(N, M, R, employee_preferences): from itertools import permutations def is_valid_assignment(employee_assignment): department_counts = [0] * N for employee, depts in employee_assignment.items(): for dept in depts: department_counts[dept]...
def test_can_distribute_workload_case1(): N = 3 M = 3 R = [1, 1, 1] employee_preferences = { 0: [0, 1], 1: [1, 2], 2: [2] } assert can_distribute_workload(N, M, R, employee_preferences) == "YES" def test_can_distribute_workload_case2(): N = 3 M = 3 R = [2, 1,...
[ { "docstring": null, "function_declaration": "def can_distribute_workload(N, M, R, employee_preferences):", "function_name": "can_distribute_workload", "parameter_list": "(N, M, R, employee_preferences)" }, { "docstring": null, "function_declaration": "def distribute_workload():", "f...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_distribute_workload(N, M, requirements, employees):\n from collections import defaultdict\n from itertools import combinations\n\n # Create a list...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073723", "row_id": 73723, "seed_ids": "[23761]" }
0.694272
Taco_73723
I
[ "can_distribute_workload", "distribute_workload" ]
2
[ [ "distribute_workload", "can_distribute_workload" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c4bdde3debe24d49e809180fbd8af75e0244e253
fc9cfbbc28fc60870a34605b5432928dea8875ca
v1.0
instruct
Taco
Taco_73834_I
Implement a function `sort_and_merge` that takes two lists of integers, sorts each list in ascending order, and then merges the two sorted lists into one sorted list in ascending order without using any built-in sort or merge functions. The function should return the final merged sorted list. ### Input: - Two lists of...
def bubble_sort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] def merge_sorted_lists(list1, list2): sorted_list = [] i, j = 0, 0 while i < len(list1) and j < len(list2): if list1[...
from solution import sort_and_merge def test_sort_and_merge(): list1 = [3, 1, 5] list2 = [2, 8, 4] assert sort_and_merge(list1, list2) == [1, 2, 3, 4, 5, 8] def test_sort_and_merge_empty_lists(): list1 = [] list2 = [] assert sort_and_merge(list1, list2) == [] def test_sort_and_merge_one_empty...
[ { "docstring": null, "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge_sorted_lists(list1, list2):", "function_name": "merge_sorted_lists", "parameter_list": "(list...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_and_merge(list1, list2):\n def bubble_sort(arr):\n n = arr.length\n for i in range(n):\n for j in range(0, n - i - 1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073834", "row_id": 73834, "seed_ids": "[23698]" }
0.583882
Taco_73834
I
[ "bubble_sort", "merge_sorted_lists", "sort_and_merge" ]
3
[ [ "sort_and_merge", "bubble_sort" ], [ "sort_and_merge", "merge_sorted_lists" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d3dd933f68ae8760125b4c2fa7c57b58e9aa40c8
4142e83d26630ccf2f161cf5f45b95ac8ed5560e
v1.0
instruct
Taco
Taco_73876_I
You are working on a new online social media platform that is implementing a feature to shorten lengthy URLs. One of the requirements is to ensure that each shortened URL is unique and easy to remember. To achieve this, you need to generate unique shortcodes based on the original URLs provided as input. The shortcodes ...
import itertools # A generator for base-26 alphabetic sequences def base26_generator(): length = 1 while True: for s in itertools.product("abcdefghijklmnopqrstuvwxyz", repeat=length): yield ''.join(s) length += 1 def generate_shortcodes(urls): url_to_shortcode = {} generato...
from solution import generate_shortcodes def test_generate_shortcodes_simple(): urls = ["https://example.com/page1", "https://example.com/page2"] expected = ["a", "b"] assert generate_shortcodes(urls) == expected def test_generate_shortcodes_repeated_url(): urls = [ "https://first.com", ...
[ { "docstring": null, "function_declaration": "def base26_generator():", "function_name": "base26_generator", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate_shortcodes(urls):", "function_name": "generate_shortcodes", "parameter_list": "(urls)"...
[ 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 generate_shortcodes(urls):\n def num_to_shortcode(num):\n \"\"\"Converts a number into a base-26-like shortcode.\"\"\"\n shortcode = []\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073876", "row_id": 73876, "seed_ids": "[15942]" }
0.494133
Taco_73876
I
[ "base26_generator", "generate_shortcodes" ]
2
[ [ "generate_shortcodes", "base26_generator" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfa848285bf463ea1600753373d38de212d308a9
2ea214517052dcaf7266114bf2d5f6a28bc15ae5
v1.0
instruct
Taco
Taco_73886_I
Given two strings s1 and s2, write a function to determine if s2 is a rotated version of s1. A rotation of a string is obtained by moving characters from the beginning of the string to the end of the string. For example, "bottle" and "tlebot" are rotated versions of the string "bottlet". You can only call the isSubstr...
def isSubstring(s1, s2): """ Checks if s2 is a substring of s1. """ return s2 in s1 def isRotatedVersion(s1, s2): """ Returns True if s2 is a rotated version of s1, False otherwise. """ if len(s1) != len(s2): return False concatenated = s1 + s1 return isSubstring(concate...
from solution import isRotatedVersion def test_rotated_version_true(): assert isRotatedVersion("bottle", "tlebot") == True assert isRotatedVersion("waterbottle", "erbottlewat") == True assert isRotatedVersion("abcd", "dabc") == True def test_rotated_version_false(): assert isRotatedVersion("hello", "w...
[ { "docstring": "Checks if s2 is a substring of s1.", "function_declaration": "def isSubstring(s1, s2):", "function_name": "isSubstring", "parameter_list": "(s1, s2)" }, { "docstring": "Returns True if s2 is a rotated version of s1, False otherwise.", "function_declaration": "def isRotate...
[ 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 isSubstring(s1, s2):\n \"\"\"\n Return True if s2 is a substring of s1, else False.\n \"\"\"\n return s2 in s1\n\ndef isRotatedVersion(s1, s2):\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00073886", "row_id": 73886, "seed_ids": "[12594]" }
0.627721
Taco_73886
I
[ "isSubstring", "isRotatedVersion" ]
2
[ [ "isRotatedVersion", "isSubstring" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c76a05c697a2d87b327248e701f3c14fc949d04
d3598f32e91055fbd868f9c8a9ccd129b8fc84db
v1.0
instruct
Taco
Taco_73919_I
**Step 1:** Create a function called `word_count()` that takes a string and returns a dictionary where the keys are unique words, and the values are the number of times those words appeared in the input string. Ignore punctuation and case sensitivity. For example, `word_count("Hello, hello! How are you?")` would retur...
import re from collections import defaultdict def word_count(input_string): """ Returns a dictionary with the count of each unique word in the input string. """ # Remove punctuation and make the string lowercase words = re.findall(r'\b\w+\b', input_string.lower()) word_freq = defaultdict(int) ...
from solution import word_count, most_common_word def test_word_count_basic(): assert word_count("Hello, hello! How are you?") == {"hello": 2, "how": 1, "are": 1, "you": 1} def test_word_count_empty(): assert word_count("") == {} def test_word_count_punctuation(): assert word_count("Cats, cats, cats.") =...
[ { "docstring": "Returns a dictionary with the count of each unique word in the input string.", "function_declaration": "def word_count(input_string):", "function_name": "word_count", "parameter_list": "(input_string)" }, { "docstring": "Returns the word that appears the most number of times ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nfrom collections import Counter\n\ndef word_count(text):\n \"\"\"\n Returns a dictionary with unique words as keys and their counts as values.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073919", "row_id": 73919, "seed_ids": "[20372]" }
0.792335
Taco_73919
I
[ "word_count", "most_common_word" ]
2
[ [ "most_common_word", "word_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
304988fda09a63f3352fbadff32be07db3e7b048
6f5049f449f4ed9845cd8515623c34b2912465e5
v1.0
instruct
Taco
Taco_73932_I
Write a function that takes a list of integers and returns a list of the prime numbers found in the original list. A prime number is a number that has no positive divisors other than 1 and itself. The order of the primes in the returned list should match the order in which they appear in the input list. If the input li...
import math def is_prime(n): """ Determines if a given number n is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(math.sqrt(n)) + 1 for d in range(3, max_divisor, 2): if n % d == 0: ...
from solution import is_prime, find_primes def test_is_prime(): assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(2) assert not is_prime(1) assert not is_prime(0) assert is_prime(29) assert not is_prime(100) def test_find_primes_with_mixed_numbers(): numb...
[ { "docstring": "Determines if a given number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers found in the original list.", "function_declaration": "def find_primes(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(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073932", "row_id": 73932, "seed_ids": "[24519]" }
0.756349
Taco_73932
I
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6617cbfd3e1cabc92ac6cdfe2da71a146966dca7
b516fedc526aabe5100a60d2f5213ec8f6f38735
v1.0
instruct
Taco
Taco_73935_I
Fiona the Farmer has a rectangular farm with $N$ rows and $M$ columns, all filled with steel crates. Each cell in the farm grid is identified by its coordinates $(i,j)$, where $1 \leq i \leq N$ and $1 \leq j \leq M$. Recently, she acquired a magic plow that can remove crates in various rectangular subgrids from her far...
def apply_operations(N, M, operations): # Initial farm grid, filled with 1s farm = [[1] * M for _ in range(N)] # Apply each operation for r1, c1, r2, c2 in operations: for i in range(r1 - 1, r2): for j in range(c1 - 1, c2): farm[i][j] = 0 return farm de...
def test_apply_operations(): N, M = 3, 4 operations = [ (1, 1, 2, 2), (2, 3, 3, 4) ] expected_output = [ [0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 0, 0] ] assert apply_operations(N, M, operations) == expected_output def test_process_test_cases(): T = 1 t...
[ { "docstring": null, "function_declaration": "def apply_operations(N, M, operations):", "function_name": "apply_operations", "parameter_list": "(N, M, operations)" }, { "docstring": null, "function_declaration": "def process_test_cases(T, test_cases):", "function_name": "process_test...
[ 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 remove_crates(N, M, operations):\n # Initialize the grid with each cell having one crate.\n grid = [[1 for _ in range(M)] for _ in range(N)]\n\n # App...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073935", "row_id": 73935, "seed_ids": "[17205]" }
0.654808
Taco_73935
I
[ "apply_operations", "process_test_cases", "solution" ]
3
[ [ "process_test_cases", "apply_operations" ], [ "solution", "process_test_cases" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
false
[]
true
fe0a8bdc274281d6e37535e35a937abcd509b9e9
52e6b0a39984f46929d6403e1422f1c4cd12e510
v1.0
instruct
Taco
Taco_73955_I
Genos has decided to create his own team of powerful robots. To manage the team efficiently, he needs to maintain the skill levels of the robots and respond to queries about the total skill levels of robots within specific ranges quickly. Given the number of robots and their initial skill levels, Genos will perform two...
class SegmentTree: def __init__(self, data): self.n = len(data) self.data = data[:] self.tree = [0] * (2 * self.n) self.build() def build(self): # Initialize leaves for i in range(self.n): self.tree[self.n + i] = self.data[i] # Build the t...
def test_generic_case(): input_data = """5 4 1 2 3 4 5 2 1 3 1 2 6 2 1 3 2 2 5 """ output_data = """6 10 18""" assert genos_robot_team(input_data) == output_data def test_all_updates(): input_data = """3 3 1 2 3 1 1 10 1 2 20 1 3 30""" output_data = "" # No range queries, so no output assert g...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class FenwickTree:\n def __init__(self, size):\n self.size = size\n self.tree = [0] * (size + 1)\n\n def update(self, index, delta):\n w...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00073955", "row_id": 73955, "seed_ids": "[4981]" }
0.550527
Taco_73955
I
[ "handle_operations", "process_input", "genos_robot_team" ]
3
[ [ "genos_robot_team", "handle_operations" ], [ "genos_robot_team", "process_input" ] ]
2
[ "process_input" ]
false
[ "SegmentTree" ]
true
pytest
false
[]
true
37ca555d77f2a07e286aca6c124b7348e09ff686
4e3d2303359abaffa0f553c50040c2f57a4acf73
v1.0
instruct
Taco
Taco_74010_I
Write a function that takes a list of numbers and returns the sum of all the numbers that are prime. If there are no prime numbers in the list, return the string "No prime numbers found." For instance: ``` sum_of_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) => 17 sum_of_primes([4, 6, 8, 10, 12]) => "No prime numbers foun...
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def sum_of_primes(numbers): """...
from solution import sum_of_primes def test_sum_of_primes_with_primes(): assert sum_of_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17 def test_sum_of_primes_with_no_primes(): assert sum_of_primes([4, 6, 8, 10, 12]) == "No prime numbers found" def test_sum_of_primes_all_primes(): assert sum_of_primes([13, ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sums all the prime numbers in the provided list.\nReturns the sum or \"No prime numbers found\" if there are no primes.", "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074010", "row_id": 74010, "seed_ids": "[10568]" }
0.709473
Taco_74010
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5ae3bcc655fe232898f43c19c6d8afbcfcb83a32
e18d6aec655e38eeaf922b22539e2c76f53d68e8
v1.0
instruct
Taco
Taco_74049_I
In a gaming environment, there are a number of rectangular platforms. Each platform is defined by two coordinates: (X1, Y1) and (X2, Y2), which represent the bottom-left and top-right corners of the rectangle, respectively. A player is initially standing at a starting coordinate (Sx, Sy). The goal is to determine the m...
from collections import deque def min_platform_jumps(Sx, Sy, Tx, Ty, platforms): def is_adjacent_or_overlap(p1, p2): # p1 and p2 are platforms with structure (X1, Y1, X2, Y2) X1_1, Y1_1, X2_1, Y2_1 = p1 X1_2, Y1_2, X2_2, Y2_2 = p2 if X1_1 <= X2_2 and X2_1 >= X1_2 and (Y1_1 == Y2_2 o...
from solution import solve, parse_input def test_example_1(): input_str = '2\n0 0 10 10\n3\n0 0 2 2\n2 2 5 5\n5 5 10 10\n0 0 3 3\n3\n0 0 2 2\n5 5 7 7\n8 8 10 10\n' test_cases = parse_input(input_str) result = solve(test_cases) assert result == [2, -1] def test_no_valid_start_or_end(): input_s...
[ { "docstring": null, "function_declaration": "def min_platform_jumps(Sx, Sy, Tx, Ty, platforms):", "function_name": "min_platform_jumps", "parameter_list": "(Sx, Sy, Tx, Ty, platforms)" }, { "docstring": null, "function_declaration": "def solve(test_cases):", "function_name": "solve"...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef is_adjacent_or_overlapping(p1, p2):\n \"\"\"\n Check if two platforms p1 and p2 are adjacent or overlapping...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00074049", "row_id": 74049, "seed_ids": "[15413]" }
0.700184
Taco_74049
I
[ "min_platform_jumps", "solve", "parse_input", "print_output" ]
4
[ [ "solve", "min_platform_jumps" ] ]
1
[ "parse_input", "print_output" ]
false
[]
false
pytest
true
[]
true
e3e0c39307f6c1107a814e87201e2bfcd41136a9
78444064660064da84e54605711968f3ab577171
v1.0
instruct
Taco
Taco_74055_I
Mona is a software engineer at a tech firm. One of her tasks involves validating user input for a new feature. For this feature, users can input a string that must be a palindrome after removing at most one character. Mona needs to write a function to validate these strings efficiently. A string is a palindrome if it...
def can_be_palindrome_after_one_removal(s: str) -> bool: def is_palindrome_range(start, end): return all(s[i] == s[end - i + start] for i in range(start, (end + start) // 2 + 1)) left, right = 0, len(s) - 1 while left < right: if s[left] != s[right]: # Work out if either the de...
from solution import can_be_palindrome_after_one_removal, validate_strings_can_become_palindromes def test_can_be_palindrome_after_one_removal(): assert can_be_palindrome_after_one_removal("abca") == True assert can_be_palindrome_after_one_removal("racecar") == True assert can_be_palindrome_after_one_remov...
[ { "docstring": null, "function_declaration": "def can_be_palindrome_after_one_removal(s):", "function_name": "can_be_palindrome_after_one_removal", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def validate_strings_can_become_palindromes(T, strings):", "fun...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_be_palindrome(s):\n \"\"\"\n Check if the string can be a palindrome by removing at most one character.\n \"\"\"\n def is_palindrome_range(left...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074055", "row_id": 74055, "seed_ids": "[18235]" }
0.824815
Taco_74055
I
[ "can_be_palindrome_after_one_removal", "validate_strings_can_become_palindromes" ]
2
[ [ "validate_strings_can_become_palindromes", "can_be_palindrome_after_one_removal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
366930fcc8cc35e6f50c6d7734a6126e79f02063
3ed29a148886bb38c942d426695151a451fd8f5c
v1.0
instruct
Taco
Taco_74062_I
You are given a list of connections where each connection is a tuple of two integers representing a direct path between two cities. There are N cities labeled from 0 to N-1. You are also given a list of queries where each query is a tuple of two integers representing two cities. For each query, determine if there is a ...
def find_connected_components(n, connections): def dfs(node, component_id): stack = [node] while stack: curr = stack.pop() if components[curr] == -1: components[curr] = component_id for neighbor in adjacency_list[curr]: stac...
def test_are_cities_connected_basic(): n = 5 connections = [(0, 1), (1, 2), (2, 3), (3, 4)] queries = [(0, 4), (1, 3), (0, 5)] assert are_cities_connected(n, connections, queries) == ["Yes", "Yes", "No"] def test_are_cities_connected_single_connection(): n = 2 connections = [(0, 1)] queries...
[ { "docstring": null, "function_declaration": "def find_connected_components(n, connections):", "function_name": "find_connected_components", "parameter_list": "(n, connections)" }, { "docstring": null, "function_declaration": "def are_cities_connected(n, connections, queries):", "fun...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(x, parent):\n if parent[x] != x:\n parent[x] = find(parent[x], parent)\n return parent[x]\n\ndef union(x, y, parent, rank):\n rootX = find...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00074062", "row_id": 74062, "seed_ids": "[7041]" }
0.766602
Taco_74062
I
[ "find_connected_components", "are_cities_connected" ]
2
[ [ "are_cities_connected", "find_connected_components" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e0f30bf7f7099d7fae9b1248b374299aa8cced4f
c287f166fccfb42625b34c025fa8939f9e3c687b
v1.0
instruct
Taco
Taco_74106_I
You are a forest ranger tasked with monitoring wildlife in a large, rectangular forest. The forest is divided into a grid of cells, where each cell can either be empty or have an animal. Your goal is to make periodic reports about the distribution of animals in the forest. At any point, you may be asked to report the ...
def preprocess_forest(R, C, forest): # Create a 2D array to store cumulative sum dp = [[0] * (C + 1) for _ in range(R + 1)] # Fill the cumulative sum array for r in range(1, R + 1): for c in range(1, C + 1): dp[r][c] = (1 if forest[r - 1][c - 1] == 'A' else 0) + dp[r - 1][c] + d...
def test_preprocess_forest(): R, C = 5, 5 forest = [ ".....", ".....", ".A.A.", "..A..", "....." ] expected = [ [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 2, 2], [0, 0, 1, 2, 3, 3], [0, ...
[ { "docstring": null, "function_declaration": "def preprocess_forest(R, C, forest):", "function_name": "preprocess_forest", "parameter_list": "(R, C, forest)" }, { "docstring": null, "function_declaration": "def query_animals(dp, r1, c1, r2, c2):", "function_name": "query_animals", ...
[ 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 prepare_animal_count_matrix(forest, R, C):\n \"\"\"\n Prepare 2D prefix sum array for the animal counts in the forest grid.\n \"\"\"\n prefix_sum =...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074106", "row_id": 74106, "seed_ids": "[11646]" }
0.670847
Taco_74106
I
[ "preprocess_forest", "query_animals", "forest_animals" ]
3
[ [ "forest_animals", "preprocess_forest" ], [ "forest_animals", "query_animals" ] ]
2
[]
false
[]
false
pytest
false
[]
true
d5fd35ebacfa21dd73087d1068520081f2634697
7b04bcb726fd61710f2b92da893d975b793a93d6
v1.0
instruct
Taco
Taco_74120_I
Given an undirected graph with N nodes and M edges, you need to find if there exists a path between two given nodes u and v that passes through exactly k nodes. A valid path is defined as a sequence of nodes starting from node u, ending at node v, and with the length of the path being exactly k nodes long (including ...
from collections import deque, defaultdict def find_exact_path(n, edges, queries): graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) def bfs(u, distance, target_distance, target): queue = deque([(u, 1)]) visited = set() while queue: ...
from solution import find_exact_path, process_graph_query # Test helper functions def test_helper_bfs(): edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [3, 6]] queries = [(1, 4, 4), (1, 6, 2), (2, 5, 3)] expected = ["Yes", "Yes", "No"] assert find_exact_path(6, edges, queries) == expected de...
[ { "docstring": null, "function_declaration": "def find_exact_path(n, edges, queries):", "function_name": "find_exact_path", "parameter_list": "(n, edges, queries)" }, { "docstring": null, "function_declaration": "def process_graph_query(n, m, edge_list, q, query_list):", "function_na...
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bfs_path_exact_k(adjacency_list, start, end, k):\n from collections import deque\n \n queue = deque([(start, 1)]) # (current_node, current_depth)\n ...
trial_gpt4o_7
{ "original_instruction": "", "prompt_id": "00074120", "row_id": 74120, "seed_ids": "[14181]" }
0.72538
Taco_74120
I
[ "find_exact_path", "process_graph_query" ]
2
[ [ "process_graph_query", "find_exact_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
363742e23ae68af9e4d9ef9920f8f622741ef392
5ac008790ff476ac893ab102b10521cd7717fe7d
v1.0
instruct
Taco
Taco_74213_I
Julia and her friends have a unique way of sending secret messages to each other. Each message is divided into segments, and each segment contains a non-negative integer. They enjoy decoding messages by rearranging the segments based on specific rules. You are given a message as a list of non-negative integers. Julia ...
def sum_of_digits(n): return sum(int(d) for d in str(n)) def count_rearrangements(k, segments): MOD = 10**9 + 7 # Count segments by sum of digits % 3 category count_0 = 0 count_1 = 0 count_2 = 0 for segment in segments: sum_digits = sum_of_digits(segment) if sum_digits ...
from solution import count_rearrangements def test_example1(): assert count_rearrangements(3, [123, 456, 789]) == 6 def test_example2(): assert count_rearrangements(4, [111, 222, 333, 444]) == 24 def test_single_segment(): assert count_rearrangements(1, [123]) == 1 def test_all_zeroes(): assert coun...
[ { "docstring": null, "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_rearrangements(k, segments):", "function_name": "count_rearrangements", "parameter_list": "(k...
[ 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": "MOD = 10**9 + 7\n\ndef digit_sum(n):\n \"\"\"\n Returns the sum of digits of the integer n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\nde...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074213", "row_id": 74213, "seed_ids": "[17979]" }
0.600238
Taco_74213
I
[ "sum_of_digits", "count_rearrangements" ]
2
[ [ "count_rearrangements", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
385557a27111ab3afc6420d76f2943fbbe361f64
9bb90702451a554c70bd6059eea92d6e91ffb61d
v1.0
instruct
Taco
Taco_74227_I
You are given a grid representing a maze where some cells are passable and some are walls. Your task is to determine the shortest path from the start cell to the target cell. The maze is defined by a matrix with 0's and 1's — 0 represents a passable cell and 1 represents a wall. You can move up, down, left, or right fr...
from collections import deque def shortest_path_maze(n, m, maze, x1, y1, x2, y2): """ Returns the length of the shortest path from the start cell (x1, y1) to the target cell (x2, y2) in the maze. """ if (x1, y1) == (x2, y2): return 0 # Directions for moving up, down, left, right di...
import pytest from solution import solve_maze_problem def test_shortest_path_example(): n, m = 5, 5 grid_data = [ "0 1 0 0 0", "0 1 0 1 0", "0 0 0 1 0", "0 1 0 1 0", "0 0 0 0 0" ] start_x, start_y = 0, 0 target_x, target_y = 4, 4 assert solve_maze_problem...
[ { "docstring": "Returns the length of the shortest path from the start cell (x1, y1) to the target cell (x2, y2) in the maze.", "function_declaration": "def shortest_path_maze(n, m, maze, x1, y1, x2, y2):", "function_name": "shortest_path_maze", "parameter_list": "(n, m, maze, x1, y1, x2, y2)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_maze(n, m, maze, x1, y1, x2, y2):\n \"\"\"\n Returns the length of the shortest path from (x1, y1) to (...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074227", "row_id": 74227, "seed_ids": "[16509]" }
0.749008
Taco_74227
I
[ "shortest_path_maze", "solve_maze_problem" ]
2
[ [ "solve_maze_problem", "shortest_path_maze" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb3016c8ce1640af524e7d305fb036dba9caed73
0e67c1cc741856add42ffc23b34fd361151d45fe
v1.0
instruct
Taco
Taco_74231_I
In a distant land, cities are connected by roads. The government has decided to upgrade the roads to attract tourists. Each road has a cost associated with upgrading it. The government wants to upgrade a subset of these roads such that every city is reachable from any other city (a connected network), and the total cos...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if xroot != yroot: if rank[xroot] < rank[yroot]: parent[xroot] = yr...
def test_minimum_upgrade_cost(): assert minimum_upgrade_cost(4, 4, [(1, 2, 1), (2, 3, 4), (3, 4, 3), (1, 4, 5)]) == 8 assert minimum_upgrade_cost(4, 2, [(1, 2, 3), (3, 4, 2)]) == -1 assert minimum_upgrade_cost(5, 6, [(1, 2, 2), (1, 3, 2), (3, 4, 3), (4, 5, 1), (2, 3, 4), (1, 4, 3)]) == 8 assert minimum_...
[ { "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 else:\n parent[i] = find(parent, parent[i])\n return parent[i]\n\ndef union(paren...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00074231", "row_id": 74231, "seed_ids": "[23460]" }
0.769415
Taco_74231
I
[ "find", "union", "kruskal", "minimum_upgrade_cost" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_upgrade_cost", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
596a76ffdf1d3e23d8773ab2b99d6397893ee526
ba1d019aefb9ce5676f49b0a8587dbddd89d2e93
v1.0
instruct
Taco
Taco_74264_I
Alice has a number in her mind and loves experimenting with its properties. She has recently become fascinated with palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. For example, 121 and 1331 are palindromic numbers. Alice is curious about the smallest palindromi...
def is_palindrome(num): """ Returns True if num is a palindromic number, False otherwise. """ return str(num) == str(num)[::-1] def next_palindrome(n): """ Given an integer n, returns the smallest palindromic number greater than n. """ n += 1 while not is_palindrome(n): n +=...
from solution import next_palindrome def test_next_palindrome(): assert next_palindrome(123) == 131 assert next_palindrome(808) == 818 assert next_palindrome(1) == 2 assert next_palindrome(10) == 11 assert next_palindrome(99) == 101 assert next_palindrome(12321) == 12421 assert next_palindr...
[ { "docstring": "Returns True if num is a palindromic number, False otherwise.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Given an integer n, returns the smallest palindromic number greater than n.", ...
[ 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 next_palindromic_number(n):\n \"\"\"\n Returns the smallest palindromic number greater than n.\n \"\"\"\n def is_palindrome(num):\n return s...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074264", "row_id": 74264, "seed_ids": "[2294]" }
0.833253
Taco_74264
I
[ "is_palindrome", "next_palindrome" ]
2
[ [ "next_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
36b09b316e4a8318760e5071607fad321d3654c5
11ecc6d758db05c3dfa5b7ac79235e2dd0367a20
v1.0
instruct
Taco
Taco_74266_I
## Task There is a 3D grid of dimensions \(N \times M \times L\). Each cell in the grid can be either empty (`.`) or blocked (`#`). Your task is to determine the length of the shortest path from the starting cell to the target cell. You can move to adjacent cells in the grid, i.e., left, right, forward, backward, up, a...
from collections import deque def is_valid(x, y, z, N, M, L, grid, visited): return 0 <= x < N and 0 <= y < M and 0 <= z < L and grid[x][y][z] == '.' and not visited[x][y][z] def shortest_path(grid, N, M, L, start, target): directions = [(1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, -1, 0), (0, 0, 1), (0, 0, -1)] ...
import pytest from solution import shortest_path def test_shortest_path_simple(): N, M, L = 3, 3, 3 grid = [ [['.','.','.'],['#','.','#'],['.','.','.']], [['.','.','.'],['#','.','#'],['.','.','.']], [['.','.','.'],['#','.','#'],['.','.','.']] ] start = (0, 0, 0) target = (2,...
[ { "docstring": null, "function_declaration": "def is_valid(x, y, z, N, M, L, grid, visited):", "function_name": "is_valid", "parameter_list": "(x, y, z, N, M, L, grid, visited)" }, { "docstring": null, "function_declaration": "def shortest_path(grid, N, M, L, start, target):", "funct...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(grid, N, M, L, start, target):\n \"\"\"\n Returns the length of the shortest path from start to target in ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074266", "row_id": 74266, "seed_ids": "[17808]" }
0.695766
Taco_74266
I
[ "is_valid", "shortest_path" ]
2
[ [ "shortest_path", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21aaf283ce5218645070eec3427043eda41288fd
95a0fa7ae0c1c67bf3c9c59a02cf7432dbabed7c
v1.0
instruct
Taco
Taco_74308_I
A warehouse manager needs an efficient way to manage incoming shipments and store them in the warehouse. The warehouse can be visualized as a 2D grid of cells, where each cell either contains goods or is empty. A shipment consists of multiple containers, each of which requires a certain number of cells for storage. The...
def parse_input(input_str): """ Parses the input string and returns a list of test cases. Each test case is a tuple containing: - the grid (2D list) - the list of container lengths """ lines = input_str.strip().split('\n') cases = [] i = 0 while i < len(lines): if lines[i...
def test_parse_input(): input_str = "4 4\n....\n....\n....\n....\n3\n3\n2\n2\n3 3\n..#\n.#.\n..#\n1\n3\n3 3\n..#\n.#.\n..#\n1\n4\n0\n" expected_output = [ ([['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']], [3, 2, 2]), ([['.', '.', '#'], ['.', '#', '.'], ['...
[ { "docstring": "Parses the input string and returns a list of test cases.\nEach test case is a tuple containing:\n- the grid (2D list)\n- the list of container lengths", "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(input_str)" }, { ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_place_horizontally(grid, row, col, length):\n if col + length > len(grid[0]):\n return False\n for c in range(col, col + length):\n if ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00074308", "row_id": 74308, "seed_ids": "[21603]" }
0.685789
Taco_74308
I
[ "parse_input", "find_max_cells_used", "optimal_placement" ]
3
[ [ "optimal_placement", "find_max_cells_used" ], [ "optimal_placement", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
20729439f0aa58a87624252b9b610240ba205dad
a3a6a0a9c17cf0fe7936b30bd8b19ef2d9975c27
v1.0
instruct
Taco
Taco_74340_I
You are given a matrix of size MxN filled with the integers from 1 to MxN in a spiral order. Your task is to determine if there exists a contiguous subarray that, when flattened into a single row, forms a bitonic sequence. A sequence is called bitonic if it first strictly increases and then strictly decreases. Constra...
def is_bitonic_sequence(arr): """ Check if a given array forms a bitonic sequence. """ n = len(arr) if n < 3: return False increasing = True # Find the peak point for i in range(1, n): if increasing: if arr[i] <= arr[i - 1]: increasing = False ...
def test_is_bitonic_sequence(): assert is_bitonic_sequence([1, 2, 3, 2, 1]) == True assert is_bitonic_sequence([1, 3, 2]) == True assert is_bitonic_sequence([1, 2, 3, 4]) == False assert is_bitonic_sequence([4, 2, 1]) == False assert is_bitonic_sequence([1, 1, 2, 3]) == False def test_is_bitonic_su...
[ { "docstring": "Check if a given array forms a bitonic sequence.", "function_declaration": "def is_bitonic_sequence(arr):", "function_name": "is_bitonic_sequence", "parameter_list": "(arr)" }, { "docstring": "Determines if there exists a contiguous subarray that, when flattened into a single...
[ 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 generate_spiral_matrix(M, N):\n spiral_matrix = [[0] * N for _ in range(M)]\n num = 1\n left, right = 0, N - 1\n top, bottom = 0, M - 1\n\n whil...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00074340", "row_id": 74340, "seed_ids": "[18074]" }
0.600416
Taco_74340
I
[ "is_bitonic_sequence", "is_spiral_bitonic_sequence_exists", "is_bitonic_subarray_exists" ]
3
[ [ "is_bitonic_subarray_exists", "is_spiral_bitonic_sequence_exists" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4d89a093444ea90afe8f8b2115cd705916678d2f
fe90c43f9ded8682e95547d89455a94838b1683d
v1.0
instruct
Taco
Taco_74376_I
You are given a binary tree with N nodes. Each node has a distinct integer value. You are also given Q queries of the following types: - \texttt{1 v x}: Given node v (1 ≤ v ≤ N) and integer x, add the value x to the value of node v. - \texttt{2 v}: Given node v (1 ≤ v ≤ N), compute and print the sum of the values of a...
class TreeNode: def __init__(self, value=0): self.value = value self.children = [] def add_value_to_node(tree, node_id, value): tree[node_id].value += value def sum_subtree(tree, node_id): def dfs_sum(node): total = node.value for child in node.children: total +...
def test_process_queries(): n = 5 values = [1, 2, 3, 4, 5] edges = [(1, 2), (1, 3), (2, 4), (2, 5)] queries = [(2, 1), (1, 3, 5), (2, 1)] assert process_queries(n, values, edges, queries) == [15, 20] def test_process_queries_single_node(): n = 1 values = [10] edges = [] queries = [(...
[]
[ 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):\n self.val = val\n self.children = []\n self.subtree_sum = val\n\ndef build_tree(n, values, ed...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074376", "row_id": 74376, "seed_ids": "[9629]" }
0.736799
Taco_74376
I
[ "add_value_to_node", "sum_subtree", "create_tree", "process_queries" ]
4
[ [ "process_queries", "add_value_to_node" ], [ "process_queries", "create_tree" ], [ "process_queries", "sum_subtree" ] ]
3
[ "process_queries" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
8e731c05a7c3b84d9461afe1c26fbeb209a39e4c
427331f67b9e6215a87584469008001042d394e3
v1.0
instruct
Taco
Taco_74414_I
Sara has a unique lock mechanism that requires a code to be cracked in order to open it. The lock is designed in a way that it only opens if the sum of digits of a given number is a prime number. You need to write a code that helps Sara determine if the lock will open for a given number or not. Input The first input l...
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import is_prime, sum_of_digits, will_lock_open, process_cases def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(20) == False def test_sum_of_digits(): assert sum_of_digits(123) == 6 ...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of digits of the number n.", "function_declaration": "def sum_of_digits(n):", "function_name": "s...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074414", "row_id": 74414, "seed_ids": "[6000]" }
0.598111
Taco_74414
I
[ "is_prime", "sum_of_digits", "will_lock_open", "process_cases" ]
4
[ [ "process_cases", "will_lock_open" ], [ "will_lock_open", "is_prime" ], [ "will_lock_open", "sum_of_digits" ] ]
3
[ "process_cases" ]
false
[]
false
pytest
true
[]
true
776f519b2ff26b3f637331191cc154ed4e8c44b9
537155347b25a9a3e015a648b95dc505c9eb99c3
v1.0
instruct
Taco
Taco_74416_I
Develop a program that calculates the maximum possible sum of a contiguous subarray within a given array of integers. ------ Input Format ------ - The first line contains an integer T, the number of test cases. - Each of the next T pairs of lines: - The first line contains an integer N, the length of the array. ...
def max_subarray_sum(arr): """ Returns the maximum possible sum of a contiguous subarray within the given array. """ max_sum = float('-inf') current_sum = 0 for num in arr: current_sum = max(num, current_sum + num) max_sum = max(max_sum, current_sum) return max_sum ...
from solution import max_subarray_sum, solve, parse_input def test_single_positive_array(): assert max_subarray_sum([1, 2, 3, 4]) == 10 def test_single_mixed_array(): assert max_subarray_sum([1, -2, 3, 4]) == 7 def test_single_negative_array(): assert max_subarray_sum([-1, -2, -3, -4]) == -1 def test_si...
[ { "docstring": "Returns the maximum possible sum of a contiguous subarray within the given array.", "function_declaration": "def max_subarray_sum(arr):", "function_name": "max_subarray_sum", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def solve(test_cases):...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Returns the maximum possible sum of a contiguous subarray within the given array.\n \"\"\"\n max_sum = float('-in...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00074416", "row_id": 74416, "seed_ids": "[4658]" }
0.807837
Taco_74416
I
[ "max_subarray_sum", "solve", "parse_input" ]
3
[ [ "solve", "max_subarray_sum" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
4635efc8dc8db31e5e8e634cf041e47beedbb842
71207ed04698be9479dd812a82cd577a89af9d4a
v1.0
instruct
Taco
Taco_74684_I
In a video game, a player controls a character on a 2D grid. The grid has $N$ rows and $M$ columns, and the character starts at the cell $(1, 1)$. The goal is to reach the cell $(N, M)$ by moving only up, down, left, or right, but there are some restrictions: - Some cells in the grid are blocked and cannot be entered....
def is_path_exists(grid, N, M): """ Determines if there is a path from the top-left corner (1, 1) to the bottom-right corner (N, M). :param grid: List[List[str]] - The grid representing the 2D grid with open ('.') and blocked ('#') cells :param N: int - Number of rows in the grid :param M: int - Nu...
def test_is_path_exists(): assert is_path_exists( [['.', '.', '.', '.', '.'], ['.', '#', '#', '#', '.'], ['.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.']], 5, 5) == "YES" assert is_path_exists( [['.', '#', '.'], ...
[ { "docstring": "Determines if there is a path from the top-left corner (1, 1) to the bottom-right corner (N, M).\n\n:param grid: List[List[str]] - The grid representing the 2D grid with open ('.') and blocked ('#') cells\n:param N: int - Number of rows in the grid\n:param M: int - Number of columns in the grid\...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_path_exists(N, M, grid):\n from collections import deque\n \n def is_valid(x, y):\n return 0 <= x < N and 0 <= y < M and grid[x][y] == '.'\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074684", "row_id": 74684, "seed_ids": "[619]" }
0.776705
Taco_74684
I
[ "is_path_exists", "solve" ]
2
[ [ "solve", "is_path_exists" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c2ea435c24cc1c127d006c87c2ca238df15ad20e
31bf6bb13945b1774b34bec03f2a65eadf12c568
v1.0
instruct
Taco
Taco_74686_I
Problem You are given a box of chocolates arranged in a grid of size r x c and a list of queries. Each chocolate piece in the grid has a sweetness value, and each query asks you to find the sum of the sweetness values in a subgrid defined by its corners. To be more specific, each query is defined by four integers r1,...
def preprocess_grid(grid): """ Preprocess the grid to create a prefix sum array. """ r = len(grid) c = len(grid[0]) prefix_sum = [[0] * (c + 1) for _ in range(r + 1)] for i in range(1, r + 1): for j in range(1, c + 1): prefix_sum[i][j] = grid[i-1][j-1] + prefix_sum[i...
def test_preprocess_grid(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] assert preprocess_grid(grid) == expected_prefix_sum def test_sum_in_subgrid(): pre...
[ { "docstring": "Preprocess the grid to create a prefix sum array.", "function_declaration": "def preprocess_grid(grid):", "function_name": "preprocess_grid", "parameter_list": "(grid)" }, { "docstring": "Calculate the sum of the subgrid using the prefix sum array.", "function_declaration...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def precompute_prefix_sums(grid, r, c):\n \"\"\"\n Precomputes the prefix sums of the grid.\n \"\"\"\n prefix_sums = [[0] * (c + 1) for _ in range(r + ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074686", "row_id": 74686, "seed_ids": "[21857]" }
0.624649
Taco_74686
I
[ "preprocess_grid", "sum_in_subgrid", "chocolate_sum_queries" ]
3
[ [ "chocolate_sum_queries", "preprocess_grid" ], [ "chocolate_sum_queries", "sum_in_subgrid" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3f9c5a04c8face335cf43c215267533c702bd542
7a37dda51835afd579fb794b234f8dfe0e96ab80
v1.0
instruct
Taco
Taco_74695_I
Problem Statement You have been tasked with developing a new software feature for a professional scheduling application. The feature allows users to set reminders for important dates and events. One critical aspect of your implementation is to handle various date formats from different users. Given a list of dates in...
from datetime import datetime # We will use different formats to parse the different types of date strings FORMATS = [ '%Y-%m-%d', # YYYY-MM-DD '%d-%m-%Y', # DD-MM-YYYY '%B %d, %Y' # Month DD, YYYY ] def parse_date(date_str): """ Parses a date string into a datetime object....
from solution import sort_dates def test_sort_dates_format1(): dates = [ '2023-01-15', '2021-12-01', '2022-06-30', '2021-01-15' ] result = sort_dates(dates) expected = ['2021-01-15', '2021-12-01', '2022-06-30', '2023-01-15'] assert result == expected def test_sort_d...
[ { "docstring": "Parses a date string into a datetime object.", "function_declaration": "def parse_date(date_str):", "function_name": "parse_date", "parameter_list": "(date_str)" }, { "docstring": "Takes a list of date strings, parses them, and returns a list of dates in 'YYYY-MM-DD' format."...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef parse_date(date_str):\n formats = [\"%Y-%m-%d\", \"%d-%m-%Y\", \"%B %d, %Y\"]\n for fmt in formats:\n try:\n ...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00074695", "row_id": 74695, "seed_ids": "[22027]" }
0.61684
Taco_74695
I
[ "parse_date", "sort_dates" ]
2
[ [ "sort_dates", "parse_date" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fcb3ca0c81d16f88d6a6362293429b7bfa122435
0598df42a3810e738347faebdf4740583124e1eb
v1.0
instruct
Taco
Taco_74705_I
You are given a string $\textbf{S}$. Your task is to print all possible substrings of the string $\textbf{S}$ in lexicographic sorted order. Input Format A single line containing the string $\textbf{S}$. Constraints $1 \leq \text{len}(S) \leq 10$ The string contains only lowercase English letters. Output Format ...
def sorted_substrings(S): """ Returns all possible substrings of the string S in lexicographic sorted order. """ substrings = set() n = len(S) for i in range(n): for j in range(i + 1, n + 1): substrings.add(S[i:j]) return sorted(substrings) def print_sorted_substrings(S)...
from solution import sorted_substrings, print_sorted_substrings import io import pytest import sys def test_sorted_substrings(): assert sorted_substrings("bcda") == ['a', 'b', 'bc', 'bcd', 'bcda', 'c', 'cd', 'cda', 'd', 'da'] assert sorted_substrings("abc") == ['a', 'ab', 'abc', 'b', 'bc', 'c'] assert sort...
[ { "docstring": "Returns all possible substrings of the string S in lexicographic sorted order.", "function_declaration": "def sorted_substrings(S):", "function_name": "sorted_substrings", "parameter_list": "(S)" }, { "docstring": "Print all possible substrings of the string S in lexicographi...
[ 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 get_lexicographic_substrings(s):\n \"\"\"\n Returns all possible substrings of the string s in lexicographic sorted order.\n \n :param s: A single ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074705", "row_id": 74705, "seed_ids": "[19485]" }
0.720792
Taco_74705
I
[ "sorted_substrings", "print_sorted_substrings" ]
2
[ [ "print_sorted_substrings", "sorted_substrings" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a540a1f4a43ef119ccf0ec767a754fbb4173edad
cf90f565bf7ddb03d379cbc98a7411d7e3516ace
v1.0
instruct
Taco
Taco_74750_I
A car dealership has a list of prices for vehicles in their inventory. The management wants to run some promotional offers, and they wish to determine the total value of cars within specific price ranges. To assist them, you need to write a program to process multiple queries regarding the cumulative value of cars with...
def total_car_value_in_range(test_cases): results = [] for case in test_cases: N, Q, car_prices, queries = case['N'], case['Q'], case['car_prices'], case['queries'] prefix_sum = [0] * (N + 1) # Compute prefix sums for car prices for i in range(1, N + 1): ...
def test_solver_case_1(): test_cases = [ { "N": 5, "Q": 3, "car_prices": [10000, 20000, 30000, 40000, 50000], "queries": [(15000, 35000), (5000, 25000), (20000, 60000)] } ] expected_output = [[50000, 30000, 140000]] assert total_car_value_i...
[ { "docstring": null, "function_declaration": "def total_car_value_in_range(test_cases):", "function_name": "total_car_value_in_range", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def find_lower_bound(car_prices, L):", "function_name": "find_lower...
[ 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 total_value_in_price_ranges(test_cases):\n results = []\n \n for test in test_cases:\n N, Q, prices, queries = test\n prices.sort()\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074750", "row_id": 74750, "seed_ids": "[14952]" }
0.655702
Taco_74750
I
[ "total_car_value_in_range", "find_lower_bound", "find_upper_bound" ]
3
[ [ "total_car_value_in_range", "find_lower_bound" ], [ "total_car_value_in_range", "find_upper_bound" ] ]
2
[]
false
[]
false
pytest
false
[]
true
00cb1bd9b51bbacc21fe2e5cf63110f16d99b931
28b4703300a88e73c0158b4510bb5bf0e056dbef
v1.0
instruct
Taco
Taco_74762_I
Given an integer n, return a list of all possible palindromic decompositions of n. A palindromic decomposition of n is a list of strings, where each string is a palindrome and the concatenation of all the strings is equal to n. Example 1: Input: n = 121 Output: [["1","2","1"], ["121"]] Example 2: Input: n = 1221 Out...
def is_palindrome(s): return s == s[::-1] def palindromic_decomposition(n): s = str(n) results = [] def helper(start, path): if start == len(s): results.append(path[:]) return for end in range(start + 1, len(s) + 1): part = s[start:end] i...
from solution import palindromic_decomposition def test_palindromic_decomposition_example_1(): assert palindromic_decomposition(121) == [["1","2","1"], ["121"]] def test_palindromic_decomposition_example_2(): assert palindromic_decomposition(1221) == [["1","2","2","1"], ["1", "22", "1"], ["1221"]] def test_p...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def palindromic_decomposition(n):", "function_name": "palindromic_decomposition", "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_palindrome(s):\n \"\"\"\n Check if a string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindromic_decomposition(n):\n \"\"\"\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074762", "row_id": 74762, "seed_ids": "[16640]" }
0.680142
Taco_74762
I
[ "is_palindrome", "palindromic_decomposition" ]
2
[ [ "palindromic_decomposition", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec2ac3bcdff85b2ce2d703f70d7a4f073f5a9552
cea68ba31c433366708f107061f471a2adf60c8b
v1.0
instruct
Taco
Taco_74772_I
## Task Alex is a fan of both music and coding. He has a playlist of songs, each represented as a string of note names (like "A", "B", "C", "D", "E", "F", "G"). Alex considers a song beautiful if, for every note in the song, the note in the next position is either the same, exactly one step up, or exactly one step down...
def is_beautiful_song(song): """ Determines if a song is beautiful based on the given criteria. """ for i in range(len(song) - 1): if abs(ord(song[i]) - ord(song[i + 1])) > 1: return False return True def beautiful_playlist(playlist): """ Determines if each song in the p...
from solution import beautiful_playlist def test_beautiful_playlist(): assert beautiful_playlist(["ABC", "BAB", "AC"]) == [True, True, False] assert beautiful_playlist(["A", "BB", "CCC"]) == [True, True, True] assert beautiful_playlist(["CBA", "ABC", "BAD"]) == [True, True, False] assert beautiful_play...
[ { "docstring": "Determines if a song is beautiful based on the given criteria.", "function_declaration": "def is_beautiful_song(song):", "function_name": "is_beautiful_song", "parameter_list": "(song)" }, { "docstring": "Determines if each song in the playlist is beautiful.", "function_d...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_beautiful_song(song):\n \"\"\"\n Determines if a song is beautiful based on the given criteria.\n \"\"\"\n for i in range(len(song) - 1):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00074772", "row_id": 74772, "seed_ids": "[625]" }
0.615314
Taco_74772
I
[ "is_beautiful_song", "beautiful_playlist" ]
2
[ [ "beautiful_playlist", "is_beautiful_song" ] ]
1
[]
false
[]
false
pytest
true
[]
true
09dccfdcf13d4f36051b00444bc0b24757dad294
58e089cd983f1585895f2ddf8747fe6a80490009
v1.0
instruct
Taco
Taco_74830_I
In a remote town of the country Byteland, there lived a developer named Ben. He loved prime numbers and often tried to incorporate them into his work. One day, he came up with a new challenge for his friends: to find the closest prime numbers around a given number `x`. Specifically, he wanted to find the nearest prime ...
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 += 6 re...
from solution import closest_primes, is_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(11) == True def test_closest_primes(): assert closest_primes(10) == (7...
[ { "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 closest prime numbers around the given number x.", "function_declaration": "def closest_primes(...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n for i in range(3, int(n*...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074830", "row_id": 74830, "seed_ids": "[18577]" }
0.624989
Taco_74830
I
[ "is_prime", "closest_primes" ]
2
[ [ "closest_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8b4d902e8622b52d0aa46f950e5188352be3f4c7
d0d11fa96eeb0ae72d90d7acd66e4a6cc12876bb
v1.0
instruct
Taco
Taco_74868_I
Deepak loves prime numbers. He wants to find all pairs of primes $(p, q)$ such that $p < q$ and $p + q = n$ for a given number $n$. Could you help Deepak find all such pairs? -----Input----- The first line contains an integer $t$ ($1 \le t \le 10^3$) — the number of test cases. Each of the next $t$ lines contains a ...
def sieve_of_eratosthenes(max_num): is_prime = [True] * (max_num + 1) is_prime[0], is_prime[1] = False, False for start in range(2, int(max_num**0.5) + 1): if is_prime[start]: for multiple in range(start * start, max_num + 1, start): is_prime[multiple] = False return ...
from solution import sieve_of_eratosthenes, get_prime_pairs, find_prime_pairs def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(20) == [2, 3, 5, 7, 11, 13, 17, 19] assert sieve_of_eratosthenes(1) == [] assert sieve_of_eratosthenes(2) == [2] ...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": null, "function_declaration": "def get_prime_pairs(n, primes):", "function_name": "get_prime_pairs", "para...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve(limit):\n \"\"\" Use the Sieve of Eratosthenes to generate a list of primes up to 'limit' \"\"\"\n is_prime = [True] * (limit + 1)\n is_prime[0]...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00074868", "row_id": 74868, "seed_ids": "[12887]" }
0.731201
Taco_74868
I
[ "sieve_of_eratosthenes", "get_prime_pairs", "find_prime_pairs" ]
3
[ [ "find_prime_pairs", "get_prime_pairs" ], [ "find_prime_pairs", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9f5ad829180c0dceada2d404d768d475c73b7b94
3613db8944290d9ac376d2b43922efd1998aa291
v1.0
instruct
Taco
Taco_74886_I
Alice is learning about palindrome numbers - numbers that read the same forwards and backwards. She is fascinated by them and wants to find the smallest palindrome number that is greater than or equal to a given integer M. Additionally, to make it more interesting, she wants to ensure that the sum of the digits of this...
def is_palindrome(num): return str(num) == str(num)[::-1] def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def digit_sum(num): return sum(int(digit) for digit in str(num)) def smallest_palindrom...
from solution import smallest_palindrome_with_prime_digit_sum def test_example_case(): assert smallest_palindrome_with_prime_digit_sum(123) == 131 def test_smallest_palindrome_less_than_10(): assert smallest_palindrome_with_prime_digit_sum(1) == 2 def test_large_number(): assert smallest_palindrome_with_...
[ { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring...
[ 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(num):\n return str(num) == str(num)[::-1]\n\ndef is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00074886", "row_id": 74886, "seed_ids": "[12827]" }
0.728805
Taco_74886
I
[ "is_palindrome", "is_prime", "digit_sum", "smallest_palindrome_with_prime_digit_sum" ]
4
[ [ "smallest_palindrome_with_prime_digit_sum", "digit_sum" ], [ "smallest_palindrome_with_prime_digit_sum", "is_palindrome" ], [ "smallest_palindrome_with_prime_digit_sum", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
d462295f6321e707ca7525562bf9e564590535a2
5c0f9cd27dbdcc2b67efe0cfd24361ae7d0c3a0f
v1.0
instruct
Taco
Taco_74917_I
You are given a grid of `n x n` cells where each cell can be either empty or blocked. An empty cell is represented by `0`, and a blocked cell is represented by `1`. The task is to find the number of distinct paths from the top-left corner (0,0) to the bottom-right corner (n-1,n-1), where you can only move right or down...
def find_paths(grid): n = len(grid) if grid[0][0] == 1 or grid[n-1][n-1] == 1: return 0 dp = [[0] * n for _ in range(n)] dp[0][0] = 1 for i in range(n): for j in range(n): if grid[i][j] == 0: if i > 0: dp[i][j] += dp[i-1][j] ...
def test_find_paths(): grid1 = ["0 0 0", "0 1 0", "0 0 0"] assert num_paths(3, grid1) == 2 grid2 = ["0 1 0", "1 1 0", "0 0 0"] assert num_paths(3, grid2) == 0 grid3 = ["0 0 0 0", "0 1 1 0", "0 0 0 0", "1 1 0 0"] assert num_paths(4, grid3) == 3 grid4 = ["0 0 0", "0 1 1", "0 0 0...
[ { "docstring": null, "function_declaration": "def find_paths(grid):", "function_name": "find_paths", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def num_paths(n, grid_input):", "function_name": "num_paths", "parameter_list": "(n, grid_input)" } ]
[ 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 number_of_paths(n, grid):\n # If the starting or ending cell is blocked, return 0 as there are no paths\n if grid[0][0] == 1 or grid[n-1][n-1] == 1:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074917", "row_id": 74917, "seed_ids": "[15573]" }
0.803584
Taco_74917
I
[ "find_paths", "num_paths" ]
2
[ [ "num_paths", "find_paths" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b0bf0d7d0e8398fc6760062dfc5508fac77dc62d
55edcd14f0db74a7126c1213057ec8a52bb7cd6b
v1.0
instruct
Taco
Taco_74932_I
Little Arya and Little Bran love playing with strings. One day, they stumbled upon a very interesting problem involving strings and palindromes. They decided to challenge each other to solve this problem, and now you have to solve it for them. Given a string S, find the longest substring which is a palindrome. If the...
def longest_palindromic_substring(S): """ Function to find the longest palindromic substring in a given string S. """ n = len(S) if n == 0: return "" longest = "" for i in range(n): # Odd length palindromes tmp = expand_from_middle(S, i, i) if len(tmp) > len(...
from solution import find_longest_palindromes, longest_palindromic_substring def test_single_case(): assert longest_palindromic_substring('babad') == 'bab' or longest_palindromic_substring('babad') == 'aba' assert longest_palindromic_substring('cbbd') == 'bb' assert longest_palindromic_substring('aacecaaa'...
[ { "docstring": "Function to find the longest palindromic substring in a given string S.", "function_declaration": "def longest_palindromic_substring(S):", "function_name": "longest_palindromic_substring", "parameter_list": "(S)" }, { "docstring": "Helper function to expand from the middle an...
[ 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_palindromic_substring(s):\n \"\"\"\n Finds the longest palindromic substring in the given string s.\n \"\"\"\n n = len(s)\n longest_star...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00074932", "row_id": 74932, "seed_ids": "[543]" }
0.76527
Taco_74932
I
[ "longest_palindromic_substring", "expand_from_middle", "find_longest_palindromes" ]
3
[ [ "find_longest_palindromes", "longest_palindromic_substring" ], [ "longest_palindromic_substring", "expand_from_middle" ] ]
2
[]
false
[]
false
pytest
true
[]
true
486303ae2349bb4940ddd502e33342b8c370c623
d7000b6438dc67173afe0743a6b01b3bf70dd74e
v1.0
instruct
Taco
Taco_74953_I
You are an explorer trying to locate a rare artifact hidden in one of the rooms in an ancient temple. The temple has a number of rooms connected by a series of pathways. Each room is represented as a node in a graph, and each pathway between rooms is given as an edge with a certain length. The artifact is hidden in the...
import heapq from collections import defaultdict def dijkstra(n, pathways, start): graph = defaultdict(list) for u, v, w in pathways: graph[u].append((v, w)) graph[v].append((u, w)) distances = {i: float('inf') for i in range(n)} distances[start] = 0 pq = [(0, start)] while pq...
from solution import find_farthest_room def test_simple_case(): assert find_farthest_room(4, [[0, 1, 1], [1, 2, 2], [1, 3, 2]], 0) == (2, 3) def test_single_room(): assert find_farthest_room(1, [], 0) == (0, 0) def test_star_topology(): assert find_farthest_room(4, [[0, 1, 1], [0, 2, 1], [0, 3, 1]], 0) =...
[ { "docstring": null, "function_declaration": "def dijkstra(n, pathways, start):", "function_name": "dijkstra", "parameter_list": "(n, pathways, start)" }, { "docstring": null, "function_declaration": "def find_farthest_room(n, pathways, s):", "function_name": "find_farthest_room", ...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
2
hard
0.222
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom collections import defaultdict\n\ndef find_farthest_room(n, pathways, s):\n # Create an adjacency list\n graph = defaultdict(list)\n fo...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00074953", "row_id": 74953, "seed_ids": "[16859]" }
0.658035
Taco_74953
I
[ "dijkstra", "find_farthest_room" ]
2
[ [ "find_farthest_room", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd8573a54d4c7ae8369194a18b1bf96ad81f58ef
65152d9f1d802db20ae42d5d5343fdb3a501c4d1
v1.0
instruct
Taco
Taco_74972_I
Write a function that takes in a list of integers and returns a list containing only the prime numbers from the given list. For example: ``` Input: [2, 4, 7, 10, 13, 16] Output: [2, 7, 13] ``` The function should efficiently identify prime numbers by minimizing the number of operations.
def is_prime(n): """ Helper function to determine if a given number n 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...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True assert is_prime(17) == True assert is_prime(19) == True assert is_prime(20) == False def test_fi...
[ { "docstring": "Helper function to determine if a given number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def...
[ 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 Returns True if prime, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00074972", "row_id": 74972, "seed_ids": "[16412]" }
0.647978
Taco_74972
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
672d71b1fb5d722cdf6f7e846f7c8678ae833d18
3c07686cf3050ea74de4e6c5f86787c8a810349c
v1.0
instruct
Taco
Taco_75084_I
You are tasked with evaluating the performance of different sorting algorithms on a list of integers. Specifically, you need to implement and compare QuickSort and MergeSort. Write a program that reads a list of integers and outputs the sorted list using both QuickSort and MergeSort algorithms. Here are the constrai...
def quick_sort(arr): """ QuickSort algorithm implementation. """ if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quick_sort(left) + middle + quick...
def test_quick_sort_empty(): assert quick_sort([]) == [] def test_quick_sort_single_element(): assert quick_sort([1]) == [1] def test_quick_sort_multiple_elements(): assert quick_sort([3, -1, 4, 1, 5, 9]) == [-1, 1, 3, 4, 5, 9] def test_quick_sort_duplicates(): assert quick_sort([5, 4, 5, 4, 5]) == [...
[ { "docstring": "QuickSort algorithm implementation.", "function_declaration": "def quick_sort(arr):", "function_name": "quick_sort", "parameter_list": "(arr)" }, { "docstring": "MergeSort algorithm implementation.", "function_declaration": "def merge_sort(arr):", "function_name": "me...
[ 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 quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00075084", "row_id": 75084, "seed_ids": "[6612]" }
0.525302
Taco_75084
I
[ "quick_sort", "merge_sort", "sort_integers" ]
3
[ [ "sort_integers", "merge_sort" ], [ "sort_integers", "quick_sort" ] ]
2
[]
false
[]
false
pytest
false
[]
true
4862a4d906cb3d0a0cb7897c4424a7e523bdd6eb
16e84f1bcdb9b24661490b285446c7b0520eda4e
v1.0
instruct
Taco
Taco_75095_I
Haru has a list of integers and wants to classify each integer as either 'Good' or 'Bad'. An integer is considered 'Good' if the sum of its digits is a prime number. Otherwise, it is considered 'Bad'. -----Input----- Each test contains multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 10^4$)...
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 classify_number(x): digit_sum = sum(...
from solution import classify_number def test_good_number(): assert classify_number(29) == "Good" def test_bad_number(): assert classify_number(13) == "Bad" assert classify_number(40) == "Bad" def test_prime_digit_sum_edge_case(): assert classify_number(2) == "Good" assert classify_number(5) == "...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def classify_number(x):", "function_name": "classify_number", "parameter_list": "(x)" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2 or n == 3:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00075095", "row_id": 75095, "seed_ids": "[2905]" }
0.527026
Taco_75095
I
[ "is_prime", "classify_number" ]
2
[ [ "classify_number", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1eb59c2a735e47e86a1e71af19a05d9343508bdb
aa9ccbf68cb25a1493c64439834813014377b925
v1.0
instruct
Taco
Taco_75284_I
You are organizing a classic car exhibition and you need to plan the display area for the cars. The exhibit area is represented as a 2D grid of dimensions N x M. Some areas in the grid are occupied by obstacles where cars cannot be placed. You need to find the largest rectangular area in the grid that is free from obs...
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 = (histogram[...
from solution import max_rectangle_area def test_example_1(): N, M = 4, 5 grid = [ "00010", "00110", "00000", "11000" ] assert max_rectangle_area(grid, N, M) == 6 def test_example_2(): N, M = 3, 3 grid = [ "111", "111", "111" ] as...
[ { "docstring": null, "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def max_rectangle_area(grid, n, m):", "function_name": "max_rectangle_area", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix or not matrix[0]:\n return 0\n\n max_area = 0\n N, M = len(matrix), len(matrix[0])\n heights = [0]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075284", "row_id": 75284, "seed_ids": "[1914]" }
0.671161
Taco_75284
I
[ "max_histogram_area", "max_rectangle_area", "main" ]
3
[ [ "max_rectangle_area", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86b9a17ae3fcd3cec05971f8dfe79639b9c2ec2b
e8c68edfccc482b65be720aebc705bd8211a9168
v1.0
instruct
Taco
Taco_75295_I
During a treasure hunt, a team discovers an old map that provides encoded instructions to find the treasure. Each instruction is a string that consists of lowercase letters and digits. The team must decode the instructions to make any sense of them. The decoding rule is very simple: - Each lowercase letter should rema...
def decode_instruction(instruction): """ Decodes a single encoded instruction by doubling each digit. """ decoded = [] for char in instruction: if char.isdigit(): decoded.append(char * 2) else: decoded.append(char) return ''.join(decoded) def decode_instr...
from solution import decode_instruction, decode_instructions def test_decode_instruction(): assert decode_instruction("a2b4") == "a22b44" assert decode_instruction("z1x2c3") == "z11x22c33" assert decode_instruction("g9h") == "g99h" assert decode_instruction("abc") == "abc" assert decode_instruction...
[ { "docstring": "Decodes a single encoded instruction by doubling each digit.", "function_declaration": "def decode_instruction(instruction):", "function_name": "decode_instruction", "parameter_list": "(instruction)" }, { "docstring": "Decodes a list of encoded instructions.", "function_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 decode_instruction(instruction):\n \"\"\"\n Decode the given instruction string according to the rules:\n - Each lowercase letter remains unchanged.\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075295", "row_id": 75295, "seed_ids": "[1948]" }
0.657548
Taco_75295
I
[ "decode_instruction", "decode_instructions" ]
2
[ [ "decode_instructions", "decode_instruction" ] ]
1
[]
false
[]
false
pytest
true
[]
true
40a6ced8bffa3f78c108b4585864f02b3cd95ae8
90c35ecd703e71fd5c26fb5888c00c068f82e8e0
v1.0
instruct
Taco
Taco_75329_I
Alex is fascinated with palindromic numbers. A palindromic number reads the same backward as forward. For example, 121 is a palindrome, but 123 is not. Alex wants to find the smallest palindromic number that is greater than a given integer n. Given a positive integer n, write a function to find the smallest palindromi...
def is_palindrome(num): return str(num) == str(num)[::-1] def next_palindrome(n): n += 1 while not is_palindrome(n): n += 1 return n def find_next_palindromes(test_cases): results = [] for n in test_cases: results.append(next_palindrome(n)) return results
from solution import find_next_palindromes def test_find_next_palindromes_case1(): assert find_next_palindromes([123, 99, 678]) == [131, 101, 686] def test_find_next_palindromes_case2(): assert find_next_palindromes([1, 10, 21, 33, 88]) == [2, 11, 22, 44, 99] def test_find_next_palindromes_zero_case(): a...
[ { "docstring": null, "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def next_palindrome(n):", "function_name": "next_palindrome", "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 next_palindrome(n):\n \"\"\"\n Returns the smallest palindromic number greater than n.\n \"\"\"\n def is_palindrome(x):\n s = str(x)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075329", "row_id": 75329, "seed_ids": "[241]" }
0.82114
Taco_75329
I
[ "is_palindrome", "next_palindrome", "find_next_palindromes" ]
3
[ [ "find_next_palindromes", "next_palindrome" ], [ "next_palindrome", "is_palindrome" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6d01619558d95b89958af96a806fda17b3698419
bf2594bf91f1c92539790df1340feabde47d9536
v1.0
instruct
Taco
Taco_75340_I
You are given a list of `n` students, each with their respective marks in three subjects - Math, Science, and English. You need to find out if there exists a non-empty subsequence of these students such that: 1. The students in this subsequence have their marks sorted in increasing order in Math. 2. The students in thi...
def is_valid_subsequence(students): """ Function to check whether there exists a non-empty subsequence of students satisfying the given conditions. """ n = len(students) # Sort students overall on math marks as primary key, science marks as secondary key students.sort() # Chec...
from solution import check_subsequences_for_cases, read_input def test_basic_example(): input_data = """2 3 70 80 90 60 75 90 80 80 70 5 55 65 75 60 60 70 70 70 65 75 80 80 50 65 85""" expected_output = ["YES", "YES"] test_cases = read_input(input_data) assert check_subsequences_for_cases(test_cases) =...
[ { "docstring": "Function to check whether there exists a non-empty subsequence of students \nsatisfying the given conditions.", "function_declaration": "def is_valid_subsequence(students):", "function_name": "is_valid_subsequence", "parameter_list": "(students)" }, { "docstring": "Function t...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_subsequence(students):\n \"\"\"\n Function to check whether there exists a non-empty subsequence of students \n satisfying the given conditio...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00075340", "row_id": 75340, "seed_ids": "[5731]" }
0.707224
Taco_75340
I
[ "is_valid_subsequence", "check_subsequences_for_cases", "read_input" ]
3
[ [ "check_subsequences_for_cases", "is_valid_subsequence" ] ]
1
[ "read_input" ]
false
[]
false
pytest
true
[]
true
5c64e8a9644bf80474778d58658d78aea33dccf9
b5a313b0828bba39f22b29c825d1da7d5462e886
v1.0
instruct
Taco
Taco_75360_I
Your task is to write a function that will calculate the longest subsequence of numbers that are present in at least two different sequences from a given list of sequences. For example, suppose the input is as follows: ```python sequences = [ [1, 2, 3, 4, 5, 6], [5, 6, 7, 8, 9], [1, 2, 8, 9, 10] ] ``` In...
from typing import List def is_subsequence(small: List[int], large: List[int]) -> bool: """ Helper function to check if `small` is subsequence of `large`. """ it = iter(large) return all(elem in it for elem in small) def generate_all_subsequences(seq: List[int]) -> List[List[int]]: """ Hel...
from solution import longest_common_subsequence def test_longest_common_subsequence_general(): sequences = [ [1, 2, 3, 4, 5, 6], [5, 6, 7, 8, 9], [1, 2, 8, 9, 10] ] result = longest_common_subsequence(sequences) assert result == [5, 6] or result == [8, 9] def test_longest_commo...
[ { "docstring": "Helper function to check if `small` is subsequence of `large`.", "function_declaration": "def is_subsequence(small, large):", "function_name": "is_subsequence", "parameter_list": "(small, large)" }, { "docstring": "Helper function to generate all possible subsequences of a se...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_subsequence(shorter: List[int], longer: List[int]) -> bool:\n \"\"\"\n Helper function to determine if `shorter` is a subse...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075360", "row_id": 75360, "seed_ids": "[18279]" }
0.698122
Taco_75360
I
[ "is_subsequence", "generate_all_subsequences", "longest_common_subsequence" ]
3
[ [ "longest_common_subsequence", "generate_all_subsequences" ], [ "longest_common_subsequence", "is_subsequence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ec439f7335a977b7c08f743f3836a62b0b71b4c3
87a62618c25b75b022dff55c4f2e1aa2e952e3bc
v1.0
instruct
Taco
Taco_75437_I
Sam is a software developer who is fascinated by prime numbers. He wants to write a program that can determine the smallest prime number greater than a given integer n. Your task is to help Sam by writing a function that, given an integer n, returns the smallest prime number greater than n. Recall that a prime number ...
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...
from solution import is_prime, next_prime 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(15) == False def test_next_prime(): assert next_prime(17) == 19 assert next_prime(10) == 11 asser...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number greater than n.", "function_declaration": "def next_prime(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 \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075437", "row_id": 75437, "seed_ids": "[5420]" }
0.636664
Taco_75437
I
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c47fdaba56c5d6b26341794dc6baffd08a4fa6b5
36b9fcf3e51e51ce42a6f32fb306bcb7c333b217
v1.0
instruct
Taco
Taco_75464_I
Samantha is working as a software engineer and recently, she has been assigned a task to develop a simulation for a fictional game. In this game, there are several islands connected by bridges. Each bridge has a certain cost associated with crossing it. The game requires Samantha to find the minimum total cost to conn...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
from solution import minimum_cost_to_connect_islands def test_case_1(): T = 2 test_cases = [ (4, 5, [(1, 2, 1), (2, 3, 2), (3, 4, 4), (1, 3, 3), (1, 4, 5)]), (3, 1, [(1, 2, 1)]) ] assert minimum_cost_to_connect_islands(T, test_cases) == [7, -1] def test_single_island(): T = 1 t...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n rootX = find(parent, x)\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075464", "row_id": 75464, "seed_ids": "[5587]" }
0.76356
Taco_75464
I
[ "find", "union", "kruskal_mst", "minimum_cost_to_connect_islands" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimum_cost_to_connect_islands", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
ca10df8fc497588405eeda67bb06c93d9ed67586
a839bfec812194b7f34b072672b8b4e6ba7719ee
v1.0
instruct
Taco
Taco_75490_I
Write a function that takes a list of integers and returns the same list with all prime numbers replaced by the string "prime", and all multiples of 5 replaced by the string "five". If a number is both a prime and a multiple of 5, it should be replaced by the string "prime-five". For example, the input [2, 5, 10, 15, ...
def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def replace_primes_and_multiples_of_five(lst): if isinstance(lst, list) and all(isinstance(x, int) for x in lst): for i in range(len(lst)): ...
from solution import replace_primes_and_multiples_of_five def test_valid_input(): assert replace_primes_and_multiples_of_five([2, 5, 10, 15, 17, 20]) == ["prime", "prime-five", "five", "five", "prime", "five"] def test_empty_list(): assert replace_primes_and_multiples_of_five([]) == [] def test_non_prime_num...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def replace_primes_and_multiples_of_five(lst):", "function_name": "replace_primes_and_multiples_of_five", "parame...
[ 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 replace_primes_and_fives(lst):\n \"\"\"\n Replaces prime numbers with \"prime\", multiples of 5 with \"five\",\n and numbers that are both with \"prim...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075490", "row_id": 75490, "seed_ids": "[433]" }
0.655843
Taco_75490
I
[ "is_prime", "replace_primes_and_multiples_of_five" ]
2
[ [ "replace_primes_and_multiples_of_five", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e0310f4511ea29947b65f7f7db6c2c50e1d34d55
e05fec223e649fbc6a6bd3e54d7774efd067e846
v1.0
instruct
Taco
Taco_75507_I
A company wants to streamline its employee work schedules to maximize productivity. It has employees working different shifts, each represented by an interval [start, end]. Two employees are considered "overlapping" if their working intervals intersect. The goal is to find out the maximum number of overlapping employee...
def max_overlapping_employees(test_cases): results = [] for shifts in test_cases: time_points = [] for start, end in shifts: time_points.append((start, 'start')) time_points.append((end, 'end')) time_points.sort() max_overlaps = 0 ...
def test_max_overlapping_employees(): input_data = "2\n3\n1 4\n2 6\n8 10\n4\n1 2\n2 3\n3 4\n4 5" expected_output = "2\n1" assert run(input_data) == expected_output input_data = "1\n5\n1 5\n2 6\n4 8\n3 7\n8 10" expected_output = "4" assert run(input_data) == expected_output input_data = "2\...
[ { "docstring": null, "function_declaration": "def max_overlapping_employees(test_cases):", "function_name": "max_overlapping_employees", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_overlapping_employees(test_cases):\n results = []\n for shifts in test_cases:\n time_points = []\n for start, end in shifts:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00075507", "row_id": 75507, "seed_ids": "[3682]" }
0.760829
Taco_75507
I
[ "max_overlapping_employees", "parse_input", "prepare_output", "run" ]
4
[ [ "run", "max_overlapping_employees" ], [ "run", "parse_input" ], [ "run", "prepare_output" ] ]
3
[ "parse_input", "prepare_output" ]
false
[]
false
pytest
false
[]
true
eb573e41c4684117664f6111e1680cd10f9866b7
caf33ceaf494e2f495f79faa04c5a617284b825e
v1.0
instruct
Taco
Taco_75529_I
The Pandavas need to send coded messages back and forth during the war to strategize and foil the plans of the Kauravas. Yudhishthira comes up with an ingenious idea for encoding these messages. He decides that each message will be converted to a number based on a custom numbering system where each character is associa...
def factorize(n, primes): factors = [] for p in primes: while n % p == 0: factors.append(p) n //= p if n == 1: return factors return None def decode_message(messages, num, prime_map): primes = sorted(prime_map.values()) factors = factorize(num, primes) ...
from solution import decode_all_messages def test_sample_input1(): T = 2 inputs = [ 3, 'a 2', 'b 3', 'c 5', 30, 5, 'a 2', 'b 3', 'c 5', 'd 7', 'e 11', 77 ] expected = ['abc', 'de'] result = decode...
[ { "docstring": null, "function_declaration": "def factorize(n, primes):", "function_name": "factorize", "parameter_list": "(n, primes)" }, { "docstring": null, "function_declaration": "def decode_message(messages, num, prime_map):", "function_name": "decode_message", "parameter_l...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorize(n, primes):\n factors = []\n for p in primes:\n while n % p == 0:\n factors.append(p)\n n //= p\n if n == 1:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00075529", "row_id": 75529, "seed_ids": "[20460]" }
0.545681
Taco_75529
I
[ "factorize", "decode_message", "decode_all_messages" ]
3
[ [ "decode_all_messages", "decode_message" ], [ "decode_message", "factorize" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4b2661f12e974e5e5e953e8b635ce09d39e264a1
094af9200a62960d182788f813385d7e04a14dac
v1.0
instruct
Taco
Taco_75630_I
Write a program to find the first n integers that are relatively prime to a given integer m. Two integers are relatively prime if the greatest common divisor (GCD) of the two numbers is 1. Example 1: Input: n = 3, m = 10 Output: [1, 3, 7] Explanation: The first three integers that are relatively prime to 10 are 1, 3, ...
import math def is_relatively_prime(a, b): """ Check if two integers a and b are relatively prime. """ return math.gcd(a, b) == 1 def find_relatively_prime_numbers(n, m): """ Find the first n integers that are relatively prime to m. """ result = [] k = 1 while len(result) < n: ...
from solution import is_relatively_prime, find_relatively_prime_numbers def test_is_relatively_prime(): assert is_relatively_prime(1, 10) == True assert is_relatively_prime(3, 10) == True assert is_relatively_prime(2, 10) == False assert is_relatively_prime(7, 12) == True assert is_relatively_prime...
[ { "docstring": "Check if two integers a and b are relatively prime.", "function_declaration": "def is_relatively_prime(a, b):", "function_name": "is_relatively_prime", "parameter_list": "(a, b)" }, { "docstring": "Find the first n integers that are relatively prime to m.", "function_decl...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef relatively_prime_integers(n, m):\n \"\"\"\n Finds the first n integers that are relatively prime to m.\n \n :param n: Number of inte...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075630", "row_id": 75630, "seed_ids": "[8825]" }
0.613865
Taco_75630
I
[ "is_relatively_prime", "find_relatively_prime_numbers" ]
2
[ [ "find_relatively_prime_numbers", "is_relatively_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9f3abe28507a8f2e525a0f3d45f0876da2755dc4
13f6b3b28efcc460625ef653747b03d3e3d296b4
v1.0
instruct
Taco
Taco_75643_I
A group of friends is playing a word transformation game. The game involves transforming a starting word into a target word by changing one letter at a time, such that each intermediate word must also be a valid word from the given dictionary. Your task is to find the shortest transformation sequence, if it exists, fro...
from collections import deque def one_letter_diff(word1, word2): count = sum(1 for a, b in zip(word1, word2) if a != b) return count == 1 def word_transformation(start, target, dictionary): if start == target: return ("YES", [start]) dictionary = set(dictionary) if target not in ...
from solution import word_transformation def test_example_1(): start = "hit" target = "cog" dictionary = ["hot", "dot", "dog", "lot", "log", "cog"] assert word_transformation(start, target, dictionary) == ("YES", ['hit', 'hot', 'dot', 'dog', 'cog']) def test_example_2(): start = "hit" target =...
[ { "docstring": null, "function_declaration": "def one_letter_diff(word1, word2):", "function_name": "one_letter_diff", "parameter_list": "(word1, word2)" }, { "docstring": null, "function_declaration": "def word_transformation(start, target, dictionary):", "function_name": "word_tran...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef one_letter_diff(word1, word2):\n count = sum(1 for a, b in zip(word1, word2) if a != b)\n return count == 1\n\ndef word_...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00075643", "row_id": 75643, "seed_ids": "[8574]" }
0.660797
Taco_75643
I
[ "one_letter_diff", "word_transformation" ]
2
[ [ "word_transformation", "one_letter_diff" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0d766b2407b97ebcbecb7c8b78bae4734a7bab39
d53bfa21d231d3c2881c1abd101d88e11e5f9e63
v1.0
instruct
Taco
Taco_75687_I
Implement a function that generates all possible **palindromic partitions** of a given string. A palindrome is a string that reads the same backward as forward. For instance, for the string "aab", the palindromic partitions are ["a", "a", "b"], and ["aa", "b"]. 1. Your function should return a list of lists, where eac...
def is_palindrome(s): """ Check if a string is a palindrome. """ return s == s[::-1] def palindromic_partitions(s): """ Generate all possible palindromic partitions of the given string. :param s: input string containing only lowercase letters :return: list of lists, where each list...
from solution import palindromic_partitions def test_empty_string(): assert palindromic_partitions("") == [[]] def test_single_character(): assert palindromic_partitions("a") == [['a']] def test_two_characters(): assert palindromic_partitions("aa") == [['a', 'a'], ['aa']] assert palindromic_partition...
[ { "docstring": "Check if a string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Generate all possible palindromic partitions of the given string.\n\n:param s: input string containing only lower...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Check if a given string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindromic_partitions(s):\n \"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075687", "row_id": 75687, "seed_ids": "[7985]" }
0.704153
Taco_75687
I
[ "is_palindrome", "palindromic_partitions" ]
2
[ [ "palindromic_partitions", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e18d6667275d096b10566c33f376d522787ed217
9c766937d83a3879a3fbcacdc660dc48b145150a
v1.0
instruct
Taco
Taco_75696_I
Bozo is planning a journey through different cities and wants to know the minimum travel cost. He needs to travel from city A to city B. Given the direct travel costs between some pairs of cities, help Bozo determine the minimum cost to travel from city A to city B. Input:- The first line of the input will be an inte...
import heapq def dijkstra(n, graph, start, end): """ Finds the shortest path in a graph from start to end using Dijkstra's algorithm. :param n: Number of cities :param graph: Adjacency list of the graph where graph[u] is a list of (v, cost) pairs :param start: Starting city A :param end: Destin...
def test_dijkstra_basic(): graph = { 1: [(2, 10), (3, 30)], 2: [(1, 10), (3, 20), (4, 50)], 3: [(1, 30), (2, 20)], 4: [(2, 50)] } assert dijkstra(4, graph, 1, 4) == 60 assert dijkstra(4, graph, 1, 3) == 30 assert dijkstra(4, graph, 2, 3) == 20 assert dijkstra(4, g...
[ { "docstring": "Finds the shortest path in a graph from start to end using Dijkstra's algorithm.\n:param n: Number of cities\n:param graph: Adjacency list of the graph where graph[u] is a list of (v, cost) pairs\n:param start: Starting city A\n:param end: Destination city B\n:return: Minimum cost from start to ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\n\ndef find_min_travel_cost(T, test_cases):\n results = []\n \n for i in range(T):\n N, M, edges, A, B = test_cases[i]\n ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00075696", "row_id": 75696, "seed_ids": "[18330]" }
0.783008
Taco_75696
I
[ "dijkstra", "min_travel_cost", "solve" ]
3
[ [ "min_travel_cost", "dijkstra" ], [ "solve", "min_travel_cost" ] ]
2
[]
false
[]
false
pytest
false
[]
true
9fd38428b3ba7319d0f95dc567472f61065d597c
72ab6f238224dba06a57188faf8be88252575955
v1.0
instruct
Taco
Taco_75723_I
You are given a collection of strings and you need to determine if each string is a palindrome. A palindrome is a string that reads the same backward as forward. -----Input:----- - The first line of the input contains a single integer $T$ denoting the number of test cases. - The next T lines each contain a single stri...
def is_palindrome(s): """ Check if a given string is a palindrome. """ return s == s[::-1] def check_palindromes(strings): """ Given a list of strings, return a list of "Yes" or "No" for each string depending on whether it is a palindrome or not. """ results = [] for s in string...
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("radar") == True assert is_palindrome("hello") == False assert is_palindrome("level") == True assert is_palindrome("") == True assert is_palindrome("a") == True assert is_palindrome("ab") == Fal...
[ { "docstring": "Check if a given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Given a list of strings, return a list of \"Yes\" or \"No\" for each string depending on\nwhether it is a 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 is_palindrome(s):\n \"\"\"\n Determines if the given string is a palindrome.\n \n :param s: Input string\n :return: 'Yes' if the string is a pal...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075723", "row_id": 75723, "seed_ids": "[24551]" }
0.824461
Taco_75723
I
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
395f0dba3a277cb62c52c323b97df862b6f05e2b
9b8f3291ab4dcf0370dcc650b37d7d97925993b2
v1.0
instruct
Taco
Taco_75813_I
You are required to write a program that determines if a given year is a leap year and then calculates the number of days between two given dates within that year. Input The input consists of multiple datasets. Each dataset contains one integer y, representing the year, followed by two dates in the format month/day (...
from datetime import datetime def is_leap_year(year): """ Determines if a given year is a leap year. Args: year (int): The year to check. Returns: bool: True if the year is a leap year, False otherwise. """ if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): r...
from solution import is_leap_year, days_between_dates, process_input def test_is_leap_year(): assert is_leap_year(2020) == True assert is_leap_year(2021) == False assert is_leap_year(1900) == False assert is_leap_year(2000) == True def test_days_between_dates(): assert days_between_dates(2020, "1/...
[ { "docstring": "Determines if a given year is a leap year.\n\nArgs:\nyear (int): The year to check.\n\nReturns:\nbool: True if the year is a leap year, False otherwise.", "function_declaration": "def is_leap_year(year):", "function_name": "is_leap_year", "parameter_list": "(year)" }, { "docs...
[ 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 datetime import date\n\ndef is_leap_year(year):\n if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):\n return True\n return False\n\nde...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00075813", "row_id": 75813, "seed_ids": "[21350]" }
0.656644
Taco_75813
I
[ "is_leap_year", "days_between_dates", "process_input" ]
3
[ [ "process_input", "days_between_dates" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
7905fe44b54506afedd427c71890a37edacab459
7bb716726f048fac718e45695dea1aa009f42eca
v1.0
instruct
Taco
Taco_75819_I
You are hosting a barbecue event and you want to ensure that there's enough food for everyone. You have a list of people attending and each person has preferences for what they want to eat. Every person will be satisfied if they get at least one item from their list of preferred items. You want to determine if you can ...
def can_satisfy_everyone(i, p, available_items, preferences): """ Determines if it is possible to satisfy everyone with at least one item from their list of preferred items based on the available items. Parameters: i (int): number of available items. p (int): number of people. availabl...
import pytest from solution import can_satisfy_everyone, from_input_string, to_output_string def test_example_1(): input_str = """5 3 burger hotdog fries salad soda 2 burger soda 3 fries hotdog salad 1 hotdog""" expected_output = "yes" i, p, available_items, preferences = from_input_string(input_str) a...
[ { "docstring": "Determines if it is possible to satisfy everyone with at least one item from \ntheir list of preferred items based on the available items.\n\nParameters:\ni (int): number of available items.\np (int): number of people.\navailable_items (list): list of available items.\npreferences (list of lists...
[ 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_satisfy_everyone(i, p, available_items, people_preferences):\n \"\"\"\n Determines if it's possible to satisfy all people by giving each person at le...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075819", "row_id": 75819, "seed_ids": "[11663]" }
0.699181
Taco_75819
I
[ "can_satisfy_everyone", "parse_input", "from_input_string", "to_output_string" ]
4
[ [ "from_input_string", "parse_input" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
9c1eea28a47afa412105f98f7797c464dea07a26
3e02574f579c10c412c00b9a946ab93a7ad4ec97
v1.0
instruct
Taco
Taco_75913_I
In a city, there are N intersections connected by M bidirectional roads. The distance between each pair of intersections is given in a matrix, with the entry distance[i][j] representing the distance between intersection i and intersection j. Some entries might contain -1, indicating no direct road exists between these ...
def floyd_warshall(n, dist): """Applies the Floyd-Warshall algorithm to find shortest paths between all pairs of nodes.""" for k in range(n): for i in range(n): for j in range(n): if dist[i][k] != float('inf') and dist[k][j] != float('inf'): dist[i][j] = m...
def test_shortest_path(): t = 2 test_cases = [ {'n': 4, 'm': 4, 's': 0, 'd': 3, 'roads': [(0, 1, 3), (1, 2, 1), (2, 3, 2), (0, 3, 10)]}, {'n': 4, 'm': 2, 's': 1, 'd': 3, 'roads': [(1, 2, 5), (2, 3, 7)]} ] expected_output = [6, 12] assert shortest_path(t, test_cases) == expe...
[ { "docstring": "Applies the Floyd-Warshall algorithm to find shortest paths between all pairs of nodes.", "function_declaration": "def floyd_warshall(n, dist):", "function_name": "floyd_warshall", "parameter_list": "(n, dist)" }, { "docstring": null, "function_declaration": "def shortest...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def floyd_warshall(num_intersections, roads, start, destination):\n # Initialize the distance matrix with infinite distances\n inf = float('inf')\n dist =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075913", "row_id": 75913, "seed_ids": "[20488]" }
0.704721
Taco_75913
I
[ "floyd_warshall", "shortest_path" ]
2
[ [ "shortest_path", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e07af84bf98ca1b17ce35df32f99f153da91c9ee
55e1edad539e2384d971886528e7367b8e7960ce
v1.0
instruct
Taco
Taco_75924_I
Landa works in a factory that produces lenses. Each lens can have different quality scores based on various factors. She maintains a record of the quality score for each lens produced daily. The factory rewards Landa if the average quality score of the lenses produced in a day is higher than the average quality score o...
def count_rewards(m, quality_scores): """ Returns the number of days Landa gets the reward. Parameters: m : int : The number of days. quality_scores : list : Each element is a list containing the quality scores for a day. Returns: int : The number of days Landa gets the reward. ...
from solution import daily_rewards def test_example_1(): m = 3 data = [ [3, 2, 4, 6], [4, 3, 5, 7, 9], [3, 8, 8, 8] ] assert daily_rewards(m, data) == 2 def test_example_2(): m = 2 data = [ [2, 1, 5], [3, 2, 2, 2] ] assert daily_rewards(m, data) ...
[ { "docstring": "Returns the number of days Landa gets the reward.\n\nParameters:\nm : int : The number of days.\nquality_scores : list : Each element is a list containing the quality scores for a day.\n\nReturns:\nint : The number of days Landa gets the reward.", "function_declaration": "def count_rewards(m...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_rewards(m, days_quality_scores):\n \"\"\"\n Calculate the number of days Landa will get rewarded.\n \n Args:\n m (int): Number of days...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00075924", "row_id": 75924, "seed_ids": "[5385]" }
0.6605
Taco_75924
I
[ "count_rewards", "daily_rewards" ]
2
[ [ "daily_rewards", "count_rewards" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ced678a1ba26b1d6a413fc02120971fed4d544a5
c0a38a23a0e027de6438a9653c88dc8ee25551d3
v1.0
instruct
Taco
Taco_75942_I
## Task Generate Fibonacci Primes Fibonacci numbers are a classic sequence of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. Prime numbers are numbers greater than 1 that are only divisible by 1 and themselves. A Fibonacci prime is a Fibonacci number that is also a pri...
def is_prime(num): """ Check if a number is prime. """ if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i != 0: continue return False return True def fibonacci_generator(): """ An infinite generator of Fibonacci numbers. """...
from solution import is_prime, fibonacci_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(11) == True assert is_prime(15) == False def test_fibonacci_primes(): assert fibonacci_primes(1)...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "An infinite generator of Fibonacci numbers.", "function_declaration": "def fibonacci_generator():", "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 is_prime(num):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00075942", "row_id": 75942, "seed_ids": "[25195]" }
0.748661
Taco_75942
I
[ "is_prime", "fibonacci_generator", "fibonacci_primes" ]
3
[ [ "fibonacci_primes", "fibonacci_generator" ], [ "fibonacci_primes", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
49b456c3efe16608f277a149c490a2ea3be29435
6c2bf34336730c4f91af45b62600d3ae7f2044e3
v1.0
instruct
Taco
Taco_75943_I
Dr. Watson and Sherlock Holmes are trying to solve a series of mysterious crimes in London. They find that every crime scene can be represented as a node, and each pair of nodes contains a unique clue that can help link two different cases. Watson, being a methodical person, decided to represent these clues as a matrix...
def find_mst_weight(n, edges): """ Function to find the total weight of the Minimum Spanning Tree (MST) using Kruskal's Algorithm. :param n: Number of nodes (crime scenes) :param edges: List of tuples (u, v, w) where u and v are nodes and w is the weight of the edge between them. :return: Total...
def test_sample_input(): input_data = "4 5\n1 2 5\n1 3 10\n2 3 4\n2 4 11\n3 4 8" assert process_input_and_find_mst_weight(input_data) == 17 def test_single_edge(): input_data = "2 1\n1 2 10" assert process_input_and_find_mst_weight(input_data) == 10 def test_disconnected_graph(): input_data = "3 1...
[ { "docstring": "Function to find the total weight of the Minimum Spanning Tree (MST) using Kruskal's Algorithm.\n\n:param n: Number of nodes (crime scenes)\n:param edges: List of tuples (u, v, w) where u and v are nodes and w is the weight of the edge between them.\n:return: Total weight of the MST", "funct...
[ 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_mst_weight(n, edges):\n \"\"\"\n Function to find the total weight of the Minimum Spanning Tree (MST) using Kruskal's Algorithm.\n \n :param n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00075943", "row_id": 75943, "seed_ids": "[9602]" }
0.636691
Taco_75943
I
[ "find_mst_weight", "process_input_and_find_mst_weight" ]
2
[ [ "process_input_and_find_mst_weight", "find_mst_weight" ] ]
1
[]
false
[]
false
pytest
false
[]
true
68ca1a33f9342f8e5278c71f9832995cb8dc80e4
ee151ae603f78f92a92f40dcbc067586dc53db6d
v1.0
instruct
Taco
Taco_75972_I
Mike likes playing number games and has recently invented a new game involving digit pairs of numbers. Given a number, he splits it into all possible pairs of digits and calculates the sum of these pairs. Mike wants your help to determine which numbers in a list of numbers have the largest sum of digit pairs and to fin...
def sum_of_digit_pairs(number): digits = list(map(int, str(number))) n = len(digits) sum_pairs = 0 for i in range(n): for j in range(i + 1, n): sum_pairs += digits[i] + digits[j] return sum_pairs def largest_sum_of_digit_pairs(N, numbers): max_sum = -1 min_number_with_ma...
from solution import largest_sum_of_digit_pairs def test_with_examples(): assert largest_sum_of_digit_pairs(4, [123, 456, 789, 101112]) == 789 def test_single_number(): assert largest_sum_of_digit_pairs(1, [98765432123456789]) == 98765432123456789 def test_tie_sum_choose_smaller_number(): assert largest_...
[ { "docstring": null, "function_declaration": "def sum_of_digit_pairs(number):", "function_name": "sum_of_digit_pairs", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def largest_sum_of_digit_pairs(N, numbers):", "function_name": "largest_sum_of_digit_pa...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_pair_sum(num):\n \"\"\"\n Given a number, splits it into all possible pairs of digits and calculates the sum of these pairs.\n \"\"\"\n num_s...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00075972", "row_id": 75972, "seed_ids": "[4229]" }
0.689587
Taco_75972
I
[ "sum_of_digit_pairs", "largest_sum_of_digit_pairs" ]
2
[ [ "largest_sum_of_digit_pairs", "sum_of_digit_pairs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f8b6f307f86c5281ae2cd929b80a3dbdd27e72cf
94e416885ffd044e19e68cb92bb28329a707dd52
v1.0
instruct
Taco
Taco_75996_I
Consider a grid with n rows and m columns, each cell initially occupied by a person. Each person can either be sitting or standing, and they can only see other standing people in the same row or column until blocked by another sitting person. You are given the initial state of the grid and a series of commands. Each c...
def count_pairs(grid, n, m): horz_pairs = 0 vert_pairs = 0 # Calculate horizontal pairs for r in range(n): count = 0 for c in range(m): if grid[r][c] == 'T': count += 1 else: if count > 1: horz_pairs += count * ...
from solution import process_input def test_example(): n = 4 m = 4 grid_lines = [ "SSSS", "STTT", "SSSS", "STSS" ] q = 3 queries = [ (2, 2), (3, 4), (4, 2) ] process_input(n, m, grid_lines, q, queries) def test_all_sitting(): ...
[ { "docstring": null, "function_declaration": "def count_pairs(grid, n, m):", "function_name": "count_pairs", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def toggle_and_count(n, m, grid, queries):", "function_name": "toggle_and_count", "parame...
[ 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 count_pairs(grid):\n n = len(grid)\n m = len(grid[0])\n pairs = 0\n\n # Count visible pairs in rows\n for i in range(n):\n standing_count...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00075996", "row_id": 75996, "seed_ids": "[19482]" }
0.627214
Taco_75996
I
[ "count_pairs", "toggle_and_count", "process_input" ]
3
[ [ "process_input", "toggle_and_count" ], [ "toggle_and_count", "count_pairs" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
ff3ce838bec732aa53ecb7a82b7d17867a9fbb8e
c06437355101dd4f13aa3d1d847433b1ed06b8f2
v1.0
instruct
Taco
Taco_75998_I
Password Strength Checker A company's security policy requires all passwords to be strong. A password is considered strong if it satisfies the following conditions: 1. It has a length of at least 8 characters. 2. It contains at least one lowercase letter. 3. It contains at least one uppercase letter. 4. It contains a...
def is_strong_password(password): special_characters = set('!@#$%^&*()-+') if len(password) < 8: return 'WEAK' has_lower = any(c.islower() for c in password) has_upper = any(c.isupper() for c in password) has_digit = any(c.isdigit() for c in password) has_special = any(c in spe...
from solution import is_strong_password, check_passwords def test_is_strong_password(): assert is_strong_password("P@ssw0rd") == "STRONG" assert is_strong_password("weakpassword") == "WEAK" assert is_strong_password("StrongPass1") == "WEAK" assert is_strong_password("12345678!") == "WEAK" assert is...
[ { "docstring": null, "function_declaration": "def is_strong_password(password):", "function_name": "is_strong_password", "parameter_list": "(password)" }, { "docstring": null, "function_declaration": "def check_passwords(passwords):", "function_name": "check_passwords", "paramete...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef check_password_strength(password):\n \"\"\"\n Determines if the given password is strong or weak based on predefined criteria.\n \"\"\"\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00075998", "row_id": 75998, "seed_ids": "[3638]" }
0.56991
Taco_75998
I
[ "is_strong_password", "check_passwords" ]
2
[ [ "check_passwords", "is_strong_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4e5116ea70ff9c5d67d250381a97129acc0afa4
0fe25d2b07a57aa2161c7be05c896728c6fef5c4
v1.0
instruct
Taco
Taco_76049_I
You are given a list of integers and your task is to sort this list in non-decreasing order, but if two numbers have the same value, the one that appeared first in the original list should come first. Write a function that implements this sorting algorithm. Input The input consists of a single line containing multip...
def custom_sort(input_list): """ Sorts a list of integers in non-decreasing order, while retaining the order of duplicate elements as they appeared in the original list. Arguments: input_list -- a list of integers Returns: A sorted list of integers in non-decreasing order, with rel...
from solution import read_sort_output def test_example_1(): assert read_sort_output("4 5 2 3 3 1 4 5") == "1 2 3 3 4 4 5 5" def test_example_2(): assert read_sort_output("-1 -5 0 3 -5 2 1") == "-5 -5 -1 0 1 2 3" def test_empty_input(): assert read_sort_output("") == "" def test_single_element(): ass...
[ { "docstring": "Sorts a list of integers in non-decreasing order, while retaining the order\nof duplicate elements as they appeared in the original list.\n\nArguments:\ninput_list -- a list of integers\n\nReturns:\nA sorted list of integers in non-decreasing order, with relative order of equal elements preserve...
[ 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 sort_list_preserving_order(lst):\n \"\"\"\n Sorts a list in non-decreasing order, retaining the relative order of equal elements.\n \n Args:\n l...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076049", "row_id": 76049, "seed_ids": "[15975]" }
0.670953
Taco_76049
I
[ "custom_sort", "read_sort_output" ]
2
[ [ "read_sort_output", "custom_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db6a65f801c7ecc885d87cf575d5755a3b1da829
504d3754199b78990b716c4055f88455bf366645
v1.0
instruct
Taco
Taco_76082_I
A game company is developing a new feature that involves magical squares. You are asked to determine whether a grid is a magic square. A magic square is a grid of numbers where the sum of every row, column, and both main diagonals are equal. Given a 3x3 grid, determine if it is a magic square. Input: The input will...
def is_magic_square(grid): """ Determines whether the provided 3x3 grid is a magic square. Parameters: grid (list): A list of 9 integers representing the grid in row-major order. Returns: str: "Magic Square" if the grid is a magic square, "Not a Magic Square" otherwise. """ if ...
from solution import determine_magic_square def test_magic_square(): assert determine_magic_square("8 1 6 3 5 7 4 9 2") == "Magic Square" def test_not_magic_square(): assert determine_magic_square("1 2 3 4 5 6 7 8 9") == "Not a Magic Square" def test_not_magic_square_negative_numbers(): assert determine_...
[ { "docstring": "Determines whether the provided 3x3 grid is a magic square.\n\nParameters:\ngrid (list): A list of 9 integers representing the grid in row-major order.\n\nReturns:\nstr: \"Magic Square\" if the grid is a magic square, \"Not a Magic Square\" otherwise.", "function_declaration": "def is_magic_...
[ 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": "def is_magic_square(grid):\n # Convert grid list into 3x3 matrix\n matrix = [grid[i:i+3] for i in range(0, 9, 3)]\n \n # Sum of the first row to set th...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00076082", "row_id": 76082, "seed_ids": "[15544]" }
0.67079
Taco_76082
I
[ "is_magic_square", "determine_magic_square" ]
2
[ [ "determine_magic_square", "is_magic_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1a536a0bf6e8777e18716cbac4e5dacc11ea44ca
554b3e2ad2dd12ae8e9187a459eda8a01a096b50
v1.0
instruct
Taco
Taco_76100_I
In a certain city, there are $n$ intersections connected by $m$ two-way streets. Each street has a length in meters. The city's traffic department wants to implement a new traffic system that requires calculating the shortest distance between pairs of intersections that are most distant from each other. You are tasked...
def floyd_warshall(n, edges): # Create a 2D list to store the shortest path distances dist = [[float('inf')] * n for _ in range(n)] # Distance from a node to itself is 0 for i in range(n): dist[i][i] = 0 # Initialize distances with given edges for u, v, w in edges: ...
from solution import find_longest_shortest_path def test_sample_0(): n = 4 m = 4 edges = [ (1, 2, 3), (2, 3, 4), (3, 4, 2), (4, 1, 5) ] assert find_longest_shortest_path(n, m, edges) == 7 def test_sample_1(): n = 5 m = 4 edges = [ (1, 2, 6), ...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, edges):", "function_name": "floyd_warshall", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def find_longest_shortest_path(n, m, edges):", "function_name": "find_longest_shortest_path...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom typing import List, Tuple\n\ndef shortest_distance_between_furthest_intersections(n: int, m: int, streets: List[Tuple[int, int, int]]) -> int:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076100", "row_id": 76100, "seed_ids": "[23652]" }
0.762217
Taco_76100
I
[ "floyd_warshall", "find_longest_shortest_path" ]
2
[ [ "find_longest_shortest_path", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41eb23aa73e4efafffdfde00065dd4cc049a1606
747fd764d510b1eab7a91b5bd2cb8a991bb15994
v1.0
instruct
Taco
Taco_76144_I
Given a string, determine if it is a panagram. A panagram is a sentence containing every letter in the English Alphabet at least once. INPUT First line contains number of test cases T. Each test case contains a single string S. OUTPUT For each test case, print "YES" if the string is a panagram, otherwise print "NO". ...
def is_pangram(s): """ Check if the string s is a pangram. A pangram is a sentence that contains every letter of the English alphabet at least once. """ alphabet_set = set("abcdefghijklmnopqrstuvwxyz") return alphabet_set.issubset(set(s.lower())) def check_pangrams(test_cases): """ For ...
from solution import check_pangrams, is_pangram def test_is_pangram(): assert is_pangram("The quick brown fox jumps over the lazy dog") == True assert is_pangram("Hello World") == False assert is_pangram("Pack my box with five dozen liquor jugs") == True assert is_pangram("Sphinx of black quartz, judge...
[ { "docstring": "Check if the string s is a pangram.\nA pangram is a sentence that contains every letter of the English alphabet at least once.", "function_declaration": "def is_pangram(s):", "function_name": "is_pangram", "parameter_list": "(s)" }, { "docstring": "For each test case, determi...
[ 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_pangram(string):\n \"\"\"\n Returns \"YES\" if the string is a pangram, otherwise \"NO\".\n \"\"\"\n alphabet = set('abcdefghijklmnopqrstuvwxyz'...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076144", "row_id": 76144, "seed_ids": "[11771]" }
0.635251
Taco_76144
I
[ "is_pangram", "check_pangrams", "process_input_output" ]
3
[ [ "check_pangrams", "is_pangram" ], [ "process_input_output", "check_pangrams" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
0f9f319cb2d3ab49dce8f98f1d0f2885547913c7
0bb219753a0cf7e68febcd15062a334e352e5a5c
v1.0
instruct
Taco
Taco_76157_I
Given a rectangular grid of characters and a list of words, your task is to identify the maximum length of any word in the list that can be found in the grid. A word can be constructed from characters of sequentially adjacent cells, where "adjacent" cells are those horizontally, vertically, or diagonally neighboring. T...
def exist(board, word): rows, cols = len(board), len(board[0]) def dfs(r, c, i): if i == len(word): return True if (r < 0 or r >= rows or c < 0 or c >= cols or board[r][c] != word[i]): return False temp = board[r][c] board[r][c] = '#' fou...
from solution import find_max_word_length def test_example_case(): grid_dimensions = (4, 4) grid = [ "abcd", "efgh", "ijkl", "mnop" ] words = ["abc", "fij", "ghk", "mnop", "abcdef"] assert find_max_word_length(grid_dimensions, grid, words) == 4 def test_single_cell_...
[ { "docstring": null, "function_declaration": "def exist(board, word):", "function_name": "exist", "parameter_list": "(board, word)" }, { "docstring": null, "function_declaration": "def max_word_length_in_grid(grid, words):", "function_name": "max_word_length_in_grid", "parameter_...
[ 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 find_max_word_length(grid, words):\n def dfs(x, y, word, index, visited):\n if index == len(word): \n return True\n \n if x ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00076157", "row_id": 76157, "seed_ids": "[7404]" }
0.671738
Taco_76157
I
[ "exist", "max_word_length_in_grid", "find_max_word_length" ]
3
[ [ "find_max_word_length", "max_word_length_in_grid" ], [ "max_word_length_in_grid", "exist" ] ]
2
[]
false
[]
false
pytest
true
[]
true
41da46352668d5561c3e7ada8ace29b5ca039525
69c3b1f367a966e56caf932173ddbcbb8c789e28
v1.0
instruct
Taco
Taco_76158_I
Emma loves to work with binary trees. Given a binary tree, she wants to find the longest path between any two nodes in the tree. The path may or may not pass through the root node. She describes this as finding the diameter of the binary tree, which is the number of edges in the longest path between any two nodes. Em...
class TreeNode: def __init__(self, value): self.value = value self.children = [] def build_tree(nodes, edges): node_dict = {i+1: TreeNode(i+1) for i in range(nodes)} for u, v in edges: node_dict[u].children.append(node_dict[v]) node_dict[v].children.append(node_dict[u]) ...
from solution import parse_input, build_tree, tree_diameter def test_sample_input(): input_str = "2\n5\n1 2 3 4 5\n1 2\n1 3\n3 4\n3 5\n3\n1 2 3\n1 2\n1 3" expected_output = [3, 2] assert parse_input(input_str) == expected_output def test_single_tree(): input_str = "1\n4\n1 2 3 4\n1 2\n2 3\n3 4" ex...
[]
[ 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 defaultdict, deque\n\ndef diameter_of_tree(n, edges):\n if not edges:\n return 0\n\n def bfs(start):\n visited = [-1] *...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076158", "row_id": 76158, "seed_ids": "[18429]" }
0.724065
Taco_76158
I
[ "build_tree", "diameter_helper", "tree_diameter", "parse_input", "handle_input" ]
5
[ [ "handle_input", "parse_input" ], [ "parse_input", "build_tree" ], [ "parse_input", "tree_diameter" ], [ "tree_diameter", "diameter_helper" ] ]
4
[ "parse_input", "handle_input" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
e225a1351f64a3de17cf645f60b25985b6df9583
0ca451a5d776949b37df840f8a426eab86ab18e8
v1.0
instruct
Taco
Taco_76176_I
Petya is a lover of prime numbers. He enjoys numbers which have exactly two distinct positive divisors: 1 and the number itself. Petya wants to challenge you with constructing a prime sequence in a unique way. He gives you a set of integers and asks you to find the longest subsequence such that all elements in this sub...
def is_prime(num): """ Checks if the number is a prime number. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False ...
from solution import longest_increasing_prime_subsequence def test_example_1(): assert longest_increasing_prime_subsequence([10, 2, 3, 5, 7, 11]) == 5 def test_example_2(): assert longest_increasing_prime_subsequence([4, 6, 8, 10, 12]) == 0 def test_all_primes_increasing(): assert longest_increasing_prim...
[ { "docstring": "Checks if the number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Determines the length of the longest strictly increasing subsequence of prime numbers.", "function_declaration...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076176", "row_id": 76176, "seed_ids": "[14302]" }
0.633988
Taco_76176
I
[ "is_prime", "longest_increasing_prime_subsequence" ]
2
[ [ "longest_increasing_prime_subsequence", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
21f071b960a74544de5609662d5ef2fdf51b8061
e8e9f6a81b3b4680b3ca1000c96ca74544139feb
v1.0
instruct
Taco
Taco_76227_I
A company wants to optimize the use of its conference rooms. Each conference room can be reserved for one or more meetings throughout the day. A meeting is defined by its start time and end time. Given the list of all the meetings that are planned for the day, you need to find the minimum number of conference rooms req...
import heapq def min_conference_rooms(meetings): if not meetings: return 0 meetings.sort(key=lambda x: x[0]) heap = [] heapq.heappush(heap, meetings[0][1]) for i in range(1, len(meetings)): if meetings[i][0] >= heap[0]: heapq.heappop(heap) ...
from solution import min_conference_rooms def test_min_conference_rooms(): meetings = [[1, 4], [2, 5], [7, 9]] assert min_conference_rooms(meetings) == 2 def test_non_overlapping_meetings(): meetings = [[1, 3], [4, 6], [7, 9]] assert min_conference_rooms(meetings) == 1 def test_all_meetings_overl...
[ { "docstring": null, "function_declaration": "def min_conference_rooms(meetings):", "function_name": "min_conference_rooms", "parameter_list": "(meetings)" }, { "docstring": null, "function_declaration": "def min_conference_rooms_from_input():", "function_name": "min_conference_rooms...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef min_conference_rooms(meetings):\n \"\"\"\n Returns the minimum number of conference rooms required so that no meetings overlap.\n \"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076227", "row_id": 76227, "seed_ids": "[22942]" }
0.749388
Taco_76227
I
[ "min_conference_rooms", "min_conference_rooms_from_input" ]
2
[ [ "min_conference_rooms_from_input", "min_conference_rooms" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8fc6543f3d5a913be7341affa15b62b5f0771d2d
ce875ab0acd0761ddecc5fdb15a15ca5c4908bc0
v1.0
instruct
Taco
Taco_76320_I
----- DIGIT SUM PAIRS ----- In a sequence of positive integers, the digit sum of a number is defined as the sum of its digits. For instance, the digit sum of 123 is 1+2+3=6. Given a list of integers, your task is to find all unique pairs (a, b) in the list such that the digit sum of a is equal to the digit sum of b. ...
def digit_sum(n): return sum(int(d) for d in str(n)) def digit_sum_pairs(numbers): digit_sum_map = {} for number in numbers: ds = digit_sum(number) if ds in digit_sum_map: digit_sum_map[ds].append(number) else: digit_sum_map[ds] = [number] pairs_count = ...
import pytest from solution import count_digit_sum_pairs, digit_sum_pairs def test_example_case(): input_data = "6\n34 12 52 41 71 23" assert count_digit_sum_pairs(input_data) == 2 def test_no_pairs(): input_data = "5\n12 23 34 45 56" assert count_digit_sum_pairs(input_data) == 0 def test_multiple_pa...
[ { "docstring": null, "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def digit_sum_pairs(numbers):", "function_name": "digit_sum_pairs", "parameter_list": "(numbers)" }, { ...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_sum(n):\n \"\"\"Calculate the digit sum of a number.\"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef digit_sum_pairs(n, numbers):\n \"...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00076320", "row_id": 76320, "seed_ids": "[16080]" }
0.732419
Taco_76320
I
[ "digit_sum", "digit_sum_pairs", "count_digit_sum_pairs" ]
3
[ [ "count_digit_sum_pairs", "digit_sum_pairs" ], [ "digit_sum_pairs", "digit_sum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
263034e19920a46e1b04d0418cd3a084f657dec9
55290ac8045f10ff14a1091dab7cd50dc6bce4cc
v1.0
instruct
Taco
Taco_76367_I
Tom's dog, Max, has a unique talent: he can detect shapes in a forest grid. After a walk through the grid, Max can sense if any rectangular shapes have been formed by overlapping test areas. Each cell of the grid can be either 0 (no tree) or 1 (tree). Max wants to detect the maximum size of a rectangular area formed b...
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 = (histogram[t...
def test_max_histogram_area(): assert max_histogram_area([1, 2, 3, 4]) == 6 assert max_histogram_area([6, 2, 5, 4, 5, 1, 6]) == 12 def test_max_rectangle_area(): grid1 = [ [1, 0, 1, 0, 0, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 0, 0, 1, 0, 1], [1, 1, 1, 1, 1,...
[ { "docstring": null, "function_declaration": "def max_histogram_area(histogram):", "function_name": "max_histogram_area", "parameter_list": "(histogram)" }, { "docstring": null, "function_declaration": "def max_rectangle_area(grid):", "function_name": "max_rectangle_area", "param...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def maximalRectangle(grid):\n if not grid:\n return 0\n \n H = len(grid)\n W = len(grid[0])\n max_area = 0\n \n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076367", "row_id": 76367, "seed_ids": "[25163]" }
0.696549
Taco_76367
I
[ "max_histogram_area", "max_rectangle_area", "process_input", "parse_input", "main" ]
5
[ [ "max_rectangle_area", "max_histogram_area" ], [ "process_input", "max_rectangle_area" ] ]
2
[ "process_input", "parse_input" ]
false
[]
false
pytest
false
[]
true
52b240c71ac6a9e191c15c4d2ea488d666997bbb
41799fc9344e398635eff6b467bfb21595c2d3f5
v1.0
instruct
Taco
Taco_76424_I
Alice is very fond of puzzles, and today she came across a peculiar puzzle involving prime numbers. Given a positive integer N, she wants to construct the smallest number possible using all the prime numbers less than or equal to N exactly once each. Additionally, she wants this number to have the maximum possible sum ...
def sieve_of_eratosthenes(n): """ Returns a list of all prime numbers less than or equal to n using Sieve of Eratosthenes """ is_prime = [True] * (n + 1) p = 2 while (p * p <= n): if (is_prime[p] == True): for i in range(p * p, n + 1, p): is_prime[i] = False p...
from solution import construct_smallest_number def test_construct_smallest_number(): assert construct_smallest_number(10) == "2357" assert construct_smallest_number(1) == "" assert construct_smallest_number(11) == "235711" assert construct_smallest_number(19) == "235711131719" assert construct_smal...
[ { "docstring": "Returns a list of all prime numbers less than or equal to n using Sieve of Eratosthenes ", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def const...
[ 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 smallest_prime_number_max_digit_sum(N):\n def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076424", "row_id": 76424, "seed_ids": "[7057]" }
0.627395
Taco_76424
I
[ "sieve_of_eratosthenes", "construct_smallest_number" ]
2
[ [ "construct_smallest_number", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c67a863e635589415d362ca0d0f12f8589696e6d
6239586cbd20e06cc8f525dfca02cc03c5c70705
v1.0
instruct
Taco
Taco_76438_I
Given a sequence of parentheses, brackets, and braces, create a program that determines whether each sequence is balanced. A sequence is considered balanced if the following conditions are met: 1. It contains equal numbers of opening and closing characters of each of type. 2. Every closing character corresponds to a p...
def is_balanced(sequence): """ Returns 'YES' if the sequence of parentheses, brackets, and braces is balanced and 'NO' otherwise. """ stack = [] matching_bracket = {')': '(', ']': '[', '}': '{'} for char in sequence: if char in matching_bracket.values(): stack.append(cha...
from solution import is_balanced, check_sequences def test_is_balanced(): assert is_balanced("({[]})") == "YES" assert is_balanced("(]{[})") == "NO" assert is_balanced("[({})]") == "YES" assert is_balanced("[[") == "NO" assert is_balanced("{[()]}") == "YES" assert is_balanced("(()") == "NO" ...
[ { "docstring": "Returns 'YES' if the sequence of parentheses, brackets, and braces is balanced and 'NO' otherwise.", "function_declaration": "def is_balanced(sequence):", "function_name": "is_balanced", "parameter_list": "(sequence)" }, { "docstring": "Returns the list of 'YES' or 'NO' for e...
[ 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(sequence):\n \"\"\"\n Returns \"YES\" if sequence is balanced, \"NO\" otherwise.\n A sequence is balanced if it contains equal numbers of ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076438", "row_id": 76438, "seed_ids": "[1011]" }
0.636922
Taco_76438
I
[ "is_balanced", "check_sequences" ]
2
[ [ "check_sequences", "is_balanced" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8edae9d6af1d36197cedc29028f62f8d374a6dcc
98ff77e1f9aa98f5705e19863b35bf27306f2103
v1.0
instruct
Taco
Taco_76465_I
Egor loves programming challenges. One of his favorite tasks involves special numbers. A number is considered special if its decimal representation contains at least one of the special digits 5 or 9. For example, numbers 59, 95, and 5 are special, while 123, 467, and 78 are not. Recently, Egor encountered a challenge...
def is_special_number(num): """ Determines if a number is special. A number is special if it contains the digits '5' or '9'. """ num_str = str(num) return '5' in num_str or '9' in num_str def is_sum_special(arr): """ Determines if the sum of an array of integers is a special number. ...
def test_is_special_number(): assert is_special_number(59) == True assert is_special_number(9) == True assert is_special_number(5) == True assert is_special_number(123) == False assert is_special_number(467) == False assert is_special_number(78) == False def test_is_sum_special(): asser...
[ { "docstring": "Determines if a number is special. A number is special if it contains\nthe digits '5' or '9'.", "function_declaration": "def is_special_number(num):", "function_name": "is_special_number", "parameter_list": "(num)" }, { "docstring": "Determines if the sum of an array of integ...
[ 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_special_number(num):\n \"\"\"\n Returns whether the given number is special (contains digit 5 or 9).\n \"\"\"\n return '5' in str(num) or '9' in...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076465", "row_id": 76465, "seed_ids": "[9187]" }
0.688484
Taco_76465
I
[ "is_special_number", "is_sum_special" ]
2
[ [ "is_sum_special", "is_special_number" ] ]
1
[]
false
[]
false
pytest
false
[]
true
53fd3ac11f9762bacbb65297711f2f2d68a458da
41b0de6b747ed4eab381633918e5032aed4d9dbf
v1.0
instruct
Taco
Taco_76485_I
You are given a list of points representing locations of homes in a 2D plane. A delivery center needs to be placed at one of these points to minimize the maximum distance any home has to travel to the delivery center. Afterwards, this delivery center will provide daily deliveries to each home. Write a function to dete...
from math import sqrt def euclidean_distance(p1, p2): return sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def best_delivery_center(points): best_point = None min_max_distance = float('inf') for candidate in points: max_distance = 0 for point in points: distance = eucl...
from solution import best_delivery_center def test_best_delivery_center_example_1(): points = [[0,0], [4,0], [2,3], [3,3], [1,4]] assert best_delivery_center(points) == [2,3] def test_best_delivery_center_example_2(): points = [[1,1], [2,2], [3,3]] assert best_delivery_center(points) == [2,2] def tes...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def best_delivery_center(points):", "function_name": "best_delivery_center", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef euclidean_distance(p1, p2):\n \"\"\"\n Calculate Euclidean distance between two points p1 and p2.\n \"\"\"\n return math.sqrt((p1[0]...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076485", "row_id": 76485, "seed_ids": "[3790]" }
0.748957
Taco_76485
I
[ "euclidean_distance", "best_delivery_center" ]
2
[ [ "best_delivery_center", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a36f4cec39178bda037da2bcefc3a2271de0a345
3231e283b213c947ec243ad5a54beb2c16d5d447
v1.0
instruct
Taco
Taco_76521_I
A company is planning an inter-departmental table tennis tournament. The company has $n$ employees, and they want to arrange the tournament such that each employee participates in exactly one match. Each match will consist of exactly two employees. Given that some employees might not be able to participate because the...
MOD = 10**9 + 7 def factorial_mod(n, mod=MOD): if n <= 1: return 1 result = 1 for i in range(2, n + 1): result = (result * i) % mod return result def count_matches(n): if n % 2 != 0: return 0 half_n = n // 2 factorial = factorial_mod(n) denominator = (factorial_...
from solution import count_matches def test_even_number_of_employees(): assert count_matches(4) == 3 assert count_matches(6) == 15 def test_odd_number_of_employees(): assert count_matches(1) == 0 assert count_matches(3) == 0 assert count_matches(5) == 0 def test_large_even_number_of_employees(): ...
[ { "docstring": null, "function_declaration": "def factorial_mod(n, mod=MOD):", "function_name": "factorial_mod", "parameter_list": "(n, mod=MOD)" }, { "docstring": null, "function_declaration": "def count_matches(n):", "function_name": "count_matches", "parameter_list": "(n)" }...
[ 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": "MOD = 10**9 + 7\n\ndef num_ways_to_arrange_matches(n):\n if n % 2 != 0:\n return 0\n \n dp = [0] * (n + 1)\n dp[0] = 1\n \n for i in range...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00076521", "row_id": 76521, "seed_ids": "[2196]" }
0.646989
Taco_76521
I
[ "factorial_mod", "count_matches" ]
2
[ [ "count_matches", "factorial_mod" ] ]
1
[]
false
[]
false
pytest
true
[]
true
635bee343eb22d8055b355e05d2c95119f8bdbd4
8d9e09f5016037d474b1e15cd3c53eb6c5c3faf8
v1.0
instruct
Taco
Taco_76523_I
You are participating in a programming competition where you have to solve several challenges. One of the challenges requires you to calculate the maximum contiguous subarray sum for a given sequence of integers. However, there's a twist – in this competition, you need to handle sequences that could also be entirely no...
def max_subarray_sum(T, test_cases): results = [] for case in test_cases: N, array = case max_current = max_global = array[0] for i in range(1, N): max_current = max(array[i], max_current + array[i]) if max_current > max_global: max_g...
def test_max_subarray_sum(): # A list of test cases test_cases = [ (2, [ 9, [-2, 1, -3, 4, -1, 2, 1, -5, 4], 5, [-1, -2, -3, -4, -5] ]), (1, [ 3, [1, 2, 3] ]), (1, [ 4, [-1, -2...
[ { "docstring": null, "function_declaration": "def max_subarray_sum(T, test_cases):", "function_name": "max_subarray_sum", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def process_input(T, arrays):", "function_name": "process_input", "parame...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Calculate the maximum contiguous subarray sum for the given array.\n\n :param arr: List of integers\n :return: In...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076523", "row_id": 76523, "seed_ids": "[12949]" }
0.781666
Taco_76523
I
[ "max_subarray_sum", "process_input", "solution" ]
3
[ [ "solution", "max_subarray_sum" ], [ "solution", "process_input" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
b6f1e6f90697d14c8350b674a106d3e0224f1ba0
3414db541249548d3693954632736269faaf61c0
v1.0
instruct
Taco
Taco_76530_I
In a two-dimensional grid of size N x N, we have a robot starting at the top-left corner of the grid (position (1, 1)). The robot can move either to the right or down. The goal is to determine the number of unique paths the robot can take to reach the bottom-right corner of the grid (position (N, N)). ------ Input For...
from math import factorial def unique_paths(n): """ Function to calculate the number of unique paths in a N x N grid. """ return factorial(2 * (n - 1)) // (factorial(n - 1) ** 2) def number_of_unique_paths(test_cases): results = [] for n in test_cases: results.append(unique_paths(n)) ...
import pytest from solution import unique_paths, number_of_unique_paths, parse_input def test_unique_paths(): # Test case for a 2x2 grid (N=2) assert unique_paths(2) == 2 # Test case for a 3x3 grid (N=3) assert unique_paths(3) == 6 # Test case for a 4x4 grid (N=4) assert unique_paths(...
[ { "docstring": "Function to calculate the number of unique paths in a N x N grid.", "function_declaration": "def unique_paths(n):", "function_name": "unique_paths", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def number_of_unique_paths(test_cases):", "fun...
[ 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 number_of_unique_paths(N):\n \"\"\"\n Returns the number of unique paths in an N x N grid.\n \"\"\"\n # Using dynamic programming to compute the nu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076530", "row_id": 76530, "seed_ids": "[21504]" }
0.678717
Taco_76530
I
[ "unique_paths", "number_of_unique_paths", "parse_input" ]
3
[ [ "number_of_unique_paths", "unique_paths" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
e7741dfe737c5ec4689eee979dc31d5e9a4ef934
0ca5e51c2be74525a0af72be33bbb75cf93eed56
v1.0
instruct
Taco
Taco_76593_I
In a fictional kingdom, there are n villages arranged in a straight line, numbered from 1 to n. The king wants to ensure that all villages are properly connected with water supply pipelines, but with a special condition: each pipeline can only connect two adjacent villages, and each village must be connected directly t...
def build_pipelines(n, k, restrictions): from collections import defaultdict # Initialize adjacency list adj = defaultdict(set) # Fill in the restrictions in adjacency list for a, b in restrictions: adj[a].add(b) adj[b].add(a) # List to store pipelines pipeline...
def test_pipeline_system(): from io import StringIO import sys def run_test(input_str, expected_output_str): input_stream = StringIO(input_str) output_stream = StringIO() sys.stdin = input_stream sys.stdout = output_stream n, k = map(int, input_stream.re...
[ { "docstring": null, "function_declaration": "def build_pipelines(n, k, restrictions):", "function_name": "build_pipelines", "parameter_list": "(n, k, restrictions)" }, { "docstring": null, "function_declaration": "def pipeline_system(n, k, restrictions):", "function_name": "pipeline...
[ 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_pipeline_system(n, k, restrictions):\n connected = [0] * (n + 1)\n adj_list = [set() for _ in range(n + 1)]\n\n for a, b in restrictions:\n ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00076593", "row_id": 76593, "seed_ids": "[816]" }
0.710963
Taco_76593
I
[ "build_pipelines", "pipeline_system" ]
2
[ [ "pipeline_system", "build_pipelines" ] ]
1
[]
false
[]
false
pytest
false
[]
true
153cb2e2553e7174ac5034a1cab2042cdfd26de7
0887a56d96947cb523d6d8a433f2637942c42021
v1.0
instruct
Taco
Taco_76597_I
Given a positive integer n, your task is to determine whether it is a palindrome in both decimal (base 10) representation and binary (base 2) representation. A number is considered a palindrome if it reads the same backwards as forwards, both as a decimal number and a binary number. -----Input----- The input contains...
def is_palindrome(s): return s == s[::-1] def is_palindrome_in_both_bases(n): decimal_str = str(n) binary_str = bin(n)[2:] if is_palindrome(decimal_str) and is_palindrome(binary_str): return "Yes" else: return "No"
from solution import is_palindrome_in_both_bases def test_palindrome_in_both_bases(): assert is_palindrome_in_both_bases(585) == "Yes" assert is_palindrome_in_both_bases(123) == "No" assert is_palindrome_in_both_bases(1) == "Yes" assert is_palindrome_in_both_bases(9) == "Yes" assert is_palindrome_i...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def is_palindrome_in_both_bases(n):", "function_name": "is_palindrome_in_both_bases", "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 is_palindrome(s):\n \"\"\"\n Helper function to determine if a given string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef is_palindrome_bo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076597", "row_id": 76597, "seed_ids": "[567]" }
0.755512
Taco_76597
I
[ "is_palindrome", "is_palindrome_in_both_bases" ]
2
[ [ "is_palindrome_in_both_bases", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0fdb57f17b9c735a4550a35c545285cdc47e2e33
0317f2eaaf558ac7f52a2201afadb7ea88c92ae8
v1.0
instruct
Taco
Taco_76599_I
You are given an even number of points on a 2D plane. Pair these points such that the maximum distance between any paired points is minimized. The distance between any two points $(x1, y1)$ and $(x2, y2)$ is given by the Euclidean distance formula: $$d = \sqrt{(x2 - x1)^2 + (y2 - y1)^2}$$ Your task is to write a fu...
import math from typing import List, Tuple def euclidean_distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float: return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def minimizeMaxDistance(points: List[Tuple[int, int]]) -> float: import itertools n = len(points) min_distance = float('i...
from solution import minimizeMaxDistance def test_example(): points = [(0, 1), (1, 0), (2, 0), (0, 2), (2, 2), (1, 1)] assert math.isclose(minimizeMaxDistance(points), 1.414213562, rel_tol=1e-9) def test_two_points(): points = [(0, 0), (1, 1)] assert math.isclose(minimizeMaxDistance(points), math.sqrt...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def minimizeMaxDistance(points):", "function_name": "minimizeMaxDistance", "paramet...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\nfrom typing import List, Tuple\n\ndef distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float:\n return math.sqrt((p1[0] - p2...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076599", "row_id": 76599, "seed_ids": "[17987]" }
0.743377
Taco_76599
I
[ "euclidean_distance", "minimizeMaxDistance" ]
2
[ [ "minimizeMaxDistance", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4c1f5025f37586701d8e996ca950f557670e4e1a
74ba265e76c9889fdcfb8dcb7c70a71bc120be19
v1.0
instruct
Taco
Taco_76657_I
You are given a binary tree with N nodes, where each node has a unique value between 1 and N. Each node can have at most two children. The tree is provided to you in the form of parent-child relationships. Specifically, for each node, you are given its parent and whether it is a left or right child. You need to perfor...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(n, edges): nodes = {i: TreeNode(i) for i in range(1, n+1)} for u, v, c in edges: if c == 0: nodes[u].left = nodes[v] else: nodes[u]...
def test_tree_height_and_leaf_count(): input_string = "2\n3\n1 2 0\n1 3 1\n5\n1 2 0\n1 3 1\n2 4 0\n3 5 1\n" test_cases = parse_input(input_string) results = solve(test_cases) assert results == [(1, 2), (2, 2)] def test_single_node(): input_string = "1\n1\n" test_cases = parse_input(input_string...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(n, edges):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076657", "row_id": 76657, "seed_ids": "[16008]" }
0.7406
Taco_76657
I
[ "build_tree", "tree_height_and_leaf_count", "solve", "parse_input" ]
4
[ [ "solve", "build_tree" ], [ "solve", "tree_height_and_leaf_count" ] ]
2
[ "parse_input" ]
false
[ "TreeNode" ]
true
pytest
false
[]
true
d8c156686cbe48ec5b5a6aa1668d8df075408651
d0b1ee9574c358ac8c3f0abedde1a044ee765097
v1.0
instruct
Taco
Taco_76661_I
Dr. : John, have you ever worked with prime numbers? John: I've had some experience with them. Is there something specific you have in mind? Dr. : Yes, I'd like you to create a program that identifies prime numbers within a certain range and performs some operations on them. John: That sounds interesting! What are t...
def is_prime(num): """ Check if a number is a prime number. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if (num % i == 0) or (num % (i + 2) == 0): return False ...
from solution import is_prime, find_primes_in_range, sum_and_product_of_digits_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(20) == False def test_find_primes_in_range(): assert find_...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Find all prime numbers in the range from n to m (inclusive).", "function_declaration": "def find_primes_in_range(...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076661", "row_id": 76661, "seed_ids": "[16504]" }
0.58687
Taco_76661
I
[ "is_prime", "find_primes_in_range", "sum_and_product_of_digits_of_primes" ]
3
[ [ "find_primes_in_range", "is_prime" ], [ "sum_and_product_of_digits_of_primes", "find_primes_in_range" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a024cf40d554dd949957de37c709f4d9974b28b1
1eba57220a99e76977bcb0b4f7c9949d0352a9f5
v1.0
instruct
Taco
Taco_76662_I
Manoj loves palindromes and prime numbers. He has a special interest in finding numbers that are both prime and palindromic. The prime palindromic numbers are the numbers that remain the same when their digits are reversed and are also prime. Manoj has given you a number x and wants to find the smallest prime palindrom...
def is_prime(n): """ Checks whether 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 retur...
from solution import prime_palindrome def test_prime_palindrome_example1(): assert prime_palindrome(6) == 7 def test_prime_palindrome_example2(): assert prime_palindrome(31) == 101 def test_prime_palindrome_minimum_input(): assert prime_palindrome(1) == 2 def test_prime_palindrome_small_palindrome_prime...
[ { "docstring": "Checks whether a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks whether a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_pal...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks whether a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076662", "row_id": 76662, "seed_ids": "[16212]" }
0.727278
Taco_76662
I
[ "is_prime", "is_palindrome", "prime_palindrome" ]
3
[ [ "prime_palindrome", "is_palindrome" ], [ "prime_palindrome", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c9290ae8ef2e2b65a72bd4e7dc9ab206013a451c
edf5689826469b7e4383f848020bc5f5f2961491