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
complete
Taco
Taco_90026_C
from typing import List def rotate_array(nums: List[int], k: int) -> List[int]: """ Rotates the elements of the array `nums` to the right by `k` steps. Args: nums (List[int]): List of integers to rotate. k (int): Number of steps to rotate the array. Returns: List[int]: The rotated...
from typing import List def rotate_array(nums: List[int], k: int) -> List[int]: """ Rotates the elements of the array `nums` to the right by `k` steps. Args: nums (List[int]): List of integers to rotate. k (int): Number of steps to rotate the array. Returns: List[int]: The rotated...
def test_rotate_array_basic(): assert rotate_array([1, 2, 3, 4, 5], 2) == [4, 5, 1, 2, 3] def test_rotate_array_with_zero(): assert rotate_array([1, 2, 3, 4, 5], 0) == [1, 2, 3, 4, 5] def test_rotate_array_k_greater_than_length(): assert rotate_array([1, 2, 3, 4, 5], 7) == [4, 5, 1, 2, 3] def test_rotate...
[ { "docstring": "Rotates the elements of the array `nums` to the right by `k` steps.\n\nArgs:\nnums (List[int]): List of integers to rotate.\nk (int): Number of steps to rotate the array.\n\nReturns:\nList[int]: The rotated array.", "function_declaration": "def rotate_array(nums, k):", "function_name": "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef rotate_array(nums: List[int], k: int) -> List[int]:\n \"\"\"\n Rotates the elements of the array `nums` to the right by `k` st...
trial_gpt4o_0
{ "original_instruction": "You are given an integer array `nums` of length `n`, and an integer `k` representing the number of steps to shift each element in the array to its right.\n\nWrite a function that performs this right rotation in place, meaning the array should be modified without using additional space for a...
0.672729
Taco_90026
C
[ "rotate_array", "reverse" ]
2
[ [ "rotate_array", "reverse" ] ]
1
[]
false
[]
false
pytest
false
[]
true
89f8c3c89e1fbf66b323f43dda04c7be1bf62b93
3f47707d8d9ec694c4b2de0a5b311fbefd9fcb55
v1.0
complete
Taco
Taco_89950_C
def parse_input(input_string: str) -> List[List[Union[int, Tuple[str, str, int]]]]: """ Parse the input string to extract test cases. >>> parse_input("3\nA X 5\nB Y 2\nC Z 1\n0") [[3, ('A', 'X', 5), ('B', 'Y', 2), ('C', 'Z', 1)]] """ def process_tasks(test_cases: List[List[Union[int, Tuple[str, str...
def process_tasks(test_cases): results = [] for case in test_cases: tasks = sorted(case[1:], key=lambda x: x[2]) # Sort by priority level results.append(' '.join([task[1] for task in tasks])) return results def parse_input(input_string): lines = input_string.strip().split("\n") ind...
def test_parse_input(): input_string = """3 A X 5 B Y 2 C Z 1 0""" expected_output = [ [3, ('A', 'X', 5), ('B', 'Y', 2), ('C', 'Z', 1)] ] assert parse_input(input_string) == expected_output def test_process_tasks(): test_cases = [ [3, ('A', 'X', 5), ('B', 'Y', 2), ('C', 'Z...
[ { "docstring": null, "function_declaration": "def process_tasks(test_cases):", "function_name": "process_tasks", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_string):", "function_name": "parse_input", "parameter_list": "(...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def process_tasks(test_cases):\n results = []\n \n for tasks in test_cases:\n # Sort tasks by their priority level; as we need ascending order of p...
trial_gpt4o_2
{ "original_instruction": "A company has introduced a new policy for managing employee tasks efficiently. There are 'T' tasks in total, and each task is assigned to one of the 'N' employees. Each task has a priority level represented by a positive integer, and each employee can handle only one task at a time.\n\nIf a...
0.585514
Taco_89950
C
[ "process_tasks", "parse_input", "task_management" ]
3
[ [ "task_management", "parse_input" ], [ "task_management", "process_tasks" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
7fac07788480b97773aa95962bb46535fd5c24f5
9ccce6ba8b371357e71a1b73b8849e4d4d70447d
v1.0
complete
Taco
Taco_89959_C
def find_median_prime(n: int, sequence: List[int]) -> int: """ Find the median of all prime numbers in the sequence, rounded to the nearest integer. If there are no prime numbers, return -1. Args: n: The number of integers in the sequence. sequence: A list of integers. Returns: The...
def is_prime(num): if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def find_median_prime(n, sequence): primes = [num for num in seque...
from solution import find_median_prime def test_no_primes(): assert find_median_prime(4, [4, 6, 8, 10]) == -1 def test_all_primes(): assert find_median_prime(5, [3, 5, 7, 11, 13]) == 7 def test_some_primes(): assert find_median_prime(5, [3, 5, 12, 7, 14]) == 5 def test_one_prime(): assert find_media...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def find_median_prime(n, sequence):", "function_name": "find_median_prime", "parameter_list": "(n, sequence)"...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(num):\n \"\"\"\n Helper function to determine if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\...
trial_gpt4o_2
{ "original_instruction": "Leo is fascinated with prime numbers and often likes to play with them. Recently he discovered something interesting: median prime numbers.\n\nA prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The median of a list of numbers is the midd...
0.644491
Taco_89959
C
[ "is_prime", "find_median_prime" ]
2
[ [ "find_median_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5a2e643d0c954a6cf1f3895c4d127bc473795d1c
a0f7f1edafc1f343db78165bf08b4c11057e327d
v1.0
complete
Taco
Taco_89989_C
from typing import List def count_hamming_groups(binaries: List[str]) -> int: """ Group the binary numbers based on their Hamming distance and return the number of groups formed. The Hamming distance is the number of positions at which the corresponding bits are different. Two binary numbers are considered...
from typing import List def hamming_distance(str1: str, str2: str) -> int: """ Calculate the Hamming distance between two binary strings. """ return sum(c1 != c2 for c1, c2 in zip(str1, str2)) def count_hamming_groups(binaries: List[str]) -> int: """ Group the binary numbers based on their Ham...
from solution import count_hamming_groups def test_count_hamming_groups_single_group(): binaries = ["10100", "00100", "10110", "11100", "11011"] assert count_hamming_groups(binaries) == 2 def test_count_hamming_groups_complex_case(): binaries = ["000", "001", "011", "100"] assert count_hamming_gro...
[ { "docstring": "Calculate the Hamming distance between two binary strings.", "function_declaration": "def hamming_distance(str1, str2):", "function_name": "hamming_distance", "parameter_list": "(str1, str2)" }, { "docstring": "Group the binary numbers based on their Hamming distance and retu...
[ 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 typing import List\n\ndef hamming_distance(a: str, b: str) -> int:\n \"\"\"\n Calculate the Hamming distance between two binary strings.\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a list of strings, each representing a binary number (i.e., strings of '0's and '1's). Your task is to group these binary numbers based on their Hamming distance from each other and return the number of groups formed. Two binary numbers are considered to be in the same group i...
0.636902
Taco_89989
C
[ "hamming_distance", "count_hamming_groups" ]
2
[ [ "count_hamming_groups", "hamming_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2af642e0de07008caf3355facee1fcf73a8faa5e
51ef13cbebb50699e6298d50f8e6248d5e6015d4
v1.0
complete
Taco
Taco_89503_C
from typing import List def word_break(s: str, word_dict: List[str]) -> List[str]: """ Given a string s and a dictionary of words dict, determine if s can be segmented into a sequence of one or more dictionary words. Return all such possible segmentations in any order. >>> word_break("catsanddog", ["cat",...
def word_break_helper(s, word_dict, start, memo): if start in memo: return memo[start] if start == len(s): return [""] segmentations = [] for end in range(start + 1, len(s) + 1): word = s[start:end] if word in word_dict: subsequences = word_break_helper(...
from solution import word_break def test_example_1(): s = "catsanddog" word_dict = ["cat", "cats", "and", "sand", "dog"] output = ["cats and dog", "cat sand dog"] result = word_break(s, word_dict) assert sorted(result) == sorted(output) def test_example_2(): s = "pineapplepenapple" word_di...
[ { "docstring": null, "function_declaration": "def word_break_helper(s, word_dict, start, memo):", "function_name": "word_break_helper", "parameter_list": "(s, word_dict, start, memo)" }, { "docstring": null, "function_declaration": "def word_break(s, word_dict):", "function_name": "w...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def word_break(s, dictionary):\n \"\"\"\n Determine if s can be segmented into a sequence of one or more dictionary words.\n Return all such possible segm...
trial_gpt4o_9
{ "original_instruction": "Given a string s and a dictionary of words dict, determine if s can be segmented into a sequence of one or more dictionary words. Return all such possible segmentations in any order.\n\nExample 1:\nInput: s = \"catsanddog\", dict = [\"cat\",\"cats\",\"and\",\"sand\",\"dog\"]\nOutput: [\"cat...
0.61169
Taco_89503
C
[ "word_break_helper", "word_break" ]
2
[ [ "word_break", "word_break_helper" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa139ab246dd53f737135507215baa23f72f3599
526cb238c9d0d58ac1c6642df0d7ec18598c58da
v1.0
complete
Taco
Taco_89922_C
from typing import List, Tuple def will_collide(path1: Tuple[int, int, int, int], path2: Tuple[int, int, int, int]) -> bool: """ Determines if two paths will collide. Args: path1 (tuple): The start and end coordinates of the first path. path2 (tuple): The start and end coordinates of the second pa...
def will_collide(path1, path2): """ Determines if two paths will collide. """ # Unpack the points x1_start, y1_start, x1_end, y1_end = path1 x2_start, y2_start, x2_end, y2_end = path2 # Generate all points in path 1 points1 = set() if x1_start == x1_end: # Vertical line for...
from solution import will_collide, count_non_colliding_pairs def test_will_collide_simple_cases(): assert will_collide((1, 2, 1, 5), (2, 3, 5, 3)) == False assert will_collide((1, 2, 1, 5), (4, 4, 4, 1)) == False assert will_collide((1, 2, 1, 5), (1, 0, 1, 2)) == True def test_will_collide_intersecting_pa...
[ { "docstring": "Determines if two paths will collide.", "function_declaration": "def will_collide(path1, path2):", "function_name": "will_collide", "parameter_list": "(path1, path2)" }, { "docstring": null, "function_declaration": "def count_non_colliding_pairs(test_cases):", "functi...
[ 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 will_collide(path1, path2):\n \"\"\"\n Determines if two paths will collide.\n \"\"\"\n # Unpack the points\n x1_start, y1_start, x1_end, y1_end...
trial_gpt4o_0
{ "original_instruction": "Dexter is planning to conduct a robot simulation contest in his university. The contest involves navigating multiple robots through a grid and ensuring they don't collide with each other. Each robot follows a fixed path from its initial starting point to its destination and moves either hor...
0.602353
Taco_89922
C
[ "will_collide", "count_non_colliding_pairs", "main" ]
3
[ [ "count_non_colliding_pairs", "will_collide" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7fca97680a54021d9a3e11d32a74d126aefed873
76fdd9471c589bca0e0514d3dcd7f2cde27c8cf2
v1.0
complete
Taco
Taco_90132_C
from typing import List def is_prime(n: int) -> bool: """ Helper function to determine if a given number n is prime. """ def all_1_or_prime(lst: List[int]) -> bool: """ Determines whether every element in the list is either 1 or a prime number. >>> all_1_or_prime([1, 2, 3, 5, 7]) True >>> all_1_or...
def is_prime(n): """ Helper function to determine if a given number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def a...
from solution import all_1_or_prime def test_all_1_or_prime(): assert all_1_or_prime([1, 2, 3, 5, 7]) == True assert all_1_or_prime([1, 2, 3, 4]) == False assert all_1_or_prime([1, 1, 1]) == True assert all_1_or_prime([2, 3, 5, 7, 11]) == True assert all_1_or_prime([1, 2, 3, 4, 6]) == False ass...
[ { "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": "Determines whether every element in the list is either 1 or a prime number.", "function_declara...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n ...
trial_gpt4o_0
{ "original_instruction": "Write a function that determines whether a given list of integers is a list where every element is either 1 or a prime number. The function should take one argument, which is a list of integers, and return a boolean value. \n\nThe function should return `True` if every element in the list i...
0.788222
Taco_90132
C
[ "is_prime", "all_1_or_prime" ]
2
[ [ "all_1_or_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6ce4d54d97f309df659eb3183720e116d097a179
fc837753330d4ab2ddc5f08b94b148467df1f3a1
v1.0
complete
Taco
Taco_90109_C
def minimum_maximum_latency(P, Q, connections): """ Determine the minimum possible value of the maximum latency between any two cities on planet Zog. P: Number of cities Q: Number of possible cables connections: List of tuples representing the cables with format (a, b, l), where 'a' connects to 'b' with...
def find(parent, i): if parent[i] == i: return i parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if root_x != root_y: if rank[root_x] < rank[root_y]: parent[root_x] = root_y ...
from solution import minimum_maximum_latency def test_example_1(): P = 4 Q = 5 connections = [ (1, 2, 3), (1, 3, 5), (2, 3, 4), (2, 4, 8), (3, 4, 2) ] assert minimum_maximum_latency(P, Q, connections) == 4 def test_single_edge(): P = 2 Q = 1 conn...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Function to find the parent of an element\ndef find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\n#...
trial_gpt4o_1
{ "original_instruction": "On a distant planet called Zog, a local engineer named Zark is trying to set up a communication network between cities. The planet has $ P $ cities numbered from $ 1 $ to $ P $, and there are $ Q $ possible cables that Zark can use to connect these cities. Each cable can connect city $ a $ ...
0.534956
Taco_90109
C
[ "find", "union", "minimum_maximum_latency", "main" ]
4
[ [ "minimum_maximum_latency", "find" ], [ "minimum_maximum_latency", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8f4ab1cdb3b22b462458db7b44d9b82a184fe739
a4df7feda991aaed49b2b3a5b2c5f75be639c75f
v1.0
complete
Taco
Taco_90242_C
from typing import List def vertical_order(level_order: List[int]) -> List[List[int]]: """ Given a binary tree represented by a list of its node values in level order traversal, return the vertical order traversal of its nodes' values. The vertical order traversal of a binary tree is a traversal ...
from collections import defaultdict, deque class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(level_order): """ Build a binary tree from level order list """ if not level_order: return ...
import pytest from solution import vertical_order def test_vertical_order_case1(): input_data = [3, 9, 20, None, None, 15, 7] expected_output = [ [9], [3, 15], [20], [7] ] assert vertical_order(input_data) == expected_output def test_vertical_order_case2(): input_da...
[]
[ 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\nclass TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = Non...
trial_gpt4o_1
{ "original_instruction": "Problem statement\n\nGiven a binary tree, return the vertical order traversal of its nodes' values.\n\nThe vertical order traversal of a binary tree is a traversal where we visit all nodes from top to bottom in each vertical column. Columns are ordered from left to right, and nodes in the s...
0.577925
Taco_90242
C
[ "build_tree", "verticalOrderTraversal", "vertical_order" ]
3
[ [ "vertical_order", "build_tree" ], [ "vertical_order", "verticalOrderTraversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ad1c6bb78d512c884889627c0feddf79b5747f58
1cfdc8ff45b2e3e4cc5c7d841db84a8262f67ed6
v1.0
complete
Taco
Taco_90343_C
def min_path_cost(grid): """ Returns the minimum cost required to travel from the top-left to the bottom-right corner of the grid. >>> min_path_cost([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) 21 >>> min_path_cost([[1, 3, 1, 2], [3, 4, 2, 1], [1, 2, 3, 1], [3, 1, 2, 1]]) 10 >>> min_path_cost([[...
def min_path_cost(grid): """ Returns the minimum cost required to travel from the top-left to the bottom-right corner of the grid. """ n = len(grid) m = len(grid[0]) # Create a dp table to store the minimum cost to each cell dp = [[0] * m for _ in range(n)] # Initialize the top...
from solution import min_path_cost def test_min_path_cost_3x3(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ] assert min_path_cost(grid) == 21 def test_min_path_cost_4x4(): grid = [ [1, 3, 1, 2], [3, 4, 2, 1], [1, 2, 3, 1], [3, 1, 2, 1], ] ...
[ { "docstring": "Returns the minimum cost required to travel from the top-left to the bottom-right corner of the grid.", "function_declaration": "def min_path_cost(grid):", "function_name": "min_path_cost", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def re...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_path_cost(grid):\n \"\"\"\n Returns the minimum cost required to travel from the top-left to the bottom-right corner of the grid.\n \"\"\"\n n ...
trial_gpt4o_0
{ "original_instruction": "Snuke is participating in a programming competition where he needs to solve the \"Optimal Path in Grid\" problem. The problem involves an N x M grid, where each cell contains a positive integer indicating the cost of stepping into that cell.\n\nSnuke starts at the top-left corner of the gri...
0.701374
Taco_90343
C
[ "min_path_cost", "read_input", "solve" ]
3
[ [ "solve", "min_path_cost" ], [ "solve", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
true
[]
true
fe38132deb991a760fdd773cc3801943eecd3f57
87d7b28399f6c8f103a5e63a18296b105feb5b06
v1.0
complete
Taco
Taco_90297_C
def maxHistogramArea(heights): # Helper function to calculate the maximum area in a histogram pass def maxRectangle(matrix): """ Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. >>> maxRectangle([[1, 0, 1, 0], [1, 0, 1, 1], ...
def maxHistogramArea(heights): stack = [] max_area = 0 index = 0 while index < len(heights): if not stack or heights[stack[-1]] <= heights[index]: stack.append(index) index += 1 else: top_of_stack = stack.pop() area = (heights[top_of_stack...
from solution import findLargestRectangleInMatrix, maxHistogramArea, maxRectangle def test_example_case_1(): T = 3 test_cases = [ (4, 4, [[1, 0, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1], [1, 0, 0, 1]]), (3, 3, [[1, 1, 1], [1, 1, 1], [1, 1, 1]]), (2, 2, [[0, 0], [0, 1]]) ] expected = [4...
[ { "docstring": null, "function_declaration": "def maxHistogramArea(heights):", "function_name": "maxHistogramArea", "parameter_list": "(heights)" }, { "docstring": null, "function_declaration": "def maxRectangle(matrix):", "function_name": "maxRectangle", "parameter_list": "(matr...
[ 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 maxHistogramArea(heights):\n stack = []\n max_area = 0\n index = 0\n\n while index < len(heights):\n if not stack or heights[stack[-1]] <= h...
trial_gpt4o_0
{ "original_instruction": "Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.\n\nINPUT\n\nThe first line of the input will be an integer T, denoting the number of test cases. \n\nFor each test case, you will be given the dimensions of the matrix as tw...
0.663466
Taco_90297
C
[ "maxHistogramArea", "maxRectangle", "findLargestRectangleInMatrix" ]
3
[ [ "findLargestRectangleInMatrix", "maxRectangle" ], [ "maxRectangle", "maxHistogramArea" ] ]
2
[]
false
[]
false
pytest
true
[]
true
adeb8dd6522c80c89fc291e63eca809a68ad2cba
cbb3c1c79d5ee96d4be93c00f4b09d21adcf6f93
v1.0
complete
Taco
Taco_90161_C
def is_palindrome(s: str) -> bool: """ Helper function to check if a given string s is a palindrome. >>> is_palindrome('racecar') True >>> is_palindrome('hello') False >>> is_palindrome('A Santa at NASA') True >>> is_palindrome('No lemon, no melon') True >>> is_palindrome('world') False ...
def is_palindrome(s): """ Helper function to check if a given string s is a palindrome """ # Remove non-alphanumeric characters and convert to lowercase normalized_s = ''.join(char.lower() for char in s if char.isalnum()) return normalized_s == normalized_s[::-1] def find_palindromes(words): ...
from solution import find_palindromes, is_palindrome def test_is_palindrome(): assert is_palindrome('racecar') == True assert is_palindrome('hello') == False assert is_palindrome('A Santa at NASA') == True assert is_palindrome('No lemon, no melon') == True assert is_palindrome('world') == False de...
[ { "docstring": "Helper function to check if a given string s is a palindrome", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list of strings from the input list that are palindromes.", "function_dec...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_palindromes(words):\n \"\"\"\n Returns a list of palindromes from the input list of words.\n \"\"\"\n def is_palindrome(word):\n # Remo...
trial_gpt4o_2
{ "original_instruction": "Implement a function that takes a list of strings and returns a new list with all the strings that are palindromes. A palindrome is a word or phrase that reads the same forward and backward, ignoring spaces, punctuation, and case.\n\n```python\ndef find_palindromes(words):\n # Your code ...
0.828641
Taco_90161
C
[ "is_palindrome", "find_palindromes" ]
2
[ [ "find_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4cc385529e6c3460d6fde14bf40203ae416c4142
5cd8db45b76de49dfcf75993e3037ddf44845ee8
v1.0
complete
Taco
Taco_90304_C
def self_dividing_number(num: int) -> bool: """ Checks if a number is a self-dividing number. >>> self_dividing_number(128) True >>> self_dividing_number(102) False >>> self_dividing_number(1) True >>> self_dividing_number(11) True >>> self_dividing_number(12) True >>> se...
def self_dividing_number(num): """ Checks if a number is a self-dividing number. """ original_num = num while num > 0: digit = num % 10 if digit == 0 or original_num % digit != 0: return False num //= 10 return True def self_dividing_numbers(left, right): ...
from solution import self_dividing_number, self_dividing_numbers def test_self_dividing_number(): assert self_dividing_number(128) == True assert self_dividing_number(102) == False assert self_dividing_number(1) == True assert self_dividing_number(11) == True assert self_dividing_number(12) == True...
[ { "docstring": "Checks if a number is a self-dividing number.", "function_declaration": "def self_dividing_number(num):", "function_name": "self_dividing_number", "parameter_list": "(num)" }, { "docstring": "Returns a list of all self-dividing numbers between left and right, inclusive.", ...
[ 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": "def is_self_dividing(number):\n \"\"\"\n Helper function to check if the given number is a self-dividing number.\n \"\"\"\n original_number = number\n ...
trial_gpt4o_9
{ "original_instruction": "Samantha is practicing her coding skills with some fun number games. She recently learned about a fascinating concept called \"self-dividing numbers\". A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1...
0.621454
Taco_90304
C
[ "self_dividing_number", "self_dividing_numbers" ]
2
[ [ "self_dividing_numbers", "self_dividing_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0c5100a03f5a564903d43afc4a6c3ea6078c9d8
2a7ae9f1bfa0e140503253601be4027d63f26c60
v1.0
complete
Taco
Taco_90351_C
def process_grid(n: int, m: int, grid: List[List[int]]) -> List[int]: """ Given an n x m grid filled with integers, find the largest prime number within each row. If a row does not contain any prime number, return -1 for that row. >>> process_grid(3, 4, [[10, 15, 3, 7], [5, 6, 8, 13], [1, 4, 8, 6]]) [7,...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def largest_prime_in_r...
from solution import process_grid def test_example_case(): grid = [ [10, 15, 3, 7], [5, 6, 8, 13], [1, 4, 8, 6], ] assert process_grid(3, 4, grid) == [7, 13, -1] def test_single_row_with_primes(): grid = [ [10, 11, 2, 7], ] assert process_grid(1, 4, grid) == [11...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the largest prime number within each row of the grid.\nIf a row does not contain any prime number, return -1 for that ro...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_2
{ "original_instruction": "Petya is enthusiastic about prime numbers and has recently been pondering over rectangular grids. He stumbled upon a puzzle involving a grid filled with prime numbers and became intrigued.\n\nGiven an n x m grid filled with integers, write a program that finds the largest prime number withi...
0.585527
Taco_90351
C
[ "is_prime", "largest_prime_in_rows", "process_grid" ]
3
[ [ "largest_prime_in_rows", "is_prime" ], [ "process_grid", "largest_prime_in_rows" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1d1938f9987e200650a3a1adce1e960d61f857a6
930b90de8dc3e32ad5e7d9dd3f239a2acabf874b
v1.0
complete
Taco
Taco_90181_C
def minTollCost(N: int, M: int, roads: List[List[int]]) -> int: """ Find the minimum toll cost to connect all houses using Kruskal's algorithm. >>> minTollCost(4, 5, [[1, 2, 5], [1, 3, 10], [2, 3, 7], [2, 4, 4], [3, 4, 3]]) 12 >>> minTollCost(3, 3, [[1, 2, 2], [2, 3, 3], [1, 3, 4]]) 5 """ from typing i...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: ...
from solution import minTollCost def test_minTollCost_example1(): N = 4 M = 5 roads = [[1, 2, 5], [1, 3, 10], [2, 3, 7], [2, 4, 4], [3, 4, 3]] assert minTollCost(N, M, roads) == 12 def test_minTollCost_example2(): N = 3 M = 3 roads = [[1, 2, 2], [2, 3, 3], [1, 3, 4]] assert minTollCost...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\...
trial_gpt4o_2
{ "original_instruction": "In a secluded village, there is a map consisting of N houses connected by M bidirectional roads. Each road has a certain toll associated with it. The villagers want to ensure that their village is well connected in such a way that the total toll cost is minimized. As an expert in algorithms...
0.57506
Taco_90181
C
[ "find", "union", "minTollCost" ]
3
[ [ "minTollCost", "find" ], [ "minTollCost", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
19efeeeb1a4b1546c982f053a3bb03f19b63cfaf
8ce229999f2111bf953313557152534c26082ae9
v1.0
complete
Taco
Taco_90514_C
from typing import List def is_valid_date(date_str: str) -> bool: """ Determines if a given date string is valid. >>> is_valid_date("2020-02-29") True >>> is_valid_date("2019-04-31") False >>> is_valid_date("2020-13-10") False >>> is_valid_date("2100-02-29") False """ pass
def is_valid_date(date_str): """ Determines if a given date string is valid. """ # Split the date into year, month, and day parts = date_str.split('-') if len(parts) != 3: return False year_str, month_str, day_str = parts # Check if all parts are of the correct length if le...
from solution import is_valid_date def test_valid_date(): assert is_valid_date("2020-02-29") == True # Leap year assert is_valid_date("2019-11-30") == True # Normal valid date def test_invalid_date(): assert is_valid_date("2019-02-29") == False # Not leap year assert is_valid_date("0000-00-00") == ...
[ { "docstring": "Determines if a given date string is valid.", "function_declaration": "def is_valid_date(date_str):", "function_name": "is_valid_date", "parameter_list": "(date_str)" }, { "docstring": "Determines if a given year is a leap year.", "function_declaration": "def is_leap_year...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_date(date_str):\n \"\"\"\n Determines if a given date string is valid.\n \"\"\"\n # Split the date into year, month, and day\n parts = ...
trial_gpt4o_0
{ "original_instruction": "Write a function to determine if a given date is valid or not.\n\nA valid date is in \"YYYY-MM-DD\" format where:\n- YYYY is a four-digit number representing the year. The range can be from 0000 to 9999.\n- MM is a two-digit number representing the month with values from 01 (January) to 12 ...
0.854387
Taco_90514
C
[ "is_valid_date", "is_leap_year" ]
2
[ [ "is_valid_date", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c037d9f60ccd8040397772336d5aeddb0e41c827
3ca83f70e46516cbbcbbf571fb927f52846f39cc
v1.0
complete
Taco
Taco_90327_C
import itertools from typing import List def custom_playlists(n: int, k: int, songs: List[str]) -> List[int]: """Determine the number of distinct playlists that can be created by selecting non-overlapping substrings and rearranging them. >>> custom_playlists(3, 4, ['abcd', 'aabb', 'wxyz']) [24, 6...
import itertools def factorial(n): if n == 0 or n == 1: return 1 return n * factorial(n-1) def calculate_playlists_count(song): k = len(song) all_permutations = set([''.join(p) for p in itertools.permutations(song)]) return len(all_permutations) def custom_playlists(n, k, songs): resu...
from solution import custom_playlists def test_single_song(): assert custom_playlists(1, 4, ['abcd']) == [24] # 4! = 24 def test_multiple_songs(): assert custom_playlists(3, 4, ['abcd', 'aabb', 'wxyz']) == [24, 6, 24] def test_repeated_chars(): assert custom_playlists(1, 3, ['aaa']) == [1] # Only one c...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def calculate_playlists_count(song):", "function_name": "calculate_playlists_count", "parameter_list": "(song)"...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef distinct_playlists(songs):\n \"\"\"\n Given a list of songs, returns the number of distinct playlists that can be c...
trial_gpt4o_5
{ "original_instruction": "A music streaming service has implemented a system to create custom playlists based on user preferences. The service collects multiple songs the user is interested in, determined by their recent listens. Each song is represented as a string of lowercase letters, and all songs have the same ...
0.61273
Taco_90327
C
[ "factorial", "calculate_playlists_count", "custom_playlists", "main" ]
4
[ [ "custom_playlists", "calculate_playlists_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd24653108870d20c0c89c4566cc79da20cf9a93
0ca1ca3c139e74d0c29420df33a8fa4c2a244a07
v1.0
complete
Taco
Taco_90261_C
from typing import List, Tuple def minimum_total_distance(N: int, M: int, P: int, distribution_centers: List[int], roads: List[Tuple[int, int, int]]) -> int: """ Calculate the minimum total distance required to ensure all distribution centers can communicate. Args: N (int): Number of cities. M (int): N...
def floyd_warshall(n, roads): # Initialize distance matrix dist = [[float('inf')] * n for _ in range(n)] for i in range(n): dist[i][i] = 0 for (u, v, w) in roads: dist[u-1][v-1] = w dist[v-1][u-1] = w # Apply Floyd-Warshall for k in range(n): for i in range(n): ...
def test_minimum_total_distance_example_1(): N, M, P = 5, 6, 3 distribution_centers = [1, 3, 5] roads = [ (1, 2, 2), (2, 3, 3), (2, 4, 4), (3, 5, 1), (4, 5, 6), (5, 1, 7) ] assert minimum_total_distance(N, M, P, distribution_centers, roads) == 6 def t...
[ { "docstring": null, "function_declaration": "def floyd_warshall(n, roads):", "function_name": "floyd_warshall", "parameter_list": "(n, roads)" }, { "docstring": null, "function_declaration": "def minimum_spanning_tree_cost(p_indices, dist):", "function_name": "minimum_spanning_tree_...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start, n):\n distances = [float('inf')] * (n + 1)\n distances[start] = 0\n priority_queue = [(0, start)]\n \n wh...
trial_gpt4o_7
{ "original_instruction": "In a certain state, there are N cities connected by M bidirectional roads. Each road connects two distinct cities A_i and B_i and has a length of C_i. A network of distributors needs to ensure the shortest delivery paths between specific distribution centers. Given P distribution centers, p...
0.688417
Taco_90261
C
[ "floyd_warshall", "minimum_spanning_tree_cost", "minimum_total_distance" ]
3
[ [ "minimum_total_distance", "floyd_warshall" ], [ "minimum_total_distance", "minimum_spanning_tree_cost" ] ]
2
[]
false
[]
false
pytest
false
[]
true
2242c2101bdb2031dc28ef5da09f11d0b430f4c0
e42b62ca6d7fe12504391a9f4614e315bbf7a9d1
v1.0
complete
Taco
Taco_90535_C
import math from typing import List def is_perfect_square(n: int) -> bool: """ Check if a number is a perfect square. """ root = int(math.sqrt(n)) return n == root * root def organize_books(book_ids: List[int]) -> List[int]: """ Organize the book identifiers such that perfect squares come ...
import math def is_perfect_square(n): """ Check if a number is a perfect square. """ root = int(math.sqrt(n)) return n == root * root def organize_books(book_ids): """ Organize the book identifiers such that perfect squares come first, followed by non-perfect squares sorted in ascendin...
from solution import organize_books def test_organize_books_all_perfect_squares(): assert organize_books([1, 4, 9, 16, 25]) == [1, 4, 9, 16, 25] def test_organize_books_no_perfect_squares(): assert organize_books([3, 5, 7, 8, 10]) == [3, 5, 7, 8, 10] def test_organize_books_mixed(): assert organize_books...
[ { "docstring": "Check if a number is a perfect square.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Organize the book identifiers such that perfect squares come first,\nfollowed by non-perfect squares ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(n):\n \"\"\"Check if a number is a perfect square.\"\"\"\n return n == int(math.sqrt(n)) ** 2\n\ndef organize_books(book...
trial_gpt4o_4
{ "original_instruction": "### The Story:\nAnita is a librarian who needs your help to organize a huge stack of books by their identifiers. Each book has a unique identifier number. To make her task easier, she wants you to sort a list of these book identifiers. The catch is, she wants to maintain a special order: An...
0.568801
Taco_90535
C
[ "is_perfect_square", "organize_books" ]
2
[ [ "organize_books", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac6cce4e9a7b281b8b889138732dbfae7543585f
7b627f55f88d2bb76e0195fc3fe658a1918a5467
v1.0
complete
Taco
Taco_90111_C
def sieve_of_eratosthenes(max_num): """ Computes prime numbers up to max_num using the Sieve of Eratosthenes. """ sieve = [True] * (max_num + 1) sieve[0] = sieve[1] = False # 0 and 1 are not prime numbers for start in range(2, isqrt(max_num) + 1): if sieve[start]: for multip...
from math import isqrt def sieve_of_eratosthenes(max_num): """ Computes prime numbers up to max_num using the Sieve of Eratosthenes. """ sieve = [True] * (max_num + 1) sieve[0] = sieve[1] = False # 0 and 1 are not prime numbers for start in range(2, isqrt(max_num) + 1): if sieve[start]...
import pytest from solution import solve def test_example_1(): t = 2 test_cases = [ (6, 2, 5, [6, 10, 15, 20, 25, 30]), (5, 3, 7, [14, 21, 28, 35, 42]), ] results = solve(t, test_cases) assert results == [6, 5] def test_edge_case_no_primes(): t = 1 test_cases = [ (4...
[ { "docstring": "Computes prime numbers up to max_num using the Sieve of Eratosthenes.", "function_declaration": "def sieve_of_eratosthenes(max_num):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(max_num)" }, { "docstring": "Finds all prime numbers in the range [m, p].", ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(max_num):\n \"\"\" Helper function to generate a list of prime numbers up to max_num using the Sieve of Eratosthenes algorithm. \"\"\"...
trial_gpt4o_4
{ "original_instruction": "You are given an integer array $A$ of length $n$. Your task is to find the maximum length of a subarray where every element is divisible by at least one prime number in the range $[m, p]$. \n\nA subarray is a contiguous part of an array.\n\nConsider the following example for clarity. \n\n--...
0.653213
Taco_90111
C
[ "sieve_of_eratosthenes", "primes_in_range", "max_subarray_length_divisible_by_primes", "solve" ]
4
[ [ "max_subarray_length_divisible_by_primes", "primes_in_range" ], [ "primes_in_range", "sieve_of_eratosthenes" ], [ "solve", "max_subarray_length_divisible_by_primes" ] ]
3
[]
false
[]
false
pytest
true
[]
true
786f1dae32cf63544dcb7d4fe4d0ebc335c14545
eca3bcb6fbbac95ae465a2402e7ba656f71c2b28
v1.0
complete
Taco
Taco_90139_C
from typing import List, Tuple class TreeNode: def __init__(self, value): self.value = value self.children = [] def increment_subtree(node: TreeNode, inc: int) -> None: """ Increment all node values in a specific subtree by a given value. Args: node (TreeNode): The root node of the sub...
class TreeNode: def __init__(self, value): self.value = value self.children = [] def increment_subtree(node, inc): if node: node.value += inc for child in node.children: increment_subtree(child, inc) def find_max_in_subtree(node): if not node: return flo...
import pytest from solution import TreeNode, increment_subtree, find_max_in_subtree, solve_tree_problem def test_increment_subtree(): node = TreeNode(1) child1 = TreeNode(2) child2 = TreeNode(3) node.children = [child1, child2] increment_subtree(node, 2) assert node.value == 3 assert c...
[]
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def solve_tree_queries(n, node_values, edges, queries):\n from collections import defaultdict, deque\n \n # Build the tree adjace...
trial_gpt4o_3
{ "original_instruction": "You are given a binary tree with n nodes. Each node in the tree has a positive integer value. You need to answer several queries about the tree. Each query can be one of the following types:\n\n* Increment all node values in a specific subtree by a given value.\n* Find the maximum value in ...
0.545683
Taco_90139
C
[ "increment_subtree", "find_max_in_subtree", "solve_tree_problem" ]
3
[ [ "solve_tree_problem", "find_max_in_subtree" ], [ "solve_tree_problem", "increment_subtree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
c5eea2e453afa945485a3c90d61a70baacea050f
6958e3c9692f0922dd14ae18eafab48d29a28e3a
v1.0
complete
Taco
Taco_90613_C
def process_input(input_str: str): """ Determine the number of unique molecules that can be bonded together starting from a specific molecule through direct and indirect bonds. Args: input_str (str): Input string containing multiple datasets. Each dataset includes n, d followed by n lines of coordinate...
import math def euclidean_distance(x1, y1, x2, y2): return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) def find_bonded_molecules(n, d, molecules): bonded = [False] * n queue = [0] bonded[0] = True count = 1 while queue: current = queue.pop(0) for i in range(n): if n...
from solution import process_input def test_dataset_1(): input_str = "3 10\n1.000 1.000\n2.000 2.000\n15.000 15.000\n0 0" expected_output = [2] assert process_input(input_str) == expected_output def test_dataset_2(): input_str = "5 7\n3.000 3.000\n10.000 10.000\n3.500 4.000\n17.000 17.000\n1.000 1.500...
[ { "docstring": null, "function_declaration": "def euclidean_distance(x1, y1, x2, y2):", "function_name": "euclidean_distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def find_bonded_molecules(n, d, molecules):", "function_name": "find_bo...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_bonded_molecules(data):\n from math import sqrt\n\n def distance(p1, p2):\n return sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\n \n...
trial_gpt4o_2
{ "original_instruction": "You are part of a research team studying the behavior of molecules in a container. Each molecule is represented by a point in a 2D plane, and molecules interact with one another through a process called \"magnetic bonding.\" Two molecules will form a magnetic bond if they are within a certa...
0.55778
Taco_90613
C
[ "euclidean_distance", "find_bonded_molecules", "process_input" ]
3
[ [ "find_bonded_molecules", "euclidean_distance" ], [ "process_input", "find_bonded_molecules" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
54fe5e47a53aa86a1d16fe0905541606f3b0da44
081163105fb247b2ef4c846b73c6f5bc14ba8c70
v1.0
complete
Taco
Taco_90676_C
def can_distribute_problems_fairly(t: int, test_cases: List[Tuple[int, int]]) -> List[str]: """ Determine if it is possible to distribute the problems to participants fairly. Args: t (int): The number of test cases. test_cases (List[Tuple[int, int]]): A list containing tuples with number of part...
def can_distribute_problems_fairly(t, test_cases): results = [] for case in test_cases: n, p = case if (p % n == 0) or (p % n == n - 1): results.append("YES") else: results.append("NO") return results # Function to preprocess input and call function def solve...
from solution import can_distribute_problems_fairly def test_case_1(): t = 3 test_cases = [(3, 8), (2, 5), (4, 10)] assert can_distribute_problems_fairly(t, test_cases) == ["YES", "YES", "NO"] def test_case_2(): t = 2 test_cases = [(1, 1), (100, 10000)] assert can_distribute_problems_fairly(t,...
[ { "docstring": null, "function_declaration": "def can_distribute_problems_fairly(t, test_cases):", "function_name": "can_distribute_problems_fairly", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "par...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_distribute_fairly(t, test_cases):\n results = []\n for case in test_cases:\n n, p = case\n if p // n == p // n + 1 or p // n == p // n:...
trial_gpt4o_3
{ "original_instruction": "Alice is hosting a coding contest and wants to distribute a certain number of problems to the participants in a fair manner. To make it fair, she decides that no two participants should get a difference of more than one problem. She wants to determine whether it is possible to distribute al...
0.557555
Taco_90676
C
[ "can_distribute_problems_fairly", "solve" ]
2
[ [ "solve", "can_distribute_problems_fairly" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c0414f6cf3d6e2c5c0c474a974bf0da610290ff0
37f78722a3fe6a4a1c06410f4f972c04fc115133
v1.0
complete
Taco
Taco_90239_C
def employee_of_the_month(employee_data): """ Given a list of employee data tuples (name, department, points), returns a dictionary with departments as keys and the employee with the highest points as values. """ pass def format_employee_of_the_month(employee_data): """ Given a list of...
def employee_of_the_month(employee_data): """ Given a list of employee data tuples (name, department, points), returns a dictionary with departments as keys and the employee with the highest points as values. """ department_best = {} for name, department, points in employee_data: ...
from solution import employee_of_the_month, format_employee_of_the_month def test_basic_case(): employees = [ ("Alice", "HR", 88), ("Bob", "IT", 92), ("Charlie", "HR", 90), ("David", "IT", 85), ("Eve", "HR", 88), ("Frank", "IT", 92) ] result = employee_of_the...
[ { "docstring": "Given a list of employee data tuples (name, department, points),\nreturns a dictionary with departments as keys and the \nemployee with the highest points as values.", "function_declaration": "def employee_of_the_month(employee_data):", "function_name": "employee_of_the_month", "para...
[ 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_employee_of_the_month(employee_data):\n \"\"\"\n Determines the Employee of the Month for each department based on points.\n \"\"\"\n departme...
trial_gpt4o_2
{ "original_instruction": "The XYZ Company has launched a special program called \"Employee of the Month.\" For this program, each department selects an employee based on their performance and assigns them points. The company wishes to automate the process of determining the Employee of the Month based on the points ...
0.667842
Taco_90239
C
[ "employee_of_the_month", "format_employee_of_the_month" ]
2
[ [ "format_employee_of_the_month", "employee_of_the_month" ] ]
1
[]
false
[]
false
pytest
true
[]
true
621bc5769888e06335f9ce6ec86afd2bb87499e4
68e9b1e22401d5a015fce375c646c4351097ac65
v1.0
complete
Taco
Taco_90376_C
def find_median(scores): """ Given a list of scores, find the median score. If the number of scores is even, the median is the average of the two middle scores. If the number of scores is odd, the median is the middle score. Args: scores (List[int]): List of scores of team members. Ret...
def find_median(scores): scores.sort() n = len(scores) mid = n // 2 if n % 2 == 0: # Even number of elements return (scores[mid - 1] + scores[mid]) / 2 else: # Odd number of elements return scores[mid] def sort_teams_by_median(T, N, teams_scores): teams_with_medians = [] f...
from solution import find_median, sort_teams_by_median def test_find_median(): assert find_median([50, 80, 90, 70]) == 75.0 assert find_median([60, 40, 100, 50]) == 55.0 assert find_median([30, 20, 60, 10]) == 25.0 assert find_median([1, 2, 3]) == 2 assert find_median([5, 7, 9, 3, 1]) == 5 asse...
[ { "docstring": null, "function_declaration": "def find_median(scores):", "function_name": "find_median", "parameter_list": "(scores)" }, { "docstring": null, "function_declaration": "def sort_teams_by_median(T, N, teams_scores):", "function_name": "sort_teams_by_median", "paramet...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_median(scores):\n scores.sort()\n n = len(scores)\n mid = n // 2\n if n % 2 == 0: # Even number of elements\n return (scores[mid - 1] ...
trial_gpt4o_0
{ "original_instruction": "Chef is organizing a marathon where $T$ teams participate. Each team has $N$ members. At the end of the marathon, each team receives a score based on the performance of its members. The score of a team is calculated as follows:\n- Consider the performance scores of all members of the team.\...
0.687835
Taco_90376
C
[ "find_median", "sort_teams_by_median", "marathon" ]
3
[ [ "marathon", "sort_teams_by_median" ], [ "sort_teams_by_median", "find_median" ] ]
2
[]
false
[]
false
pytest
true
[]
true
eea8a96e76a52feb675898c4268b13245ce0de8e
4e15217dffcf293f3f4b35ddcee5a3c9edc19a98
v1.0
complete
Taco
Taco_90364_C
def largest_number(nums: List[int]) -> str: """ Find the largest number that can be constructed by concatenating all the integers in the array. >>> largest_number([10, 2]) "210" >>> largest_number([3, 30, 34, 5, 9]) "9534330" >>> largest_number([1]) "1" >>> largest_number([0]) "0" >>> largest_nu...
def compare(x, y): if x + y > y + x: return -1 else: return 1 def largest_number(nums): nums = list(map(str, nums)) for i in range(len(nums)): for j in range(len(nums) - 1, i, -1): if compare(nums[j-1], nums[j]) > 0: nums[j], nums[j-1] = nums[j-1...
from solution import largest_number def test_example_cases(): assert largest_number([10, 2]) == "210" assert largest_number([3, 30, 34, 5, 9]) == "9534330" def test_single_element(): assert largest_number([1]) == "1" assert largest_number([0]) == "0" def test_leading_zeros(): assert largest_numbe...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_number(nums):", "function_name": "largest_number", "parameter_list": "(nums)" } ]
[ 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 compare(x, y):\n \"\"\"\n Compares two numbers x and y for sorting in a way that constructs the largest possible number.\n \"\"\"\n return (x + y) ...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers. Your task is to find the largest number that can be constructed by concatenating all the integers in the array.\n\nYour function should return this largest number as a string.\n\nNote:\n- Each integer in the array is non-negative.\n- The array may contain...
0.732374
Taco_90364
C
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cbda9a84406a4627313cc1f5e8e50f7f2944238c
78566965e0936c9dcdc926b9844e064b6053de55
v1.0
complete
Taco
Taco_90548_C
def is_prime(x): """ Helper function to check if a number is prime. """ pass def next_prime(N): """ Function to find the smallest prime number greater than N. >>> next_prime(10) 11 >>> next_prime(31) 37 """ pass from solution import next_prime def test_next_prime_after_10(): ...
def is_prime(x): """ Helper function to check if a number is prime. """ if x <= 1: return False if x <= 3: return True if x % 2 == 0 or x % 3 == 0: return False i = 5 while i * i <= x: if x % i == 0 or x % (i + 2) == 0: return False i +...
from solution import next_prime def test_next_prime_after_10(): assert next_prime(10) == 11 def test_next_prime_after_31(): assert next_prime(31) == 37 def test_next_prime_after_0(): assert next_prime(0) == 2 def test_next_prime_after_1(): assert next_prime(1) == 2 def test_next_prime_after_50(): ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(x):", "function_name": "is_prime", "parameter_list": "(x)" }, { "docstring": "Function to find the smallest prime number greater than N.", "function_declaration": "def next_prime(N):", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_1
{ "original_instruction": "Given an integer N, write a function to find the smallest prime number greater than N. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\nExample 1:\nInput: N = 10\nOutput: 11\nExplanation: The prime numbers greater than 10 are 11, 13, ...
0.809643
Taco_90548
C
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6f92a873bfb5f1457f7acde118805dae7e6a648e
886f098c4ae5db14b881f75259814acbb891ee19
v1.0
complete
Taco
Taco_90453_C
from typing import List def sieve_of_eratosthenes(limit: int) -> List[int]: """ Generate a list of prime numbers up to a given limit. >>> sieve_of_eratosthenes(10) [2, 3, 5, 7] >>> sieve_of_eratosthenes(20) [2, 3, 5, 7, 11, 13, 17, 19] """ pass def get_prime_factors_count(num: int, primes:...
from collections import defaultdict def sieve_of_eratosthenes(limit): primes = [True] * (limit + 1) p = 2 while p * p <= limit: if primes[p] == True: for i in range(p * p, limit + 1, p): primes[i] = False p += 1 prime_numbers = [p for p in range(2, limit + 1)...
def test_sieve_of_eratosthenes(): from solution import 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] def test_get_prime_factors_count(): from solution import get_prime_factors_count, sieve_of_eratosthenes prim...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def get_prime_factors_count(num, primes):", "function_name": "get_prime_factors_cou...
[ 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 sieve(n):\n \"\"\"\n Returns a list `prime` where prime[i] is True if i is a prime number, False otherwise.\n \"\"\"\n prime = [True] * (n + 1)\n ...
trial_gpt4o_2
{ "original_instruction": "Given a large array of integers, implement a program to efficiently compute the number of distinct prime factors for each element in the array and print the maximum number of distinct prime factors present in any single element.\n\n### Input Format\n- The first line contains an integer, $n$...
0.748063
Taco_90453
C
[ "sieve_of_eratosthenes", "get_prime_factors_count", "max_distinct_prime_factors", "main" ]
4
[ [ "max_distinct_prime_factors", "get_prime_factors_count" ], [ "max_distinct_prime_factors", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9acf2c4ed3feb677b626edbd5569bfe5336ff064
e1d86341656c04462a435440c4010f1fd9dc4aee
v1.0
complete
Taco
Taco_90663_C
def number_of_unique_routes(N: int, coordinates: List[int]) -> int: """ A drone delivery company wants to optimize their flight routes. Each route is defined by starting and ending coordinates in a 2D plane, and the company has a list of such routes they need to analyze. Two routes are considered redundant if their...
def find_unique_routes(routes): def on_segment(p, q, r): """Check if point q lies on line segment pr""" if q[0] <= max(p[0], r[0]) and q[0] >= min(p[0], r[0]) and q[1] <= max(p[1], r[1]) and q[1] >= min(p[1], r[1]): return True return False def orientation(p, q, r): ...
def test_case_1(): assert number_of_unique_routes(5, [0, 0, 2, 2, 3, 3, 5, 5, 0, 0, 2, 2, 6, 6, 8, 8, 1, 1, 4, 4]) == 3 def test_case_2(): # Non-overlapping routes assert number_of_unique_routes(3, [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 3 def test_case_3(): # All routes are the same assert numbe...
[ { "docstring": null, "function_declaration": "def find_unique_routes(routes):", "function_name": "find_unique_routes", "parameter_list": "(routes)" }, { "docstring": null, "function_declaration": "def number_of_unique_routes(N, coordinates):", "function_name": "number_of_unique_route...
[ 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 shapely.geometry import LineString\n\ndef count_unique_routes(n, coordinates):\n \"\"\"\n Returns the number of unique, non-overlapping routes.\n \n ...
trial_gpt4o_1
{ "original_instruction": "A drone delivery company wants to optimize their flight routes. Each route is defined by starting and ending coordinates in a 2D plane, and the company has a list of such routes they need to analyze. Two routes are considered redundant if their paths overlap completely or partially. Your ta...
0.599294
Taco_90663
C
[ "find_unique_routes", "number_of_unique_routes" ]
2
[ [ "number_of_unique_routes", "find_unique_routes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
349d234c60e778943cc0287ddbfb7703e5fe14e1
82d61221c0045a52a64f9848e7b06a729523593d
v1.0
complete
Taco
Taco_90356_C
def int_to_roman(num): """ Convert an integer to a Roman numeral. """ val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syms = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ...
def int_to_roman(num): """ Convert an integer to a Roman numeral. """ val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syms = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ...
from solution import to_roman def test_to_roman(): assert to_roman(1) == ["I"] assert to_roman(3) == ["I", "II", "III"] assert to_roman(5) == ["I", "II", "III", "IV", "V"] assert to_roman(10) == ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"] def test_to_roman_edge_cases(): assert to...
[ { "docstring": "Convert an integer to a Roman numeral.", "function_declaration": "def int_to_roman(num):", "function_name": "int_to_roman", "parameter_list": "(num)" }, { "docstring": "Returns a list of strings representing the Roman numeral representation\nof all numbers from 1 to n (inclus...
[ 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 to_roman(n):\n \"\"\"\n Returns a list of Roman numeral representations for all numbers from 1 to n (inclusive).\n \"\"\"\n def int_to_roman(num):\...
trial_gpt4o_2
{ "original_instruction": "# Task\n\nWrite a function that takes an integer as input and returns a list of strings representing the Roman numeral representation of all numbers from 1 to that integer (inclusive).\n\nRoman numerals are represented by the following symbols:\n\n- I -> 1\n- V -> 5\n- X -> 10\n- L -> 5...
0.736912
Taco_90356
C
[ "int_to_roman", "to_roman" ]
2
[ [ "to_roman", "int_to_roman" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c13e4c6bf90703d4e272c00296b067279bbec33d
1b605d6133ad006c955b08016e7853f1fe2b6ed7
v1.0
complete
Taco
Taco_90226_C
import math from typing import List, Tuple def is_intersecting_circle(x1: int, y1: int, x2: int, y2: int, cx: int, cy: int, r: int) -> bool: """ Helper function to determine if a line segment intersects a circle. """ pass def flight_path(n: int, restricted_zones: List[Tuple[int, int, int]], x_s: int, y_s: int...
import math def is_intersecting_circle(x1, y1, x2, y2, cx, cy, r): # Translate coordinates so that the circle's center is at the origin x1, y1, x2, y2 = x1 - cx, y1 - cy, x2 - cx, y2 - cy dx = x2 - x1 dy = y2 - y1 # Coefficients of the quadratic equation a = dx ** 2 + dy ** 2 b = ...
from solution import flight_path def test_no_intersection(): assert flight_path(2, [(15, 15, 5), (25, 25, 5)], 0, 0, 10, 10) == "SAFE" def test_single_restricted_zone(): assert flight_path(1, [(15, 15, 10)], 0, 0, 30, 30) == "RESTRICTED" def test_multiple_restricted_zones(): assert flight_path(3, [(10, 1...
[ { "docstring": null, "function_declaration": "def is_intersecting_circle(x1, y1, x2, y2, cx, cy, r):", "function_name": "is_intersecting_circle", "parameter_list": "(x1, y1, x2, y2, cx, cy, r)" }, { "docstring": null, "function_declaration": "def flight_path(n, restricted_zones, x_s, y_s...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_intersecting_circle(x_center, y_center, radius, x1, y1, x2, y2):\n \"\"\"\n Determine if the line segment from (x1, y1) to (x2, y2) int...
trial_gpt4o_2
{ "original_instruction": "Your company, AeroPath, has been developing an application to assist pilots in determining optimal flight paths. The application needs to account for various air traffic constraints and output a safe and efficient route for the pilots.\n\nOne specific problem that needs solving is determini...
0.709361
Taco_90226
C
[ "is_intersecting_circle", "flight_path" ]
2
[ [ "flight_path", "is_intersecting_circle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
98460b0cb04910873f2172caf528f6dc4421bbb0
1187bb629b39c581938af85ef995a3b5996da244
v1.0
complete
Taco
Taco_90034_C
def art_installation(R: int, C: int, K: int, park_grid: List[str], D: int) -> str: """ Determine if it is possible to place K art pieces on trees in the park grid such that the Euclidean distance between any two art pieces is at least D. Args: R (int): Number of rows in the park grid. C (...
from itertools import combinations import math def is_valid_distance(x1, y1, x2, y2, D): """Check if distance between two points (x1, y1) and (x2, y2) is at least D.""" return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) >= D def can_place_art_pieces(grid, R, C, K, D): # Collect all positions of 'T' tre...
from solution import art_installation def test_art_installation_example_case(): R, C, K = 5, 5, 3 park_grid = [ "T.T..", ".TT.T", ".....", ".T.T.", "TTTTT" ] D = 2 assert art_installation(R, C, K, park_grid, D) == "YES" def test_art_installation_no_solution(...
[ { "docstring": "Check if distance between two points (x1, y1) and (x2, y2) is at least D.", "function_declaration": "def is_valid_distance(x1, y1, x2, y2, D):", "function_name": "is_valid_distance", "parameter_list": "(x1, y1, x2, y2, D)" }, { "docstring": null, "function_declaration": "...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom itertools import combinations\n\ndef can_place_art_pieces(R, C, K, park, D):\n trees = [(i, j) for i in range(R) for j in range(C) if park[i][...
trial_gpt4o_2
{ "original_instruction": "Miranda is interested in creating a new art installation for a city park. The installation consists of placing art pieces on several trees distributed throughout the park. The park can be viewed as a grid with R rows and C columns, where each cell contains either a tree ('T') or an empty sp...
0.625472
Taco_90034
C
[ "is_valid_distance", "can_place_art_pieces", "art_installation" ]
3
[ [ "art_installation", "can_place_art_pieces" ], [ "can_place_art_pieces", "is_valid_distance" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6fd10fe5afb0a3d0fb626ee37aa3e01aafcb2aa6
4cdd2f1bd66f54e2b7b80f4591690d49ff97c1c5
v1.0
complete
Taco
Taco_90561_C
def process_logs(input_data: str) -> list: """ Determines the highest priority message exchange for a given robot within a specific hour. Parameters: input_data (str): Input data containing multiple test cases. Returns: list: List of results for each test case in the format "<sender_id> <receiv...
def highest_priority_message(logs, robot_id, hour): """ Finds the highest priority message for the given robot_id within the specified hour. Parameters: logs (list): List of message logs as tuples (sender_id, receiver_id, priority_level). robot_id (str): The robot's unique identifier. hour (int...
from solution import process_logs def test_sample_input(): input_data = """2 robot007 3 5 robotA robotB 4 robotB robot007 10 robot007 robotC 8 alpha 2 2 alpha beta 5 gamma alpha 3""" expected_output = ["robotB robot007 10", "alpha beta 5"] assert process_logs(input_data) == expected_output def test_n...
[ { "docstring": "Finds the highest priority message for the given robot_id within the specified hour.\n\nParameters:\nlogs (list): List of message logs as tuples (sender_id, receiver_id, priority_level).\nrobot_id (str): The robot's unique identifier.\nhour (int): The hour during which the messages were sent.\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 highest_priority_message(test_cases):\n results = []\n\n for case in test_cases:\n robot_id, n, h, messages = case\n highest_priority = -1\...
trial_gpt4o_1
{ "original_instruction": "The year is 3022 and the world is now governed by a robotic council. Communication between the robots happens through secure encrypted messages. Each robot is identified by a unique ID, represented by an alphanumeric string. \n\nEvery robot can send a message to any other robot. Each messag...
0.588351
Taco_90561
C
[ "highest_priority_message", "process_test_case", "process_logs" ]
3
[ [ "process_logs", "process_test_case" ], [ "process_test_case", "highest_priority_message" ] ]
2
[ "process_test_case" ]
false
[]
false
pytest
true
[]
true
83bef107222dce2c3312b2c826c240680767c68b
9e3b9eb8453aaa3a8277de271204557e7a81671a
v1.0
complete
Taco
Taco_90508_C
def find_all_sequences(T: int): """ Finds all distinct sequences of positive integers that sum up to T. >>> find_all_sequences(5) 1 1 1 1 1 1 1 1 2 1 1 3 1 2 2 1 4 2 3 5 >>> find_all_sequences(1) 1 """
def find_sequences(total, current_sequence, result): """ Helper function to find all distinct sequences of positive integers that sum up to `total`. """ if total == 0: result.append(current_sequence[:]) return start = current_sequence[-1] if current_sequence else 1 for i in rang...
from solution import find_all_sequences def test_find_all_sequences_for_5(capfd): find_all_sequences(5) out, _ = capfd.readouterr() assert out.strip() == "1 1 1 1 1\n1 1 1 2\n1 1 3\n1 2 2\n1 4\n2 3\n5" def test_find_all_sequences_for_1(capfd): find_all_sequences(1) out, _ = capfd.readouterr() ...
[ { "docstring": "Helper function to find all distinct sequences of positive integers that sum up to `total`.", "function_declaration": "def find_sequences(total, current_sequence, result):", "function_name": "find_sequences", "parameter_list": "(total, current_sequence, result)" }, { "docstri...
[ 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 partition(n):\n def helper(n, max_num, path, res):\n if n == 0:\n res.append(path)\n return\n for i in range(1, max_num ...
trial_gpt4o_1
{ "original_instruction": "In a distant village, there is a magical well with an infinite amount of water. Every day, the villagers fetch water from the well into jars. Each villager receives a specific number of jars, and the total number of jars fetched in a day forms a sequence.\n\nUnfortunately, at the end of eac...
0.656241
Taco_90508
C
[ "find_sequences", "find_all_sequences" ]
2
[ [ "find_all_sequences", "find_sequences" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7de4277eb72a4b2f8e4f552750c413ba772aea9
aef3a0b19ad4954a2bb175c0c7f0ed23043f62b7
v1.0
complete
Taco
Taco_90901_C
from typing import List, Tuple def time_difference(start: str, finish: str) -> int: """ Calculate the difference in seconds between start and finish times. Both start and finish are strings in "HH:MM:SS" format. """ pass # Implement the logic to calculate time difference in seconds def marath...
from datetime import datetime def time_difference(start, finish): """ Calculate the difference in seconds between start and finish times. Both start and finish are strings in "HH:MM:SS" format. """ FMT = '%H:%M:%S' # Time format tdelta = datetime.strptime(finish, FMT) - datetime.strptime(start...
from solution import marathon_times def test_marathon_times(): test_cases = [ (3, [("08:00:00", "11:00:00"), ("07:30:00", "10:45:00"), ("09:15:00", "12:45:00")]) ] expected_output = [ [10800, 11700, 12600] ] assert marathon_times(test_cases) == expected_output def test_ed...
[ { "docstring": "Calculate the difference in seconds between start and finish times.\nBoth start and finish are strings in \"HH:MM:SS\" format.", "function_declaration": "def time_difference(start, finish):", "function_name": "time_difference", "parameter_list": "(start, finish)" }, { "docstr...
[ 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 datetime import datetime\n\ndef time_difference(start, finish):\n \"\"\"\n Calculate the difference in seconds between start and finish times.\n Both...
trial_gpt4o_0
{ "original_instruction": "The city of Algoville is holding a marathon event. You have been tasked with timing the runners. During the event, you will receive a series of timestamps that indicate when a runner crosses the start line and when they finish.\n\nWrite a program to compute the total time each runner took t...
0.540416
Taco_90901
C
[ "time_difference", "marathon_times", "read_input" ]
3
[ [ "marathon_times", "time_difference" ] ]
1
[ "read_input" ]
false
[]
false
pytest
true
[]
true
dfaec2cac4a94c2abae49a7e70a4c6f76ae0ddc4
9d1f8ff45ba881f1f3e4b00c821989959b425379
v1.0
complete
Taco
Taco_91007_C
def specialReverse(N: int, K: int, A: List[int]) -> List[int]: """ Reverse the array from 0 to K-1 and then reverse the array from K to N-1. Finally, reverse the whole array of size N. >>> specialReverse(5, 3, [1, 2, 3, 4, 5]) [4, 5, 1, 2, 3] >>> specialReverse(7, 4, [1, 2, 3, 4, 5, 6, 7]) [...
def reverse(arr, start, end): while start < end: arr[start], arr[end] = arr[end], arr[start] start += 1 end -= 1 def specialReverse(N, K, A): """ Reverse the array from 0 to K-1 and then reverse the array from K to N-1. Finally, reverse the whole array of size N. """ # R...
from solution import specialReverse def test_specialReverse_example1(): N = 5 K = 3 A = [1, 2, 3, 4, 5] expected_output = [4, 5, 1, 2, 3] assert specialReverse(N, K, A) == expected_output def test_specialReverse_example2(): N = 7 K = 4 A = [1, 2, 3, 4, 5, 6, 7] expected_output = [5...
[ { "docstring": null, "function_declaration": "def reverse(arr, start, end):", "function_name": "reverse", "parameter_list": "(arr, start, end)" }, { "docstring": "Reverse the array from 0 to K-1 and then reverse the array from K to N-1.\nFinally, reverse the whole array of size N.", "fun...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def specialReverse(arr, N, K):\n \"\"\"\n Reverses the array from 0 to K-1 and then from K to N-1, finally reverses the whole array.\n \"\"\"\n if not ...
trial_gpt4o_6
{ "original_instruction": "You are given an array which contains integers and an integer value K. Reverse the array from 0 to K-1 and then reverse the array from K to N-1. Finally, reverse the whole array of size N.\n\nExample 1:\nInput:\nN = 5, K = 3\nA[] = {1, 2, 3, 4, 5}\nOutput:\n4 5 1 2 3\n\nExample 2:\nInput:\n...
0.686521
Taco_91007
C
[ "reverse", "specialReverse" ]
2
[ [ "specialReverse", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
153e919f16a5ecc05eb06c5b87bfa0581e218193
11a880967b2f673e124d59b8ffe60248c999de61
v1.0
complete
Taco
Taco_91216_C
def number_of_paths(grid): """ Calculate the number of different paths from top-left to bottom-right of a grid. :param grid: A list of strings representing the grid. :return: The number of different paths. >>> number_of_paths([ ... '...', ... '.#.', ... '...']) == 2 >>> num...
def number_of_paths(grid): """ Calculate the number of different paths from top-left to bottom-right of a grid. :param grid: A list of strings representing the grid. :return: The number of different paths. """ N = len(grid) M = len(grid[0]) if grid[0][0] == '#' or grid[N-1][M-1...
from solution import number_of_paths def test_number_of_paths_case_1(): grid = [ '...', '.#.', '...' ] assert number_of_paths(grid) == 2 def test_number_of_paths_case_2(): grid = [ '.#', '#.' ] assert number_of_paths(grid) == 0 def test_number_of_paths_...
[ { "docstring": "Calculate the number of different paths from top-left to bottom-right of a grid.\n\n:param grid: A list of strings representing the grid.\n:return: The number of different paths.", "function_declaration": "def number_of_paths(grid):", "function_name": "number_of_paths", "parameter_li...
[ 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_paths(grid):\n \"\"\"\n Returns the number of different paths the robot can take to reach the bottom-right corner\n from the top-left corner of ...
trial_gpt4o_1
{ "original_instruction": "In a robotics competition, a robot needs to navigate through a grid. The robot starts at the top-left corner (1, 1) and needs to reach the bottom-right corner (N, M). However, there are certain obstacles in the grid which the robot cannot traverse. The robot can only move right or down from...
0.676009
Taco_91216
C
[ "number_of_paths", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "number_of_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d6747837c425d33c6ff58b575212158f473fff65
f002cd3b4a4f412c93ecd2bef422c719683c37de
v1.0
complete
Taco
Taco_91051_C
from typing import List def process_operations(s: str, n: int, operations: List[List[str]]) -> str: """Perform a series of operations on the string `s`. Each operation is described by a group of three components (op, x, y): - 'R' (reverse) operation: Reverse the substring of `s` from index `x` to `y`, inc...
def manipulate_string(s, operations): result = s for op in operations: if op[0] == 'R': start, end = int(op[1]), int(op[2]) result = result[:start] + result[start:end + 1][::-1] + result[end + 1:] elif op[0] == 'C': concat_str = op[1] resu...
from solution import process_operations def test_process_operations_case1(): initial_string = "abcde" operations = [["R", "1", "3"], ["C", "xyz"], ["S", "xyz", "deab"]] assert process_operations(initial_string, 3, operations) == "NO" def test_process_operations_case2(): initial_string = "hello" op...
[ { "docstring": null, "function_declaration": "def manipulate_string(s, operations):", "function_name": "manipulate_string", "parameter_list": "(s, operations)" }, { "docstring": null, "function_declaration": "def process_operations(s, n, operations):", "function_name": "process_opera...
[ 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 manipulate_string(s, operations):\n for op in operations:\n if op[0] == 'R':\n _, x, y = op\n x, y = int(x), int(y)\n ...
trial_gpt4o_2
{ "original_instruction": "Alice loves to create new words by manipulating existing words. She has a favorite string `s` and she wants to generate a set of new words from it by following a series of operations. Each operation is described by a group of three components (op, x, y):\n\n1. `op` - a single character oper...
0.640406
Taco_91051
C
[ "manipulate_string", "process_operations" ]
2
[ [ "process_operations", "manipulate_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a127437051163a60858c1831a94e5b3aac76c9f3
d1088333983aba2b4e97cc159f3ab458a0194ead
v1.0
complete
Taco
Taco_91477_C
def min_seconds_to_reach_destination(city_map: List[str]) -> int: """ Determine the minimum time required for all cars to reach their respective destinations without causing a gridlock. >>> min_seconds_to_reach_destination([ ... "S..", ... ".#.", ... "..E" ... ]) 4 >>> min_seconds_to_rea...
from collections import deque def min_seconds_to_reach_destination(city_map): N = len(city_map) M = len(city_map[0]) # Helper functions to find 'S' and 'E' positions def find_positions(): start, end = None, None for i in range(N): for j in range(M): if c...
def test_min_seconds_to_reach_destination_simple(): city_map = [ "S..", ".#.", "..E" ] assert min_seconds_to_reach_destination(city_map) == 4 def test_min_seconds_to_reach_destination_blocked(): city_map = [ "S#.", "###", ".#E" ] assert min_se...
[ { "docstring": null, "function_declaration": "def min_seconds_to_reach_destination(city_map):", "function_name": "min_seconds_to_reach_destination", "parameter_list": "(city_map)" }, { "docstring": null, "function_declaration": "def min_time_for_cars(test_cases):", "function_name": "...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_time_to_destination(T, test_cases):\n results = []\n\n for case in test_cases:\n N, M, grid = case\n s...
trial_gpt4o_4
{ "original_instruction": "You are tasked with developing a simulation for a new type of traffic control system. The system aims to control the flow of cars through a series of crossroads in a city using real-time traffic sensors. Cars at each crossroad can only move in four directions: North, South, East, and West. ...
0.643057
Taco_91477
C
[ "min_seconds_to_reach_destination", "min_time_for_cars", "read_input" ]
3
[ [ "min_time_for_cars", "min_seconds_to_reach_destination" ] ]
1
[ "read_input" ]
false
[]
false
pytest
false
[]
true
52b4d62d4935fdb0edd13bf3520d4f9339e79f76
8f3c3ac5df4d126a6eeea85228f2655d1f5f0614
v1.0
complete
Taco
Taco_91203_C
def maximal_value_of_items(n, W, items): """ Marta is planning a hiking trip and wants to pack her backpack efficiently. Her backpack has a maximum weight capacity, and she has a list of essential items she wants to bring, each with a specific weight and value. Marta wants to maximize the total value o...
def knapsack(W, weights, values, n): """ Returns the maximum value that can be accommodated in the knapsack with given weight capacity W, weights and values of the items. """ # Initialize a DP table to store the maximum value up to capacity W dp = [0] * (W + 1) for i in range(n): ...
from solution import maximal_value_of_items def test_example1(): n = 3 W = 50 items = [(20, 40), (50, 100), (30, 60)] assert maximal_value_of_items(n, W, items) == 100 def test_example2(): n = 4 W = 10 items = [(5, 10), (4, 7), (3, 4), (2, 2)] assert maximal_value_of_items(n, W, items)...
[ { "docstring": "Returns the maximum value that can be accommodated in the knapsack\nwith given weight capacity W, weights and values of the items.", "function_declaration": "def knapsack(W, weights, values, n):", "function_name": "knapsack", "parameter_list": "(W, weights, values, 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 knapsack(n, W, items):\n \"\"\"\n Solves the knapsack problem using dynamic programming.\n\n Parameters:\n n (int): Number of items.\n W (int): ...
trial_gpt4o_1
{ "original_instruction": "Marta is planning a hiking trip and wants to pack her backpack efficiently. Her backpack has a maximum weight capacity, and she has a list of essential items she wants to bring, each with a specific weight and value. Marta wants to maximize the total value of the items she can carry without...
0.687562
Taco_91203
C
[ "knapsack", "maximal_value_of_items" ]
2
[ [ "maximal_value_of_items", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f3e628cc31c26cd1ab66baf8076802bf025027b0
0b0117b9b01aae24cec272c1076627824a35032a
v1.0
complete
Taco
Taco_91585_C
def max_non_overlapping_tasks(tasks: List[Tuple[int, int]]) -> int: """ Determine the maximum number of non-overlapping tasks that can be completed. Args: tasks: A list of tuples where each tuple contains two integers representing the start and end times of tasks. Returns: An integer repre...
def max_non_overlapping_tasks(tasks): tasks.sort(key=lambda x: x[1]) # Sort by end time count = 0 last_end_time = 0 for start, end in tasks: if start >= last_end_time: count += 1 last_end_time = end return count def read_input_and_compute_max_tasks(): ...
def test_max_non_overlapping_tasks(): tasks1 = [(1, 3), (2, 5), (4, 6), (6, 7), (5, 8)] assert max_non_overlapping_tasks(tasks1) == 3 tasks2 = [(1, 2), (2, 3), (3, 5)] assert max_non_overlapping_tasks(tasks2) == 3 tasks3 = [(1, 4), (2, 5), (3, 6)] assert max_non_overlapping_tasks(tasks3) == 1 ...
[ { "docstring": null, "function_declaration": "def max_non_overlapping_tasks(tasks):", "function_name": "max_non_overlapping_tasks", "parameter_list": "(tasks)" }, { "docstring": null, "function_declaration": "def read_input_and_compute_max_tasks():", "function_name": "read_input_and_...
[ 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 max_non_overlapping_tasks(tasks):\n \"\"\"\n Returns the maximum number of non-overlapping tasks that can be completed.\n \"\"\"\n # Sort the tasks...
trial_gpt4o_3
{ "original_instruction": "You are planning a project where you need to allocate tasks to your team members. Each task has a specific start and end time, and each team member can work on at most one task at a time. Your goal is to maximize the number of tasks completed by your team.\n\nGiven a list of tasks with thei...
0.58912
Taco_91585
C
[ "max_non_overlapping_tasks", "read_input_and_compute_max_tasks" ]
2
[ [ "read_input_and_compute_max_tasks", "max_non_overlapping_tasks" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2ddc4e31c2e928186e218addac6bc73e3b3a84a5
54936994362464952793df4c120d5768aa7b43d8
v1.0
complete
Taco
Taco_91501_C
def find_lcs_length(input_data: str) -> int: """ Write a program that reads two sequences of integers and finds their longest common subsequence. A longest common subsequence (LCS) is a subsequence that appears in both sequences in the same order but not necessarily consecutively. The program should output ...
def longest_common_subsequence(seq1, seq2): """ This function finds the length of the longest common subsequence between two sequences. """ n = len(seq1) m = len(seq2) # Create a 2D array to store lengths of longest common subsequence. dp = [[0] * (m + 1) for _ in range(n + 1)] ...
from solution import find_lcs_length def test_example_case(): input_data = "6\n1 2 3 4 1\n5\n3 4 1 2 1 3" result = find_lcs_length(input_data) assert result == 3 def test_case_no_common_subsequence(): input_data = "3\n1 2 3\n3\n4 5 6" result = find_lcs_length(input_data) assert result == 0 de...
[ { "docstring": "This function finds the length of the longest common subsequence between two sequences.", "function_declaration": "def longest_common_subsequence(seq1, seq2):", "function_name": "longest_common_subsequence", "parameter_list": "(seq1, seq2)" }, { "docstring": null, "functi...
[ 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 lcs_length(seq1, seq2):\n \"\"\"\n Computes the length of the longest common subsequence (LCS) between two sequences.\n :param seq1: First sequence of...
trial_gpt4o_1
{ "original_instruction": "Write a program that reads two sequences of integers and finds their longest common subsequence. A longest common subsequence (LCS) is a subsequence that appears in both sequences in the same order but not necessarily consecutively. The program should output the length of the LCS.\n\nNote\n...
0.708875
Taco_91501
C
[ "longest_common_subsequence", "find_lcs_length" ]
2
[ [ "find_lcs_length", "longest_common_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e186537ba473b52de7c09399903453d505258065
6d2a6703fbdb3004ba5256f9e9164faea164dcaf
v1.0
complete
Taco
Taco_91612_C
import math def is_perfect_square(x): """Check if a number x is a perfect square.""" s = int(math.isqrt(x)) return s * s == x def count_perfect_squares(arr, queries): """ Count the number of perfect squares in subarrays specified by the queries. Parameters: arr (list of int): The array ...
import math def is_perfect_square(x): """Check if a number x is a perfect square.""" s = int(math.isqrt(x)) return s * s == x def count_perfect_squares(arr, queries): """Count the number of perfect squares in subarrays specified by the queries.""" perfect_square_flags = [1 if is_perfect_square(x) ...
def test_is_perfect_square(): from math import isqrt def is_perfect_square(x): s = int(isqrt(x)) return s * s == x assert is_perfect_square(1) assert is_perfect_square(4) assert is_perfect_square(9) assert is_perfect_square(16) assert not is_perfect_square(2) assert not ...
[ { "docstring": "Check if a number x is a perfect square.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": "Count the number of perfect squares in subarrays specified by the queries.", "function_declarat...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(number):\n \"\"\"\n Check if a number is a perfect square.\n \"\"\"\n root = int(math.isqrt(number))\n return r...
trial_gpt4o_3
{ "original_instruction": "Jack loves playing with numbers. He has an integer array and wants to perform queries on it. Each query consists of two integers L and R, and for each query, Jack wants to know the count of elements in the subarray from L to R (inclusive) that are perfect squares. \n\nWrite a program to hel...
0.651376
Taco_91612
C
[ "is_perfect_square", "count_perfect_squares", "process_input", "main" ]
4
[ [ "count_perfect_squares", "is_perfect_square" ] ]
1
[ "process_input" ]
false
[]
false
pytest
false
[]
true
bd44d975bffd5b7872d90cfd0457e41b60954698
bdbb04331054b1a79caf3940bb22ef5898eb868d
v1.0
complete
Taco
Taco_91928_C
def count_unique_necklaces(n: int, necklaces: List[str]) -> int: """ Returns the number of unique cyclic sequences in the list of necklaces. >>> count_unique_necklaces(5, ["abc", "bca", "cab", "xyz", "yyy"]) == 3 >>> count_unique_necklaces(3, ["aaa", "bbb", "ccc"]) == 3 >>> count_unique_necklaces(4, ["a...
def rotate_string(s): """ Returns all cyclic rotations of the string 's'. """ return [s[i:] + s[:i] for i in range(len(s))] def canonical_form(s): """ Returns the canonical form of the string 's' by finding the lexicographically smallest rotation of 's'. """ rotations = rotate_strin...
from solution import count_unique_necklaces def test_basic_example(): assert count_unique_necklaces(5, ["abc", "bca", "cab", "xyz", "yyy"]) == 3 def test_all_unique(): assert count_unique_necklaces(3, ["aaa", "bbb", "ccc"]) == 3 def test_all_identical(): assert count_unique_necklaces(4, ["abc", "abc", "a...
[ { "docstring": "Returns all cyclic rotations of the string 's'.", "function_declaration": "def rotate_string(s):", "function_name": "rotate_string", "parameter_list": "(s)" }, { "docstring": "Returns the canonical form of the string 's' by finding the lexicographically smallest\nrotation of ...
[ 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 calculate_unique_necklaces(n, necklaces):\n def get_canonical_form(s):\n return min(s[i:] + s[:i] for i in range(len(s)))\n\n unique_necklaces = s...
trial_gpt4o_2
{ "original_instruction": "Anna has a collection of beautiful necklaces, where each necklace is composed of a sequence of beads of various colors. She often wears these necklaces, and while doing so, she noticed something interesting. Each necklace forms a cyclic sequence, meaning the end of the necklace is connected...
0.608516
Taco_91928
C
[ "rotate_string", "canonical_form", "count_unique_necklaces" ]
3
[ [ "canonical_form", "rotate_string" ], [ "count_unique_necklaces", "canonical_form" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0c974c85fa76e2f9fb8c62a3dd96fc5efbacb7ae
cfab094a07a745c3f21497ce23afe6b95e9930f8
v1.0
complete
Taco
Taco_91702_C
def min_instructions_to_erase(N: int, M: int, instructions: List[str]) -> int: """ Determine the minimum number of instructions to erase to make the remaining instructions logically consistent. >>> min_instructions_to_erase(4, 5, ["S 1 2", "C 1 red", "S 2 3", "C 2 blue", "S 3 4"]) 1 >>> min_instructions...
def min_instructions_to_erase(N, M, instructions): parent = list(range(N + 1)) color = [-1] * (N + 1) def find(x): if parent[x] != x: parent[x] = find(parent[x]) return parent[x] def union(x, y): rootX = find(x) rootY = find(y) if rootX != rootY: ...
def test_min_instructions_to_erase(): assert solve_from_input("4 5\nS 1 2\nC 1 red\nS 2 3\nC 2 blue\nS 3 4\n") == 1 assert solve_from_input("4 6\nS 1 2\nS 2 3\nC 1 red\nC 3 blue\nC 2 blue\nS 1 4\n") == 2 assert solve_from_input("4 4\nS 1 2\nC 1 red\nS 2 3\nS 3 4\n") == 0 assert solve_from_input("3 4\nS ...
[ { "docstring": null, "function_declaration": "def min_instructions_to_erase(N, M, instructions):", "function_name": "min_instructions_to_erase", "parameter_list": "(N, M, instructions)" }, { "docstring": null, "function_declaration": "def solve_from_input(input_str):", "function_name...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_instructions_to_erase(n, m, instructions):\n parent = list(range(n + 1))\n color = [-1] * (n + 1) # -1 denotes unassigned color\n\n def find(x):\...
trial_gpt4o_2
{ "original_instruction": "In a small town, there are N houses arranged in a row and each house is either painted red or blue. You and your friend Alice decide to play a game. Alice gives you M instructions, each instruction either tells you a sequence of houses has the same color, or it tells you a specific house ha...
0.586964
Taco_91702
C
[ "min_instructions_to_erase", "solve_from_input" ]
2
[ [ "solve_from_input", "min_instructions_to_erase" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4a5b1b03dec7029c1e3a029bd5da60d9f61d8ec6
abb03133ac42309f359e0aa7c6127a7f3e014e4e
v1.0
complete
Taco
Taco_91807_C
def gcd_fib(a: int, b: int) -> int: """ Function to calculate the GCD of Fib(a) and Fib(b) using the relation: GCD(Fib(a), Fib(b)) = Fib(GCD(a, b)) >>> gcd_fib(10, 15) 5 >>> gcd_fib(21, 21) 10946 >>> gcd_fib(0, 5) 5 >>> gcd_fib(1000, 1001) 1 >>> gcd_fib(1, 1) 1 "...
def gcd(a, b): """ Helper function to calculate the GCD of two numbers using the Euclidean algorithm. """ while b: a, b = b, a % b return a def fib(n): """ Helper function to calculate the n-th Fibonacci number using matrix exponentiation. This function can effectively compute F...
from solution import gcd_fib def test_sample_case(): assert gcd_fib(10, 15) == 5 def test_same_number(): assert gcd_fib(21, 21) == 10946 # Because Fib(21) is 10946 def test_zero_case(): assert gcd_fib(0, 5) == 5 # Fib(0) is 0, Fib(5) is 5, GCD(0, 5) is 5 and Fib(5) is 5 def test_large_numbers(): a...
[ { "docstring": "Helper function to calculate the GCD of two numbers using the Euclidean algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Helper function to calculate the n-th Fibonacci number using matrix exponentiat...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Helper function to calculate the GCD of two numbers using the Euclidean algorithm.\n \"\"\"\n while b:\n a, b = b, a %...
trial_gpt4o_0
{ "original_instruction": "Alice has recently developed an interest in number theory and discovered a sequence of numbers called the \"Fibonacci sequence.\" The Fibonacci sequence is defined as follows:\n\n- $\\text{Fib}(0) = 0$\n- $\\text{Fib}(1) = 1$\n- For $n \\geq 2$, $\\text{Fib}(n) = \\text{Fib}(n-1) + \\text{F...
0.756309
Taco_91807
C
[ "gcd", "fib", "gcd_fib" ]
3
[ [ "gcd_fib", "fib" ], [ "gcd_fib", "gcd" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9e0d5294e9b1bf412d7ea34546b8cd10c4712a5a
13b3bc3ad8297b2be80d546a85b8e8cf37f30c5f
v1.0
complete
Taco
Taco_91801_C
from typing import List def max_min_distance(n: int, m: int, positions: List[int]) -> int: """ Returns the maximum possible minimum distance between any two planted trees. Parameters: n (int): The number of planting points. m (int): The number of trees to be planted. positions (List[int]): The...
def can_place_trees(positions, n, m, min_dist): """ Helper function to check if m trees can be placed with at least min_dist distance apart. """ count = 1 # Place the first tree at the first position last_position = positions[0] for i in range(1, n): if positions[i] - last_position >= ...
from solution import max_min_distance def test_example1(): n = 5 m = 3 positions = [1, 2, 8, 4, 9] assert max_min_distance(n, m, positions) == 3 def test_example2(): n = 6 m = 4 positions = [1, 2, 6, 7, 8, 11] assert max_min_distance(n, m, positions) == 2 def test_small_case(): n ...
[ { "docstring": "Helper function to check if m trees can be placed with at least min_dist distance apart.", "function_declaration": "def can_place_trees(positions, n, m, min_dist):", "function_name": "can_place_trees", "parameter_list": "(positions, n, m, min_dist)" }, { "docstring": "Returns...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_min_distance(n, m, positions):\n positions.sort()\n\n def feasible(distance):\n count, last_position = 1, positions[0]\n for i in range...
trial_gpt4o_2
{ "original_instruction": "The city mayor has decided to plant trees along the main road to beautify the city. The road can be represented as a straight line with n points where trees can be planted. Due to budget constraints, the mayor can only plant m trees. To ensure uniformity and maximized beauty, the mayor want...
0.619581
Taco_91801
C
[ "can_place_trees", "max_min_distance" ]
2
[ [ "max_min_distance", "can_place_trees" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d88ce9586c2eac1d57d2d257b676680d4b575193
f6cf54e41be1a8f874c53cc11064d7940fead245
v1.0
complete
Taco
Taco_91403_C
def min_operations_to_arithmetic_sequence(arr): """ Determine if a given unsorted array is an arithmetic sequence and, if not, return the minimum number of operations required to make it an arithmetic sequence. An operation consists of changing a single element of the array to any integer value. >>> min_op...
def is_arithmetic_sequence(arr): """ Helper function to determine if an array is already an arithmetic sequence. """ if len(arr) <= 1: return True common_diff = arr[1] - arr[0] for i in range(1, len(arr)): if arr[i] - arr[i - 1] != common_diff: return False ...
from solution import min_operations_to_arithmetic_sequence def test_no_operations_needed(): assert min_operations_to_arithmetic_sequence([1, 3, 5, 7, 9]) == 0 def test_one_operation_needed(): assert min_operations_to_arithmetic_sequence([2, 4, 6, 8, 12]) == 1 def test_multiple_operations_needed(): assert...
[ { "docstring": "Helper function to determine if an array is already an arithmetic sequence.", "function_declaration": "def is_arithmetic_sequence(arr):", "function_name": "is_arithmetic_sequence", "parameter_list": "(arr)" }, { "docstring": "Returns the minimum number of operations needed to...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_operations_to_arithmetic_sequence(arr):\n \"\"\"\n Returns the minimum number of operations needed to make the input array an arithmetic sequence.\n ...
trial_gpt4o_4
{ "original_instruction": "An arithmetic sequence is a sequence of numbers in which the difference between consecutive terms is constant. This difference is called the \"common difference\". \n\nIn this problem, you need to determine if a given unsorted array is an arithmetic sequence and, if not, return the minimum ...
0.657597
Taco_91403
C
[ "is_arithmetic_sequence", "min_operations_to_arithmetic_sequence" ]
2
[ [ "min_operations_to_arithmetic_sequence", "is_arithmetic_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b2c26911a374bc36cf331d737ad484fb5ba8d80
2ff22bebf330e9ba90e5f3830d38469d1d5ab45d
v1.0
complete
Taco
Taco_91530_C
def minimal_communication_cost(n: int, m: int, edges: List[Tuple[int, int, int]]) -> int: """ Determine the minimal total communication cost to connect all planets through the Minimum Spanning Tree (MST) of the network. Args: n (int): The number of planets. m (int): The number of bidirectional comm...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] ...
def test_mst_case1(): n = 4 m = 5 edges = [(1, 2, 1), (2, 3, 4), (3, 4, 3), (1, 3, 5), (1, 4, 2)] assert minimal_communication_cost(n, m, edges) == 6 def test_mst_case2(): n = 3 m = 3 edges = [(1, 2, 2), (2, 3, 3), (1, 3, 1)] assert minimal_communication_cost(n, m, edges) == 3 def test...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_8
{ "original_instruction": "In a distant universe, there exists a network of connected planets. Each planet is linked to certain other planets by bidirectional communication channels, allowing the exchange of resources between them. The emperor of this universe wants to know about the minimal resource distribution net...
0.659708
Taco_91530
C
[ "find", "union", "kruskal_mst", "minimal_communication_cost" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimal_communication_cost", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
f4fe99527a55dbaa10bc71379736b9035e424195
20e7251b98208bbf1b83e70a5b4fc1d3463175cc
v1.0
complete
Taco
Taco_92023_C
def is_valid_route(M, N, x, y, movements): """ Determine if the route for the truck is valid based on the given conditions. Args: M : int : number of streets (grid rows) N : int : number of avenues (grid columns) x : int : starting x-coordinate y : int : starting y-coordinate movements : str...
def is_valid_route(M, N, x, y, movements): visited = set() visited.add((x, y)) for move in movements: if move == 'U': x -= 1 elif move == 'D': x += 1 elif move == 'L': y -= 1 elif move == 'R': y += 1 if x <...
from solution import process_input, determine_routes, is_valid_route def test_process_input(): input_data = "1\n5 5\n2\n3 3 UURRDDL\n2 2 RRUULL\n" expected_output = [(5, 5, [(2, 2, 'UURRDDL'), (1, 1, 'RRUULL')])] assert process_input(input_data) == expected_output def test_is_valid_route(): M = 5 ...
[ { "docstring": null, "function_declaration": "def is_valid_route(M, N, x, y, movements):", "function_name": "is_valid_route", "parameter_list": "(M, N, x, y, movements)" }, { "docstring": null, "function_declaration": "def determine_routes(test_cases):", "function_name": "determine_r...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_route(grid_size, start_pos, movement):\n M, N = grid_size\n x, y = start_pos\n visited = set()\n visited.add((x, y))\n \n directions...
trial_gpt4o_5
{ "original_instruction": "A delivery company operates in a city structured as a grid. The city's layout consists of M streets and N avenues, forming a grid with M intersections. Each intersection can be identified by a pair of coordinates (x, y). The company needs to plan routes for its delivery trucks such that eac...
0.653759
Taco_92023
C
[ "is_valid_route", "determine_routes", "process_input" ]
3
[ [ "determine_routes", "is_valid_route" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
6151d85d5572c121be7a6c471e4b99759f921c00
107c01b382252e682a2ed8c60761754ec160ab93
v1.0
complete
Taco
Taco_92191_C
def sumOfPrimes(N: int) -> int: """ Given an integer N, compute the sum of the first N prime numbers. >>> sumOfPrimes(5) 28 >>> sumOfPrimes(7) 58 """
def is_prime(num): if num <= 1: return False if num == 2 or num == 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def sumOfPrimes(N)...
from solution import sumOfPrimes def test_sum_of_first_5_primes(): assert sumOfPrimes(5) == 28 def test_sum_of_first_1_prime(): assert sumOfPrimes(1) == 2 def test_sum_of_first_7_primes(): assert sumOfPrimes(7) == 58 def test_sum_of_first_10_primes(): assert sumOfPrimes(10) == 129 def test_lower_bo...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def sumOfPrimes(N):", "function_name": "sumOfPrimes", "parameter_list": "(N)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\" Helper function to check if a number is prime \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) ...
trial_gpt4o_1
{ "original_instruction": "Given an integer N, design an algorithm to compute the sum of the first N prime numbers. \n\nExample 1:\nInput:\nN=5\nOutput:\n28 \nExplanation:\nThe first 5 prime numbers are 2, 3, 5, 7, and 11. Their sum is 2 + 3 + 5 + 7 + 11 = 28.\n\nExample 2:\nInput:\nN=7\nOutput:\n58\nExplanation:\nTh...
0.705273
Taco_92191
C
[ "is_prime", "sumOfPrimes" ]
2
[ [ "sumOfPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91404e50a8978494869f1acf1f2c92fdf1312a0f
6ed18ad0e5d8a0333664ad3661e04dd744fff5cc
v1.0
complete
Taco
Taco_91958_C
from typing import List, Tuple def process_queries(queries: List[Tuple[int, int]], limit: int = 10**6) -> List[int]: """ Compute the sums of magic numbers for all given ranges. Each range is provided as a tuple (l, r), and this function returns a list with the sum of unique prime factors for each range [l,...
def count_unique_prime_factors(n): """ Returns the number of unique prime factors of n. """ count = 0 i = 2 if n % i == 0: count += 1 while n % i == 0: n //= i for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: count += 1 ...
from solution import process_queries def test_sum_magic_numbers(): queries = [ (1, 1), (2, 4), (10, 15), (1000, 1002) ] assert process_queries(queries) == [0, 3, 10, 8] def test_sum_magic_numbers_single_range(): queries = [ (5, 5) # Single number, which is prim...
[ { "docstring": "Returns the number of unique prime factors of n.", "function_declaration": "def count_unique_prime_factors(n):", "function_name": "count_unique_prime_factors", "parameter_list": "(n)" }, { "docstring": "Preprocess and return an array of magic numbers up to the given limit.", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_prime_factors_sums(limit=10**6):\n prime_factors_count = [0] * (limit + 1)\n \n # Sieve of Eratosthenes to calculate the number of unique pri...
trial_gpt4o_1
{ "original_instruction": "In an ancient magical kingdom, there is a library that contains an infinite number of books, indexed sequentially by positive integers starting from 1. Each book is enchanted with a magic number, defined as follows:\n- The magic number of book i (considering 1-based indexing) equals the num...
0.577407
Taco_91958
C
[ "count_unique_prime_factors", "preprocess_magic_numbers", "preprocess_sum_magic_numbers", "sum_magic_numbers", "process_queries" ]
5
[ [ "process_queries", "preprocess_magic_numbers" ], [ "process_queries", "preprocess_sum_magic_numbers" ], [ "process_queries", "sum_magic_numbers" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
5aa50e0f46e32b720d3555c8dd78d2e20d8d2f25
6d16f7fcc4f2bf0bda2ba31ac7fd042484afec19
v1.0
complete
Taco
Taco_92097_C
def maxSubArraySum(arr: List[int], n: int) -> int: """ Write a function to find the maximum subarray sum for a given array of integers, using the Divide and Conquer technique. Example 1: >>> maxSubArraySum([2, 3, 4, 5, 7], 5) 21 Example 2: >>> maxSubArraySum([-2, -3, 4, -1, -2, 1, 5, -3], ...
def maxCrossingSum(arr, low, mid, high): # Include elements on the left of mid. left_sum = float('-inf') sum_now = 0 for i in range(mid, low - 1, -1): sum_now += arr[i] if sum_now > left_sum: left_sum = sum_now # Include elements on the right of mid right_sum = f...
from solution import maxSubArraySum def test_max_sub_array_sum_all_positive(): assert maxSubArraySum([2, 3, 4, 5, 7], 5) == 21 def test_max_sub_array_sum_mixed(): assert maxSubArraySum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7 def test_max_sub_array_sum_single_element(): assert maxSubArraySum([1], 1) == 1 ...
[ { "docstring": null, "function_declaration": "def maxCrossingSum(arr, low, mid, high):", "function_name": "maxCrossingSum", "parameter_list": "(arr, low, mid, high)" }, { "docstring": null, "function_declaration": "def maxSubArraySumUtil(arr, low, high):", "function_name": "maxSubArr...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_crossing_sum(arr, low, mid, high):\n # Include elements on the left of mid\n sum = 0\n left_sum = float('-inf')\n for i in range(mid, low - 1, ...
trial_gpt4o_1
{ "original_instruction": "Write a function to find the maximum subarray sum for a given array of integers, using the Divide and Conquer technique. The array can contain both negative and positive numbers.\n\nExample 1:\nInput:\narr[] = {2, 3, 4, 5, 7}\nOutput: 21\nExplanation: The sum of entire array is 21, which is...
0.762421
Taco_92097
C
[ "maxCrossingSum", "maxSubArraySumUtil", "maxSubArraySum" ]
3
[ [ "maxSubArraySum", "maxSubArraySumUtil" ], [ "maxSubArraySumUtil", "maxCrossingSum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
54d60664f5595631ced88af859713f4ace81ca83
5a0899726c70d7f37857b2cf0e448f17878da21b
v1.0
complete
Taco
Taco_91896_C
from typing import List, Tuple def process_treasure_queries(n: int, m: int, q: int, treasure_grid: List[List[Tuple[int, int]]], queries: List[Tuple[int, int, int, int]]) -> List[Tuple[int, int]]: """ Process treasure queries on a grid and return the sum of gold and number of items in specified sub-grids. >>> n...
def preprocess(grid, n, m): gold_prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] items_prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): gold_prefix_sum[i][j] = gold_prefix_sum[i - 1][j] + gold_prefix_sum[i][j - 1] - gold_prefix_su...
from solution import process_treasure_queries def test_process_treasure_queries(): n, m, q = 3, 3, 2 treasure_grid = [ [(1, 5), (2, 3), (3, 7)], [(4, 2), (5, 1), (6, 4)], [(7, 3), (8, 2), (9, 5)] ] queries = [ (1, 1, 2, 2), (2, 2, 3, 3) ] expected_output ...
[ { "docstring": null, "function_declaration": "def preprocess(grid, n, m):", "function_name": "preprocess", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def query_sums(gold_prefix_sum, items_prefix_sum, r1, c1, r2, c2):", "function_name": "query_su...
[ 0, 0, 0, 0, 0, 0, 1, 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 process_queries(n, m, q, grid, queries):\n # Initialize prefix sums for gold and items\n gold_prefix = [[0]*(m+1) for _ in range(n+1)]\n items_prefix ...
trial_gpt4o_6
{ "original_instruction": "In a distant future, on an uncharted island, there is a massive grid of treasure chests. Each treasure chest is located at specific coordinates, and each can hold a varying amount of gold and items. Treasure hunters have to answer queries related to the distribution of gold and items in the...
0.551016
Taco_91896
C
[ "preprocess", "query_sums", "process_treasure_queries" ]
3
[ [ "process_treasure_queries", "preprocess" ], [ "process_treasure_queries", "query_sums" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4c83d76618c98405a5a928855fb9fd8150ae0c4f
2c6dfec1cddac00d5f460f90480230122f30bcb1
v1.0
complete
Taco
Taco_91870_C
def max_fertile_area(m: int, n: int, field: List[str]) -> int: """ Returns the area of the largest contiguous rectangular block of fertile cells. >>> max_fertile_area(4, 4, [ ... "FFFF", ... "FFBF", ... "FFFF", ... "FBFF" ... ]) 6 >>> max_fertile_area(5, 6, [ ... ...
def max_fertile_area(m, n, field): """ Returns the area of the largest contiguous rectangular block of fertile cells. """ # Create a height array to store the height of 'F' (fertile) cells. height = [0] * n max_area = 0 for i in range(m): for j in range(n): if field[...
from solution import max_fertile_area def test_example_1(): m, n = 4, 4 field = [ "FFFF", "FFBF", "FFFF", "FBFF" ] assert max_fertile_area(m, n, field) == 6 def test_example_2(): m, n = 5, 6 field = [ "FFFFFF", "FFFFBF", "FFBBFF", ...
[ { "docstring": "Returns the area of the largest contiguous rectangular block of fertile cells.", "function_declaration": "def max_fertile_area(m, n, field):", "function_name": "max_fertile_area", "parameter_list": "(m, n, field)" }, { "docstring": "Helper function to find the largest rectang...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_fertile_area(m, n, field):\n \"\"\"\n Returns the area of the largest contiguous rectangular block of fertile cells.\n \"\"\"\n # Create a heig...
trial_gpt4o_0
{ "original_instruction": "A farmer owns a rectangular field that is divided into a grid of m rows and n columns. Some cells are fertile where crops can be grown, while others are barren where no crops can be grown. The farmer wants to grow the maximum number of contiguous crops in any rectangular block of fertile ce...
0.577088
Taco_91870
C
[ "max_fertile_area", "largest_rectangle_area" ]
2
[ [ "max_fertile_area", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b3361351210e06847718385a55a27664136fcd6b
debb101762d29137937dc9c5f8b8184433796080
v1.0
complete
Taco
Taco_92254_C
def minimum_spanning_tree(): """ Find the sum of the weights of the edges that form the Minimum Spanning Tree (MST) of the graph. If the MST does not exist, output -1. Input is given from Standard Input in the following format: N M u_1 v_1 w_1 u_2 v_2 w_2 : u_M v_M w_M ...
def find(parent, i): if parent[i] != i: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): rootx = find(parent, x) rooty = find(parent, y) if rootx != rooty: if rank[rootx] > rank[rooty]: parent[rooty] = rootx elif rank[rootx] < r...
def test_mst_sample(): input_data = "4 5\n1 2 3\n1 3 4\n4 2 6\n4 3 5\n2 3 2\n" expected_output = 9 from io import StringIO import sys sys.stdin = StringIO(input_data) from solution import minimum_spanning_tree minimum_spanning_tree() def test_mst_no_edges(): input_data = "4 0\n" ex...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_MST_sum(N, M, edges):\n \"\"\"\n Returns the sum of the weights of the edges that form the Minimum Spanning Tree (MST)\n of the given undirected ...
trial_gpt4o_9
{ "original_instruction": "You are given an undirected graph with N nodes and M edges. Each edge has a weight associated with it. Your task is to find the sum of the weights of the edges that form the Minimum Spanning Tree (MST) of the graph. If the MST does not exist, output -1.\n\n-----Constraints-----\n - 2 ≤ N ≤ ...
0.807188
Taco_92254
C
[ "find", "union", "kruskal_mst", "calculate_mst_weight", "minimum_spanning_tree" ]
5
[ [ "calculate_mst_weight", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimum_spanning_tree", "calculate_mst_weight" ], [ "union", "find" ] ]
5
[]
false
[]
false
pytest
true
[]
true
9c708fff08fd584a0aff0f90227610cb3f148593
bc9ca0607e51f87517c2c76b3c940cb9377c4ddd
v1.0
complete
Taco
Taco_91649_C
from typing import List, Tuple def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def longest_prime_subsequence(arr: List[int]) -> int: """ Find the longest subsequence of prime numbers in a list. >>> longest_prime_subs...
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 longest_prime_subsequence(arr): prime_...
def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(1) assert not is_prime(4) assert is_prime(17) assert not is_prime(100) def test_longest_prime_subsequence(): assert longest_prime_subsequence([2, 6, 4, 7]) == 1 assert longest_prime_subsequence([1, 3, 5, 8, 9...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def longest_prime_subsequence(arr):", "function_name": "longest_prime_subsequence", "parameter_list": "(arr)" }...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n r...
trial_gpt4o_2
{ "original_instruction": "Kira is fascinated by prime numbers, and he loves to identify patterns in sequences of numbers. He has come up with a challenge where he takes a sequence of integers and tries to find the longest subsequence that consists only of prime numbers. \n\nA prime number is a natural number greater...
0.682916
Taco_91649
C
[ "is_prime", "longest_prime_subsequence", "find_longest_prime_subsequence" ]
3
[ [ "find_longest_prime_subsequence", "longest_prime_subsequence" ], [ "longest_prime_subsequence", "is_prime" ] ]
2
[]
false
[]
false
pytest
false
[]
true
d9f3066f398290428a81227cca0f39fb033a8828
e2af14b928e9d697efb823664773cc178c48cbd0
v1.0
complete
Taco
Taco_92173_C
from typing import List, Tuple def find_min_cost_to_all_intersections(n: int, m: int, edges: List[Tuple[int, int, int]], start: int) -> List[int]: """ Determine the minimum cost required to travel from the start intersection to every other intersection in the town. >>> find_min_cost_to_all_intersections(5...
import heapq def dijkstra(n, edges, start): graph = [[] for _ in range(n)] for u, v, w in edges: graph[u].append((w, v)) dist = [float('inf')] * n dist[start] = 0 priority_queue = [(0, start)] while priority_queue: current_dist, node = heapq.heappop(priority_queue) ...
def test_example1(): n = 5 m = 6 edges = [ (0, 1, 2), (0, 2, 4), (1, 2, 1), (1, 3, 7), (2, 4, 3), (3, 4, 1) ] start = 0 assert find_min_cost_to_all_intersections(n, m, edges, start) == [0, 2, 3, 9, 6] def test_example2(): n = 4 m = 3 e...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start):", "function_name": "dijkstra", "parameter_list": "(n, edges, start)" }, { "docstring": null, "function_declaration": "def find_min_cost_to_all_intersections(n, m, edges, start):", "function_name": "find_min_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, roads, start):\n graph = [[] for _ in range(n)]\n for u, v, w in roads:\n graph[u].append((w, v))\n \n distances...
trial_gpt4o_1
{ "original_instruction": "In a small town, there are M roads and N intersections, represented as a graph where intersections are nodes and roads are directed edges. Each road has a specific cost associated with it, representing the effort to move from one intersection to another. Your task is to determine the minimu...
0.62556
Taco_92173
C
[ "dijkstra", "find_min_cost_to_all_intersections" ]
2
[ [ "find_min_cost_to_all_intersections", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
304dc4ca71a0de09473e1c1a2fcc8e535711b4eb
45ccd658a8d029551bdc0b8a067ff5df8dbb98e8
v1.0
complete
Taco
Taco_92301_C
from typing import List, Tuple def allocate_drivers(customers: List[Tuple[int, int]], drivers: List[Tuple[int, int]]) -> List[int]: """ Find the closest driver to each customer using Euclidean distance. >>> allocate_drivers([(0, 0), (2, 3), (4, 5)], [(1, 1), (3, 2), (5, 5)]) == [0, 1, 2] >>> allocate_drive...
def euclidean_distance(c1, c2): """ Calculate the Euclidean distance between two points c1 and c2. c1, c2 are given as (x, y) tuples. """ return ((c1[0] - c2[0]) ** 2 + (c1[1] - c2[1]) ** 2) ** 0.5 def allocate_drivers(customers, drivers): """ Finds the closest driver to each customer using...
from solution import allocate_drivers def test_allocate_drivers_example(): assert allocate_drivers([(0, 0), (2, 3), (4, 5)], [(1, 1), (3, 2), (5, 5)]) == [0, 1, 2] def test_allocate_drivers_single_customer_and_driver(): assert allocate_drivers([(3, 3)], [(1, 1)]) == [0] assert allocate_drivers([(5, 5)], [...
[ { "docstring": "Calculate the Euclidean distance between two points c1 and c2.\nc1, c2 are given as (x, y) tuples.", "function_declaration": "def euclidean_distance(c1, c2):", "function_name": "euclidean_distance", "parameter_list": "(c1, c2)" }, { "docstring": "Finds the closest driver to e...
[ 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 allocate_drivers(customers, drivers):\n def euclidean_distance(c, d):\n return (c[0] - d[0]) ** 2 + (c[1] - d[1]) ** 2\n\n closest_drivers = []\n ...
trial_gpt4o_2
{ "original_instruction": "A taxi company wants to improve the allocation of drivers to customers based on the locations of both. They divide the city into a grid of blocks, where each block is identified using an (x, y) coordinate. Customers and drivers provide their locations as coordinates. The company wants to as...
0.580349
Taco_92301
C
[ "euclidean_distance", "allocate_drivers" ]
2
[ [ "allocate_drivers", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
847ea232288e6974aa777b383876fe635f90ad22
c4b2656416524094af633260a96ca40240add999
v1.0
complete
Taco
Taco_92461_C
def identify_hand(cards: List[str]) -> str: """Identify if the given hand of cards forms a flush or a straight flush. Args: cards (List[str]): A list of strings representing the cards, where each string contains a rank and a suit (e.g., '2H' for the 2 of Hearts, 'QD' for the Queen of Diamo...
def card_rank_value(rank): rank_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14} return rank_order[rank] def is_consecutive(values): values.sort() for i in range(len(values) - 1): if values[i+1] - values[i] != 1: ...
from solution import identify_hand def test_identify_hand_straight_flush(): assert identify_hand(["2H", "3H", "4H", "5H", "6H"]) == "6SF" assert identify_hand(["10D", "JD", "QD", "KD", "AD"]) == "ASF" assert identify_hand(["9S", "10S", "JS", "QS", "KS"]) == "KSF" assert identify_hand(["4C", "5C", "6C",...
[ { "docstring": null, "function_declaration": "def card_rank_value(rank):", "function_name": "card_rank_value", "parameter_list": "(rank)" }, { "docstring": null, "function_declaration": "def is_consecutive(values):", "function_name": "is_consecutive", "parameter_list": "(values)"...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def identify_flush(hand):\n \"\"\"\n Identify whether a given hand of cards forms a flush or a straight flush.\n \n Parameters:\n hand (list of str)...
trial_gpt4o_6
{ "original_instruction": "## Introduction\n\nIn a standard deck of playing cards, there are 52 cards divided into 4 suits: hearts, diamonds, clubs, and spades. Each suit has 13 ranks: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King.\n\nA flush is a hand where all cards have the same suit. However, the specifi...
0.629785
Taco_92461
C
[ "card_rank_value", "is_consecutive", "identify_hand" ]
3
[ [ "identify_hand", "card_rank_value" ], [ "identify_hand", "is_consecutive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
edc8f1a8070c7afb74fe774de212592786d92bc7
c2ce01b78ed10d248cb282cd02a99b38f106b55a
v1.0
complete
Taco
Taco_92580_C
def is_composite(x: int) -> bool: """ Determine if x is a composite number. >>> is_composite(4) True >>> is_composite(6) True >>> is_composite(7) False """ pass def longest_composite_subarray(arr: List[int]) -> int: """ Find the length of the longest contiguous subarray consisti...
def is_composite(x): """ Determine if x is a composite number. """ if x <= 1: return False for i in range(2, int(x**0.5) + 1): if x % i == 0: return True return False def longest_composite_subarray(arr): """ Find the length of the longest contiguous subarray ...
from solution import is_composite, longest_composite_subarray def test_is_composite(): assert is_composite(4) == True assert is_composite(6) == True assert is_composite(7) == False assert is_composite(15) == True assert is_composite(97) == False assert is_composite(1) == False def test_lon...
[ { "docstring": "Determine if x is a composite number.", "function_declaration": "def is_composite(x):", "function_name": "is_composite", "parameter_list": "(x)" }, { "docstring": "Find the length of the longest contiguous subarray consisting of only composite numbers.", "function_declara...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_composite(n):\n \"\"\"\n Returns True if n is a composite number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n...
trial_gpt4o_1
{ "original_instruction": "Mike is working on a problem involving composite numbers. A composite number is a positive integer greater than 1 that is not prime. In other words, it has at least one divisor other than 1 and itself.\n\nMike has an array of integers and needs to find the longest contiguous subarray where ...
0.569024
Taco_92580
C
[ "is_composite", "longest_composite_subarray" ]
2
[ [ "longest_composite_subarray", "is_composite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
94d0e7fe05828ee1ad196a9a95df5d0f4e1fbd0c
d83734dae4190ab99b31a805716e3586cf95fab9
v1.0
complete
Taco
Taco_92488_C
from typing import List, Tuple def is_resilient(n: int, edges: List[Tuple[int, int, int]]) -> str: """ Determine if the network of highways remains connected after removing any single road. Args: n: The number of cities. edges: A list of tuples, where each tuple represents a highway with three int...
from collections import defaultdict def is_connected(graph, n): visited = [False] * n stack = [0] count = 0 visited[0] = True while stack: node = stack.pop() count += 1 for neighbor in graph[node]: if not visited[neighbor]: visited[neighbor] ...
from solution import is_resilient def test_example_1(): n = 5 edges = [ (0, 1, 10), (0, 2, 20), (1, 2, 30), (2, 3, 40), (3, 4, 50), (2, 4, 60) ] assert is_resilient(n, edges) == "The highway system is resilient." def test_vulnerable_example(): n = 4 ...
[ { "docstring": null, "function_declaration": "def is_connected(graph, n):", "function_name": "is_connected", "parameter_list": "(graph, n)" }, { "docstring": null, "function_declaration": "def is_resilient(n, edges):", "function_name": "is_resilient", "parameter_list": "(n, edges...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef is_connected(graph, n):\n visited = [False] * n\n stack = [0]\n count = 0\n visited[0] = True\n \n whi...
trial_gpt4o_0
{ "original_instruction": "The Kingdom of Monza is constructing a new highway system connecting its cities. Each city is represented as a node, and roads as edges in a weighted graph. The goal is to determine if the highway system can withstand any single road failure without disconnecting the cities.\n\nWrite a prog...
0.599687
Taco_92488
C
[ "is_connected", "is_resilient", "main" ]
3
[ [ "is_resilient", "is_connected" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed24747eaaa6483ed4a4aeddf627a2cb8bf9db6f
83af0bca329d51a65b2bc1d4e8497c9cb1d8e9f0
v1.0
complete
Taco
Taco_92255_C
from typing import List def digit_root(n: int) -> int: """ Calculate the digit root of a number. >>> digit_root(56) 2 >>> digit_root(1234) 1 """ pass def is_digit_root_palindrome(number: int) -> bool: """ Determine if the digit root of a number is a palindrome. >>> is_digit_root_pa...
def digit_root(n): """ Calculate the digit root of a number. """ while n >= 10: n = sum(int(digit) for digit in str(n)) return n def is_digit_root_palindrome(number): """ Determine if the digit root of a number is a palindrome. """ root = digit_root(number) return str(ro...
from solution import digit_root, is_digit_root_palindrome, process_input def test_digit_root(): assert digit_root(56) == 2 assert digit_root(1234) == 1 assert digit_root(98765) == 8 assert digit_root(1010101) == 4 assert digit_root(34567) == 7 assert digit_root(89) == 8 assert digit_root(12...
[ { "docstring": "Calculate the digit root of a number.", "function_declaration": "def digit_root(n):", "function_name": "digit_root", "parameter_list": "(n)" }, { "docstring": "Determine if the digit root of a number is a palindrome.", "function_declaration": "def is_digit_root_palindrome...
[ 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 digit_root(n):\n \"\"\"\n Returns the digit root of an integer n.\n \"\"\"\n while n >= 10:\n n = sum(int(digit) for digit in str(n))\n r...
trial_gpt4o_2
{ "original_instruction": "Write a program that reads a list of integers and checks for each integer if it is a \"digit root palindrome.\" The digit root of a number is obtained by an iterative process of summing digits, on each step using the result from the previous step, until a single-digit number is obtained. A ...
0.634628
Taco_92255
C
[ "digit_root", "is_digit_root_palindrome", "process_input" ]
3
[ [ "is_digit_root_palindrome", "digit_root" ], [ "process_input", "is_digit_root_palindrome" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
da01a89aee0ec2b466735907b655043ac108be55
10f7753e49fde268e61d5eabf1b1b09b6639c9f5
v1.0
complete
Taco
Taco_91873_C
def is_valid_triangle(a, b, c): """ Check if three given side lengths can form a valid triangle. >>> is_valid_triangle(3, 4, 5) == True >>> is_valid_triangle(1, 1, 3) == False """ def calculate_area(a, b, c): """ Calculate the area of a triangle using Heron's formula if the given sides form a v...
import math def is_valid_triangle(a, b, c): # Check if sum of any two sides is greater than the third side if a + b > c and a + c > b and b + c > a: return True else: return False def calculate_area(a, b, c): if is_valid_triangle(a, b, c): # Using Heron's formula to calculate t...
def test_is_valid_triangle(): assert is_valid_triangle(3, 4, 5) == True assert is_valid_triangle(1, 1, 3) == False assert is_valid_triangle(5, 5, 5) == True assert is_valid_triangle(10, 20, 30) == False assert is_valid_triangle(7, 10, 5) == True def test_calculate_area(): assert calculate_area(...
[ { "docstring": null, "function_declaration": "def is_valid_triangle(a, b, c):", "function_name": "is_valid_triangle", "parameter_list": "(a, b, c)" }, { "docstring": null, "function_declaration": "def calculate_area(a, b, c):", "function_name": "calculate_area", "parameter_list":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_valid_triangle(a, b, c):\n \"\"\"\n Returns True if a, b, c can form a valid triangle, otherwise False.\n \"\"\"\n return a + b >...
trial_gpt4o_1
{ "original_instruction": "You are given three sides of a triangle a, b, and c. Determine if a triangle is valid with these side lengths and if valid, calculate the area of the triangle using Heron's formula. If the triangle is not valid, print \"Invalid\".\n\n-----Constraints-----\n - 1≤a≤100\n - 1≤b≤100\n - 1≤c≤100...
0.789314
Taco_91873
C
[ "is_valid_triangle", "calculate_area" ]
2
[ [ "calculate_area", "is_valid_triangle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e0ac597db8d9698208056b6508b3a50a663df3d1
06ceb34b0d3bfc7f6e34369fd0cf9d7cb5578e60
v1.0
complete
Taco
Taco_92852_C
def largest_palindrome_product(n: int) -> int: """ Find the largest numerical palindrome that can be obtained by multiplying two n-digit numbers. >>> largest_palindrome_product(1) 9 >>> largest_palindrome_product(2) 9009 >>> largest_palindrome_product(3) 906609 """
def is_palindrome(num): """ Check if a number is a palindrome. """ return str(num) == str(num)[::-1] def largest_palindrome_product(n): """ Find the largest palindrome product of two n-digit numbers. """ max_num = 10**n - 1 min_num = 10**(n-1) max_palindrome = 0 for i i...
from solution import largest_palindrome_product def test_largest_palindrome_product_1_digit(): assert largest_palindrome_product(1) == 9 def test_largest_palindrome_product_2_digits(): assert largest_palindrome_product(2) == 9009 def test_largest_palindrome_product_3_digits(): assert largest_palindrome_p...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Find the largest palindrome product of two n-digit numbers.", "function_declaration": "def largest_palind...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(num):\n \"\"\"\n Check if a given number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef largest_palindrome_prod...
trial_gpt4o_2
{ "original_instruction": "Gabriella is learning about numerical palindromes, which are numbers that read the same forwards and backwards. She wants to write a program to find the largest numerical palindrome that can be obtained by multiplying two n-digit numbers. Write a program to help Gabriella by taking in a sin...
0.729797
Taco_92852
C
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0bdd0f908b65bb5c315d8e26dc4a4c618f74e7e6
6bb0bee99f7a35dea936f1d0fb3300f7c7f20859
v1.0
complete
Taco
Taco_92819_C
def nthSmithNumber(n: int) -> int: """ Given an integer `n`, find the `nth` Smith Number. >>> nthSmithNumber(1) 4 >>> nthSmithNumber(2) 22 >>> nthSmithNumber(3) 27 >>> nthSmithNumber(4) 58 >>> nthSmithNumber(5) 85 """
def prime_factors(n): """ Helper function to return prime factors of a number """ i = 2 factors = [] while i * i <= n: while n % i == 0: factors.append(i) n //= i i += 1 if n > 1: factors.append(n) return factors def sum_of_digits(n): ...
from solution import nthSmithNumber def test_nthSmithNumber_case1(): assert nthSmithNumber(1) == 4 def test_nthSmithNumber_case2(): assert nthSmithNumber(2) == 22 def test_nthSmithNumber_case3(): assert nthSmithNumber(3) == 27 def test_nthSmithNumber_case4(): assert nthSmithNumber(4) == 58 def test...
[ { "docstring": "Helper function to return prime factors of a number ", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Helper function to return sum of digits of a number ", "function_declaration": "def sum_of_...
[ 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 prime_factors(n):\n \"\"\" \n Helper function to return prime factors of a number \n \"\"\"\n i = 2\n factors = []\n while i * i <= n:\n ...
trial_gpt4o_0
{ "original_instruction": "Given an integer `n`, find the `nth` Smith Number.\n\nA Smith number is a composite number for which the sum of its digits is equal to the sum of the digits in its prime factorization (excluding 1).\n\nExample 1:\nInput:\nn = 1\nOutput:\n4\nExplanation:\nThe first Smith Number is 4 whose pr...
0.57852
Taco_92819
C
[ "prime_factors", "sum_of_digits", "is_smith_number", "nthSmithNumber" ]
4
[ [ "is_smith_number", "prime_factors" ], [ "is_smith_number", "sum_of_digits" ], [ "nthSmithNumber", "is_smith_number" ] ]
3
[]
false
[]
false
pytest
true
[]
true
383f4e9af8d0ec278106a0982f68387ddcaa0bb1
8f500dffe140e44ff5cc77ccdd5d7b5312a8d433
v1.0
complete
Taco
Taco_92671_C
def is_prime(num): """Check if a number is prime.""" pass def sum_of_unique_primes(test_cases): """Calculate the sum of unique prime numbers in each list of test cases. >>> sum_of_unique_primes([(5, [2, 3, 4, 5, 6])]) == [10] >>> sum_of_unique_primes([(4, [8, 9, 10, 11])]) == [11] >>> sum_of_un...
def is_prime(num): """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 False i += 6 retur...
from solution import process_input, is_prime, sum_of_unique_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_sum_of_unique_primes(): assert sum_of_unique_primes([(5, [...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Calculate the sum of unique prime numbers in each list of test cases.", "function_declaration": "def sum_of_unique_primes(...
[ 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 \"\"\"Check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0...
trial_gpt4o_0
{ "original_instruction": "Maggu has started to learn numbers and their properties. This time, he is fascinated by prime numbers. His teacher gave him some tasks related to prime numbers, and he has come to you for help.\n\nYou need to find all unique prime numbers in a given list and then compute their sum.\n\nINPUT...
0.674482
Taco_92671
C
[ "is_prime", "sum_of_unique_primes", "process_input" ]
3
[ [ "process_input", "sum_of_unique_primes" ], [ "sum_of_unique_primes", "is_prime" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
10720d642c90cdf0d2feccb7cd076d75df87a7f7
e8a89ea8410f58e926b710cb0945f07f9285b285
v1.0
complete
Taco
Taco_92545_C
def min_distinct_stones(n, powers): """ Determines the minimum number of distinct types of stones after performing any number of merge operations. Parameters: n (int): the number of different types of magical stones initially present. powers (list of int): the magical powers of the stones. Ret...
def min_distinct_stones(n, powers): """ Determines the minimum number of distinct types of stones after performing any number of merge operations. Parameters: n (int): the number of different types of magical stones initially present. powers (list of int): the magical powers of the stones. Ret...
from solution import min_distinct_stones def test_single_stone(): assert min_distinct_stones(1, [7]) == 1 def test_multiple_stones_case_1(): assert min_distinct_stones(3, [5, 9, 12]) == 1 def test_multiple_stones_case_2(): assert min_distinct_stones(4, [8, 16, 24, 32]) == 1 def test_multiple_stones_case...
[ { "docstring": "Determines the minimum number of distinct types of stones after performing any number of merge operations.\n\nParameters:\nn (int): the number of different types of magical stones initially present.\npowers (list of int): the magical powers of the stones.\n\nReturns:\nint: the minimum number of ...
[ 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 min_distinct_stone_types(n, stone_powers):\n \"\"\"\n Determines the minimum number of distinct types of stones after performing any number of merge oper...
trial_gpt4o_2
{ "original_instruction": "In a fantasy game, there are n different types of magical stones, each with a unique magical power represented by a positive integer. A wizard can merge any two different types of stones to create a new type of stone whose magical power is the absolute difference between the powers of the t...
0.528903
Taco_92545
C
[ "min_distinct_stones", "find_gcd" ]
2
[ [ "min_distinct_stones", "find_gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64f25b8dbec2d6094c1ab9aa5358e6db678a1f29
4e440911ad68e019ddf11890d44dd7a6f6978227
v1.0
complete
Taco
Taco_92575_C
def digit_sum(x: int) -> int: """ Returns the sum of the digits of the number x. """ pass def max_digit_sum(L: int, R: int) -> int: """ Returns the number within the range [L, R] with the maximum digit sum. If multiple numbers have the same digit sum, returns the smallest one. >>> max_digi...
def digit_sum(x): """ Returns the sum of the digits of the number x. """ return sum(int(digit) for digit in str(x)) def max_digit_sum(L, R): """ Returns the number within the range [L, R] with the maximum digit sum. If multiple numbers have the same digit sum, returns the smallest one. ...
from solution import digit_sum, max_digit_sum def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(0) == 0 assert digit_sum(999) == 27 def test_max_digit_sum(): assert max_digit_sum(10, 20) == 19 assert max_digit_sum(1, 100) == 99 assert max_digit_sum(50, 60) == 59 assert max_...
[ { "docstring": "Returns the sum of the digits of the number x.", "function_declaration": "def digit_sum(x):", "function_name": "digit_sum", "parameter_list": "(x)" }, { "docstring": "Returns the number within the range [L, R] with the maximum digit sum.\nIf multiple numbers have the same dig...
[ 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 digit_sum(x):\n \"\"\"\n Returns the sum of the digits of the number x.\n \"\"\"\n return sum(int(digit) for digit in str(x))\n\ndef max_digit_sum(...
trial_gpt4o_0
{ "original_instruction": "Lucas is fascinated by numbers and their properties. Recently, he learned about digit sums and is particularly interested in finding numbers with special digit sum properties. For any positive integer \\( x \\), its digit sum is defined as the sum of all its digits. For example, the digit s...
0.700304
Taco_92575
C
[ "digit_sum", "max_digit_sum" ]
2
[ [ "max_digit_sum", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63ffa034f0b4210d9cd2386fb97dfaa5d47b1393
db466d4f65b2f6395dbf5dd836667bebc16dbcd1
v1.0
complete
Taco
Taco_91784_C
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes): """ Builds a binary tree from list of nodes """ if not nodes: return None node_dict = {v: TreeNode(v) for v, l, r in nodes} for v, l, r in nodes: ...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes): if not nodes: return None node_dict = {v: TreeNode(v) for v, l, r in nodes} for v, l, r in nodes: node = node_dict[v] if l != 0: ...
def test_case_1(): n = 3 nodes = [(1, 2, 3), (2, 0, 0), (3, 0, 0)] assert can_transform_to_balanced_tree(n, nodes) == "YES" def test_case_2(): n = 3 nodes = [(1, 0, 2), (2, 0, 3), (3, 0, 0)] assert can_transform_to_balanced_tree(n, nodes) == "NO" def test_case_3(): n = 1 nodes = [(1, 0...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef is_...
trial_gpt4o_1
{ "original_instruction": "In a magical land, there exists a special type of tree called a \"balanced tree.\" A balanced tree is defined as one in which the heights of the two subtrees of any node never differ by more than one.\n\nYou have recently discovered a magical spell that allows you to transform a regular bin...
0.730835
Taco_91784
C
[ "build_tree", "is_balanced", "can_transform_to_balanced_tree" ]
3
[ [ "can_transform_to_balanced_tree", "build_tree" ], [ "can_transform_to_balanced_tree", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
6479d8dc07de9c85060060c330c955313fd8fe88
3eff948ff9d721dff582265f5b50fc108c4fd9e6
v1.0
complete
Taco
Taco_92564_C
def switch_row(matrix, row): """ Switch all the values (flip 0s to 1s and 1s to 0s) in the specified row of the matrix. >>> matrix = [[1, 0, 1], [0, 1, 0], [1, 1, 1]] >>> switch_row(matrix, 1) >>> matrix [[1, 0, 1], [1, 0, 1], [1, 1, 1]] """ def count_ones_in_row(matrix, row): """ C...
def switch_row(matrix, row): """ Switch all the values (flip 0s to 1s and 1s to 0s) in the specified row of the matrix. """ matrix[row] = [1 - x for x in matrix[row]] def count_ones_in_row(matrix, row): """ Count the number of 1s in the specified row of the matrix. """ return sum(matrix...
def test_switch_row(): matrix = [[1, 0, 1], [0, 1, 0], [1, 1, 1]] switch_row(matrix, 1) assert matrix == [[1, 0, 1], [1, 0, 1], [1, 1, 1]] def test_count_ones_in_row(): matrix = [[1, 0, 1], [0, 1, 0], [1, 1, 1]] assert count_ones_in_row(matrix, 0) == 2 assert count_ones_in_row(matrix, 1) == 1 ...
[ { "docstring": "Switch all the values (flip 0s to 1s and 1s to 0s) in the specified row of the matrix.", "function_declaration": "def switch_row(matrix, row):", "function_name": "switch_row", "parameter_list": "(matrix, row)" }, { "docstring": "Count the number of 1s in the specified row of ...
[ 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 switch_row(matrix, i):\n \"\"\"\n Switch all the values in row i of the matrix.\n \"\"\"\n matrix[i] = [1 - val for val in matrix[i]]\n\ndef count_...
trial_gpt4o_4
{ "original_instruction": "You are given a binary matrix with dimensions N x M. You need to perform Q queries on this matrix. Each query can be of two types:\n\n1. **Switch row i**: Flip all the values in row `i` of the matrix, that is, change all 0s to 1s and all 1s to 0s.\n2. **Count ones in row i**: Return the num...
0.535979
Taco_92564
C
[ "switch_row", "count_ones_in_row", "process_queries" ]
3
[ [ "process_queries", "count_ones_in_row" ], [ "process_queries", "switch_row" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
cf43537637ad66b0c138ebbad944d56cfdd370df
f49713116f4420fa329891244912b1688feca201
v1.0
complete
Taco
Taco_92877_C
def is_balanced_binary_tree(tree: List[Union[int, None]]) -> bool: """ Determine whether a given binary tree is balanced. A binary tree is balanced if, for every node in the tree, the difference in height between its left and right subtrees is at most 1. Args: tree (List[Union[int, Non...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(index, tree): if index >= len(tree) or tree[index] is None: return None node = TreeNode(tree[index]) node.left = build_tree(2 * index + 1, ...
from solution import is_balanced_binary_tree def test_balanced_tree(): assert is_balanced_binary_tree([3, 9, 20, None, None, 15, 7]) == True def test_unbalanced_tree(): assert is_balanced_binary_tree([1, 2, 2, 3, 3, None, None, 4, 4]) == False def test_empty_tree(): assert is_balanced_binary_tree([]) == ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef is_balanced(tree):\n if not tree:\...
trial_gpt4o_1
{ "original_instruction": "Problem statement\n\nYuki is fascinated by binary trees, and she has recently learned about a special kind of binary tree called \"Balanced Binary Tree\". A binary tree is considered balanced if, for every node in the tree, the difference in height between its left and right subtrees is at ...
0.84517
Taco_92877
C
[ "build_tree", "isBalanced", "is_balanced_binary_tree" ]
3
[ [ "is_balanced_binary_tree", "build_tree" ], [ "is_balanced_binary_tree", "isBalanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
e73fe101878dbda4e8e649fab70e0c5bf53497fe
bb74f7ffdb75e9490c0d7236827a6cc138741ad2
v1.0
complete
Taco
Taco_93015_C
def is_prime(num): """Returns whether a number is prime.""" pass def product_of_primes(N): """ Returns the product of all prime numbers less than or equal to N. >>> product_of_primes(5) 30 >>> product_of_primes(10) 210 """ pass
def is_prime(num): """Returns whether 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 False i += 6 ...
from solution import is_prime, product_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(17) == True def test_product_of_primes(): assert product_of_primes...
[ { "docstring": "Returns whether a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the product of all prime numbers less than or equal to N.", "function_declaration": "def product_of_primes(...
[ 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 \"\"\"Returns whether a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num %...
trial_gpt4o_0
{ "original_instruction": "Given an integer N, calculate the product of all prime numbers less than or equal to N.\n\nPrint the answer as a single integer.\n\nConstraints\n\n* 1 \\leq N \\leq 50\n\nInput\n\nInput is given from Standard Input in the following format:\n\nN\n\nOutput\n\nPrint the product of all prime nu...
0.841267
Taco_93015
C
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f076fe0ce20c52ec4222be6472f0007b06c20963
bd107c166d3a50367ca060802db05a988f5bd750
v1.0
complete
Taco
Taco_92514_C
from typing import List, Tuple def find_max_clique_in_network(n: int, m: int, friendships: List[Tuple[int, int]]) -> Tuple[int, List[int]]: """Find the size of the largest clique and its members in the given social network. Args: n (int): Number of individuals in the social network. m (int): Number of...
import itertools def is_clique(graph, vertices): for i in range(len(vertices)): for j in range(i+1, len(vertices)): if vertices[j] not in graph[vertices[i]]: return False return True def find_maximum_cliques(n, friendships): # Create adjacency list graph = {i: [] fo...
from solution import find_max_clique_in_network def test_sample_input_1(): n = 5 m = 6 friendships = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)] size, clique = find_max_clique_in_network(n, m, friendships) assert size == 4 assert set(clique) == {1, 2, 3, 4} def test_sample_input_2(): ...
[ { "docstring": null, "function_declaration": "def is_clique(graph, vertices):", "function_name": "is_clique", "parameter_list": "(graph, vertices)" }, { "docstring": null, "function_declaration": "def find_maximum_cliques(n, friendships):", "function_name": "find_maximum_cliques", ...
[ 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 itertools import combinations\n\ndef find_maximum_cliques(n, m, friendships):\n # Create an adjacency matrix to represent the graph\n adjacency_matrix =...
trial_gpt4o_2
{ "original_instruction": "David is working on a project that involves analyzing social networks. One of his tasks is to detect communities within the network. A community in a social network is a group of individuals who are more densely connected to each other than to the rest of the network. David has decided to u...
0.621835
Taco_92514
C
[ "is_clique", "find_maximum_cliques", "find_max_clique_in_network" ]
3
[ [ "find_max_clique_in_network", "find_maximum_cliques" ], [ "find_maximum_cliques", "is_clique" ] ]
2
[]
false
[]
false
pytest
true
[]
true
63dde3b60045326d224455c848cff4adf321a0ed
d2f4c126b22a01e0b1f42443373deb2774e0a3bf
v1.0
complete
Taco
Taco_93028_C
def is_prime(n: int) -> bool: """ Determine if a given number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(29) True >>> is_prime(30) False """ def is_sum_of_t_primes(k: int, t: int) -> bool: """ Determine if it's possibl...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def is_sum_of_t_primes(k, t): if t == 1:...
from solution import is_prime, is_sum_of_t_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(29) == True assert is_prime(30) == False def test_is_sum_of_t_primes(): assert is_sum_of_t_pri...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_sum_of_t_primes(k, t):", "function_name": "is_sum_of_t_primes", "parameter_list": "(k, t)" }, { "d...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Returns True if n is a prime number, else False.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_4
{ "original_instruction": "Given a positive integer K, determine if it's possible to express K as a sum of exactly T prime numbers (not necessarily distinct).\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq K \\leq 10^6\n - 1 \\leq T \\leq 100\n\n-----Input-----\nInput is given from Standar...
0.734197
Taco_93028
C
[ "is_prime", "is_sum_of_t_primes", "main" ]
3
[ [ "is_sum_of_t_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5378da9be89260c3343d140b5fd5a919a0a2369c
0bb9d200e58576f865bf72f1dabff132f63ae40a
v1.0
complete
Taco
Taco_93159_C
def is_palindrome(num): """ Determines if the digits of the number form a palindrome. >>> is_palindrome(121) True >>> is_palindrome(12321) True >>> is_palindrome(1234) False >>> is_palindrome(987789) True """ def determine_palindrome_status(numbers): """ For each number in the list,...
def is_palindrome(num): """ Determines if the digits of the number form a palindrome. """ num_str = str(num) return num_str == num_str[::-1] def determine_palindrome_status(numbers): """ For each number in the list, determine if it is a palindrome and print the result accordingly. """ ...
from solution import is_palindrome, determine_palindrome_status def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(12321) == True assert is_palindrome(1234) == False assert is_palindrome(987789) == True assert is_palindrome(1) == True assert is_palindrome(22) == Tr...
[ { "docstring": "Determines if the digits of the number form a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "For each number in the list, determine if it is a palindrome and print the result acco...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n \"\"\"\n Determines if the digits of the given number form a palindrome.\n \n Args:\n number (int): The number to be ch...
trial_gpt4o_1
{ "original_instruction": "You are given a list of positive integers. For each integer, determine if the digits of the number form a palindrome (read the same forwards and backwards). If the number is a palindrome, print \"Palindrome\", otherwise print \"Not Palindrome\".\n\nInput\n\nThe first line of the input conta...
0.786672
Taco_93159
C
[ "is_palindrome", "determine_palindrome_status" ]
2
[ [ "determine_palindrome_status", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
12f72d02eef90e391bd886548c8edf7ac1d35b72
6e9d8088b7449b8f050e99d60f40cd5d192f8dc2
v1.0
complete
Taco
Taco_93262_C
def hamiltonian_tour(r: int, c: int, n: int) -> str: """ Determine if a Hamiltonian tour is possible on an n x n grid starting from (r, c) and, if so, provide a sequence of moves (U, D, L, R). >>> hamiltonian_tour(1, 1, 1) "" >>> hamiltonian_tour(1, 1, 3) "impossible" >>> hamiltonian_tour(3, 3,...
def is_hamiltonian_walk_possible(r, c, n): """ Checks if a Hamiltonian walk (visiting each grid cell exactly once and returning to the start point) is possible on an odd n x n grid starting from (r, c). """ # For the odd grid n x n when n > 2, there is no possibility to complete the tour return ...
from solution import hamiltonian_tour def test_single_block(): assert hamiltonian_tour(1, 1, 1) == "" def test_3x3_grid(): assert hamiltonian_tour(1, 1, 3) == "impossible" assert hamiltonian_tour(2, 2, 3) == "impossible" assert hamiltonian_tour(3, 3, 3) == "impossible" def test_5x5_grid(): assert...
[ { "docstring": "Checks if a Hamiltonian walk (visiting each grid cell exactly once and returning\nto the start point) is possible on an odd n x n grid starting from (r, c).", "function_declaration": "def is_hamiltonian_walk_possible(r, c, n):", "function_name": "is_hamiltonian_walk_possible", "param...
[ 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_hamiltonian_walk_possible(r, c, n):\n \"\"\"\n Checks if a Hamiltonian walk (visiting each grid cell exactly once and returning\n to the start poin...
trial_gpt4o_0
{ "original_instruction": "A well-known professional photographer has been hired to document various festivities in a town. The town's layout can be represented as an odd grid of size $n \\times n$, where $1 \\le n \\le 99$ and $n$ is always odd. The grid is numbered from $1$ to $n$ both horizontally and vertically, ...
0.557032
Taco_93262
C
[ "is_hamiltonian_walk_possible", "get_hamiltonian_path", "hamiltonian_tour" ]
3
[ [ "hamiltonian_tour", "get_hamiltonian_path" ], [ "hamiltonian_tour", "is_hamiltonian_walk_possible" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e15000891e16412fd8f8c1e359a3e89ba2f72493
57852ada0302983ae710584a720dc2382ed8a22f
v1.0
complete
Taco
Taco_92954_C
def minimal_marathon_distance(n: int, paths: List[Tuple[int, int, int]]) -> int: """ Determine the minimal distance required to cover all key locations in a directed path starting at location 0 and ending at location n-1. Args: n: An integer representing the number of locations. paths: A list ...
from collections import defaultdict, deque def find_min_distance(n, paths): # Create a graph adjacency list graph = defaultdict(list) for u, v, d in paths: graph[u].append((v, d)) # Kahn's algorithm for topological sorting in_degree = [0] * n for u in graph: for v, _ in gra...
def test_minimal_marathon_distance_case_1(): n = 3 paths = [ (0, 1, 2), (1, 2, 3) ] assert minimal_marathon_distance(n, paths) == 5 def test_minimal_marathon_distance_case_2(): n = 4 paths = [ (0, 1, 1), (0, 2, 4), (1, 2, 2), (2, 3, 5) ] a...
[ { "docstring": null, "function_declaration": "def find_min_distance(n, paths):", "function_name": "find_min_distance", "parameter_list": "(n, paths)" }, { "docstring": null, "function_declaration": "def minimal_marathon_distance(n, path_info):", "function_name": "minimal_marathon_dis...
[ 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 find_min_distance(n, paths):\n # Create a graph adjacency list\n graph = defaultdict(list)\n for u, v, d...
trial_gpt4o_0
{ "original_instruction": "Alex is organizing a marathon in his city. The marathon route must be designed such that it visits several key locations and the total distance covered is as minimal as possible. Alex has a list of all the locations and the distances between each pair of locations. Unfortunately, due to cit...
0.613121
Taco_92954
C
[ "find_min_distance", "minimal_marathon_distance" ]
2
[ [ "minimal_marathon_distance", "find_min_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a20d7f17e0627a38c24c8fd8f7bf15386befa853
2e02ab1fd50aa619e1822d4b990a51981499c3da
v1.0
complete
Taco
Taco_93229_C
def max_in_subgrid(grid, queries): """ Returns the maximum value within the specified subgrid for each query. Args: grid: List[List[int]] - 2D List representing the grid. queries: List[Tuple[int, int, int, int]] - List of tuples representing the queries. Returns: List[int] - List o...
def max_in_subgrid(grid, queries): """ Returns the maximum value within the specified subgrid for each query. Args: grid: List[List[int]] - 2D List representing the grid. queries: List[Tuple[int, int, int, int]] - List of tuples representing the queries. Returns: List[int] - List o...
def test_max_in_subgrid_single_query(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] queries = [(1, 1, 2, 2)] assert max_in_subgrid(grid, queries) == [5] def test_max_in_subgrid_multiple_queries(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] ...
[ { "docstring": "Returns the maximum value within the specified subgrid for each query.\n\nArgs:\ngrid: List[List[int]] - 2D List representing the grid.\nqueries: List[Tuple[int, int, int, int]] - List of tuples representing the queries.\n\nReturns:\nList[int] - List of maximum values for each query.", "func...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_max_in_subgrid(grid, queries):\n \"\"\"\n Find the maximum value in the specified subgrid for each query.\n \n Parameters:\n - grid (list o...
trial_gpt4o_2
{ "original_instruction": "Consider a grid with N rows and M columns. Each cell in the grid contains an integer. Let the value in the cell at row $i$ and column $j$ be denoted by $a_{ij}$. You are given Q queries, each consisting of four integers $r1, c1, r2, c2$, which represent the top-left and bottom-right coordin...
0.602113
Taco_93229
C
[ "max_in_subgrid", "solve" ]
2
[ [ "solve", "max_in_subgrid" ] ]
1
[]
false
[]
false
pytest
false
[]
true
369af1cd6d4677223b73282e51a44c6819f56f17
7cbc1074540da6d4281ac24f92854fee9ea53be3
v1.0
complete
Taco
Taco_93354_C
from typing import List, Tuple def max_landmarks_visited(n: int, m: int, k: int, routes: List[Tuple[int, int]]) -> int: """ Calculate the maximum number of distinct landmarks that can be visited starting and ending in the capital city, within a given number of days. Args: n (int): Number of ci...
def bfs_max_landmarks(n, adj, k, start=1): from collections import deque queue = deque([(start, 0, 0)]) # (current_city, days_spent, bitmask_visited) visited = {(start, 0): 0} max_landmarks = 0 while queue: city, days, bm = queue.popleft() landmarks_visited = bin(bm).count('1')...
from solution import max_landmarks_visited def test_case_1(): n = 4 m = 4 k = 3 routes = [(1, 2), (1, 3), (2, 4), (3, 4)] assert max_landmarks_visited(n, m, k, routes) == 3 def test_case_2(): n = 5 m = 6 k = 4 routes = [(1, 2), (1, 3), (2, 3), (2, 4), (3, 5), (4, 5)] assert max...
[ { "docstring": null, "function_declaration": "def bfs_max_landmarks(n, adj, k, start=1):", "function_name": "bfs_max_landmarks", "parameter_list": "(n, adj, k, start=1)" }, { "docstring": null, "function_declaration": "def max_landmarks_visited(n, m, k, routes):", "function_name": "m...
[ 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 bfs_max_landmarks(n, adj, k, start=1):\n from collections import deque\n queue = deque([(start, 0, 0)]) # (current_city, days_spent, bitmask_visited)\n ...
trial_gpt4o_0
{ "original_instruction": "In the fictional country Z, there are n cities connected by m two-way flight routes. Each city has a single significant landmark that is a point of interest for tourists. The tourism board of Z has a problem: tourists wish to visit as many distinct landmarks as possible within a given perio...
0.724578
Taco_93354
C
[ "bfs_max_landmarks", "max_landmarks_visited" ]
2
[ [ "max_landmarks_visited", "bfs_max_landmarks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
38eb23e34bf5cb25bf4d654c71c9afcb427b0f7d
ebfd8a85bf0eeb99c12186a69b754eb14cd9e977
v1.0
complete
Taco
Taco_93380_C
from typing import List, Tuple def gcd_of_list(nums: List[int]) -> int: """ Calculate the greatest common divisor (GCD) of a list of numbers. """ pass def can_be_beautiful_array(n: int, arr: List[int]) -> str: """ Determine if an array can be transformed into a beautiful array by removing at m...
import math from functools import reduce def gcd_of_list(nums): return reduce(math.gcd, nums) def can_be_beautiful_array(n, arr): overall_gcd = gcd_of_list(arr) if overall_gcd > 1: return "YES" for i in range(n): temp_arr = arr[:i] + arr[i+1:] if gcd_of_list(temp_arr) > 1: ...
from solution import can_be_beautiful_array, process_input def test_gcd_of_list(): assert gcd_of_list([4, 6, 8]) == 2 assert gcd_of_list([15, 10, 5, 10, 5]) == 5 assert gcd_of_list([7, 5, 9, 11]) == 1 def test_can_be_beautiful_array(): assert can_be_beautiful_array(3, [4, 6, 8]) == "YES" assert ca...
[ { "docstring": null, "function_declaration": "def gcd_of_list(nums):", "function_name": "gcd_of_list", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def can_be_beautiful_array(n, arr):", "function_name": "can_be_beautiful_array", "parameter_list": "(...
[ 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": "from math import gcd\nfrom functools import reduce\n\ndef is_beautiful_array_possible(n, a):\n \"\"\"\n Determines if we can make the array beautiful by remo...
trial_gpt4o_3
{ "original_instruction": "Alice loves arrays, especially those involving interesting properties. She recently encountered a specific type of array called a \"beautiful\" array. An array $a$ of length $n$ is beautiful if the greatest common divisor (gcd) of all elements of $a$ is greater than 1.\n\nAlice wants to det...
0.61996
Taco_93380
C
[ "gcd_of_list", "can_be_beautiful_array", "process_input" ]
3
[ [ "can_be_beautiful_array", "gcd_of_list" ], [ "process_input", "can_be_beautiful_array" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
c35557d8c84309adf61399cc1b08e5b1c971d4fd
f6d21e3f22316c9f10f5811a3dbc124b1fa8fd8e
v1.0
complete
Taco
Taco_93266_C
class TreeNode: def __init__(self, value=0, color='red', left=None, right=None): self.value = value self.color = color self.left = left self.right = right def lcaColor(root: TreeNode, p: int, q: int) -> str: """ Determine the color of the lowest common ancestor (LCA) of two ...
class TreeNode: def __init__(self, value=0, color='red', left=None, right=None): self.value = value self.color = color self.left = left self.right = right def findLCA(root, p, q): """ Helper function to find the lowest common ancestor of two nodes in the binary tree. """...
import pytest from solution import TreeNode, lcaColor def test_lca_color_sample(): # Construct the sample tree root = TreeNode(1, 'red') root.left = TreeNode(2, 'blue') root.right = TreeNode(3, 'red') root.left.left = TreeNode(4, 'blue') root.left.right = TreeNode(5, 'red') root.right.left ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value, color, left=None, right=None):\n self.value = value\n self.color = color\n self.left = left\n ...
trial_gpt4o_2
{ "original_instruction": "In a binary tree, the nodes are colored either red or blue. Your task is to determine the color of the lowest common ancestor (LCA) of two given nodes. \n\nThe LCA of two nodes p and q in a binary tree is defined as the lowest node that has both p and q as descendants (where we allow a node...
0.528262
Taco_93266
C
[ "findLCA", "lcaColor" ]
2
[ [ "lcaColor", "findLCA" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
51c6fa7f9adc1c6ec355c1fcc489bfe1969d6d5b
2f9f2026c380aedb5e0f07bb3a4e5ed37ff26069
v1.0
complete
Taco
Taco_93479_C
from typing import List def is_strong_password(password: str) -> bool: """ Determines whether a password is strong based on the given criteria. - Contains at least one uppercase letter. - Contains at least one lowercase letter. - Contains at least one digit. - Contains at least one special char...
def is_strong_password(password): """ Determines whether a password is strong based on the given criteria. """ has_upper = any(c.isupper() for c in password) has_lower = any(c.islower() for c in password) has_digit = any(c.isdigit() for c in password) has_special = any(c in "!@#$%^&*()-+" fo...
from solution import is_strong_password, evaluate_passwords def test_is_strong_password(): # Test cases for strong passwords assert is_strong_password('HelloWorld1!') == True assert is_strong_password('Another$Pass2') == True # Test cases for weak passwords assert is_strong_password('weakpassword1...
[ { "docstring": "Determines whether a password is strong based on the given criteria.", "function_declaration": "def is_strong_password(password):", "function_name": "is_strong_password", "parameter_list": "(password)" }, { "docstring": "Evaluates each of the provided passwords and returns 'S...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_strong_password(password):\n \"\"\"\n Determines if the provided password is strong based on the given criteria.\n \n A strong password must hav...
trial_gpt4o_1
{ "original_instruction": "You have been tasked with assessing the strength of passwords based on certain criteria. A strong password should satisfy the following conditions:\n1. It contains at least one uppercase letter.\n2. It contains at least one lowercase letter.\n3. It contains at least one digit.\n4. It contai...
0.604417
Taco_93479
C
[ "is_strong_password", "evaluate_passwords" ]
2
[ [ "evaluate_passwords", "is_strong_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
37ad6bf51ff3cb554f770dc589c45a0bf2401dec
4ef610fa93204d7b96b974bf4137a21d8686c4a6
v1.0
complete
Taco
Taco_93387_C
from typing import List, Tuple def minimum_total_maintenance_cost(n: int, m: int, connections: List[Tuple[int, int, int]]) -> int: """ You are given an undirected graph representing a network of servers and connections between them. Your task is to optimize the network in such a way that the total m...
def find(parent, i): """ A function to find the set of an element i using path compression. """ if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): """ A function that does union of two sets of x and y...
from solution import minimum_total_maintenance_cost def test_case_1(): n = 4 m = 5 connections = [ (1, 2, 1), (1, 3, 4), (2, 3, 1), (2, 4, 2), (3, 4, 3) ] assert minimum_total_maintenance_cost(n, m, connections) == 4 def test_case_2(): n = 3 m = 3 ...
[ { "docstring": "A function to find the set of an element i using path compression.", "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": "A function that does union of two sets of x and y using rank.", "function_decla...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):...
trial_gpt4o_2
{ "original_instruction": "You are given an undirected graph representing a network of servers and connections between them. The graph consists of `n` servers and `m` bidirectional connections, where the cost of maintaining each connection is given. Your task is to optimize the network in such a way that the total ma...
0.708257
Taco_93387
C
[ "find", "union", "kruskal", "minimum_total_maintenance_cost" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_total_maintenance_cost", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
500d13b4087b2cbdd7f61523d928d76490ad646d
54a3bb637158188fde0ea56dee9c933edcf99950
v1.0
complete
Taco
Taco_93503_C
def collatz_length(n: int) -> int: """ Calculate the length of the Collatz sequence for a given integer n. >>> collatz_length(1) == 1 >>> collatz_length(2) == 2 >>> collatz_length(3) == 8 >>> collatz_length(4) == 3 >>> collatz_length(10) == 7 """ # Your code here def longest_collat...
def collatz_length(n): length = 1 while n != 1: if n % 2 == 0: n = n // 2 else: n = 3 * n + 1 length += 1 return length def longest_collatz_sequence(L, R): max_length = 0 for i in range(L, R + 1): length = collatz_length(i) if length >...
def test_collatz_length(): assert collatz_length(1) == 1 assert collatz_length(2) == 2 assert collatz_length(3) == 8 assert collatz_length(4) == 3 assert collatz_length(10) == 7 def test_longest_collatz_sequence(): assert longest_collatz_sequence(1, 10) == 20 assert longest_collatz_sequence...
[ { "docstring": null, "function_declaration": "def collatz_length(n):", "function_name": "collatz_length", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def longest_collatz_sequence(L, R):", "function_name": "longest_collatz_sequence", "parameter_list": ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def collatz_sequence_length(x):\n \"\"\"\n Returns the length of the Collatz sequence starting with x.\n \"\"\"\n length = 1\n while x != 1:\n ...
trial_gpt4o_1
{ "original_instruction": "story\n\nAlice loves sequences and often plays with different sequence problems. One day, she encountered a challenging one and thought to take help from you. The sequence Alice is interested in is defined as follows:\n\n- Start with an integer x.\n- If x is even, divide it by 2.\n- If x is...
0.744494
Taco_93503
C
[ "collatz_length", "longest_collatz_sequence" ]
2
[ [ "longest_collatz_sequence", "collatz_length" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2ed945c5c167a7cbb9a186a23134ae7152020a7f
c331ae33257002a4b662a5e81039f913ae33fecf
v1.0
complete
Taco
Taco_93552_C
def format_rope_length(test_cases): """ Format the output of rope lengths to be correct up to 2 decimal places. Args: test_cases (list of tuples): A list where each element is a tuple (l, w) Returns: list of strings: The formatted length of the rope required for each parcel. ...
def calculate_rope_length(test_cases): """ Calculate the required length of rope for each test case. Args: test_cases (list of tuples): A list where each element is a tuple (l, w) Returns: list of floats: The length of the rope required for each parcel in the same order as inpu...
from solution import format_rope_length def test_format_rope_length_single_case(): assert format_rope_length([(10.00, 5.00)]) == ["30.00"] def test_format_rope_length_multiple_cases(): assert format_rope_length([(10.00, 5.00), (4.20, 3.10)]) == ["30.00", "14.60"] def test_format_rope_length_decimal_precision...
[ { "docstring": "Calculate the required length of rope for each test case.\n\nArgs:\n test_cases (list of tuples): A list where each element is a tuple (l, w)\n\nReturns:\n list of floats: The length of the rope required for each parcel in the same order as input.", "function_declaration": "def calcula...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_rope_length(l, w):\n \"\"\"\n Returns the minimum length of rope required to enclose a rectangular parcel.\n \"\"\"\n return round(2 * (l...
trial_gpt4o_1
{ "original_instruction": "Farmer John has a large field where he grows various crops in rectangular parcels. He wants to fence each parcel with a rope but since he aims to minimize waste, he wants to know the minimum length of rope required to completely enclose each parcel. Each parcel is defined by its length l an...
0.525025
Taco_93552
C
[ "calculate_rope_length", "format_rope_length" ]
2
[ [ "format_rope_length", "calculate_rope_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0bba7ce82bbadd045044273548126466bc713a91
727c80d4d9d3b01f3b352e5b5b9837e42180c9c9
v1.0
complete
Taco
Taco_93432_C
from typing import Tuple, Optional def is_prime(num: int) -> bool: """Returns True if num is a prime number, otherwise False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(10) False >>> is_prime(11) True >>> is_prime(1) False >>> i...
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return ...
def test_is_prime(): # Test some known primes and non-primes 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(11) == True assert is_prime(1) == False assert is_prime(0) == False ...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the closest prime numbers less than or equal to `n` and greater than or equal to `n`.", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n ret...
trial_gpt4o_2
{ "original_instruction": "Lily loves numbers and has recently developed a fascination with prime numbers and their occurrence within ranges. She has challenged you to help her find the closest prime numbers around a given number `n`.\n\nYou need to write a program to determine the nearest prime numbers less than or ...
0.71755
Taco_93432
C
[ "is_prime", "closest_primes", "find_closest_primes" ]
3
[ [ "closest_primes", "is_prime" ], [ "find_closest_primes", "closest_primes" ] ]
2
[]
false
[]
false
pytest
false
[]
true
2ddf58cec8c6a211e4088a8694a7b22965b17189
b9013ed48c29cf5c92fefe448104f19508f73555
v1.0
complete
Taco
Taco_93553_C
def is_prime(num: int) -> bool: """Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(29) True >>> is_prime(30) False """ def largest_prime_less_than(n: int): """Find the largest prime number less than n....
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def largest_prime_less_than(n)...
from solution import is_prime, largest_prime_less_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(30) == False def test_largest_prime_less_than(): assert large...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def largest_prime_less_than(n):", "function_name": "largest_prime_less_than", "parameter_list": "(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 is_prime(num):\n if num <= 1:\n return False \n if num <= 3:\n return True \n if num % 2 == 0 or num % 3 == 0:\n return Fal...
trial_gpt4o_1
{ "original_instruction": "Many people enjoy playing with number games and puzzles. One popular puzzle is finding the largest prime number less than a given number $n$. The definition of a prime number is a natural number greater than $1$ that has no positive divisors other than $1$ and itself.\n\nGiven an integer $n...
0.807401
Taco_93553
C
[ "is_prime", "largest_prime_less_than" ]
2
[ [ "largest_prime_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8d286a38a572497b22c14e60dbd0307051f5d7b
c307b93efbec822fed82ea2970ec09ea7507d069
v1.0
complete
Taco
Taco_93647_C
def can_form(word, s): """ Helper function to determine if a word can be formed by deleting some characters of string s without reordering the remaining characters. """ pass def longest_word(s, word_list): """ Given a list of words, finds and returns the longest word that can be formed ...
def can_form(word, s): """ Helper function to determine if a word can be formed by deleting some characters of string s without reordering the remaining characters. """ it = iter(s) return all(char in it for char in word) def longest_word(s, word_list): """ Returns the longest word tha...
from solution import longest_word def test_example1(): s = "abpcplea" word_list = ["ale", "apple", "monkey", "plea"] assert longest_word(s, word_list) == "apple" def test_example2(): s = "abpcplea" word_list = ["a", "b", "c"] assert longest_word(s, word_list) == "a" def test_no_word_can_be_fo...
[ { "docstring": "Helper function to determine if a word can be formed by deleting \nsome characters of string s without reordering the remaining characters.", "function_declaration": "def can_form(word, s):", "function_name": "can_form", "parameter_list": "(word, s)" }, { "docstring": "Return...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_word(s, word):\n \"\"\"\n Checks if a word can be formed from string s by deleting some characters.\n \"\"\"\n it = iter(s)\n return al...
trial_gpt4o_6
{ "original_instruction": "Given a list of words, create a function that finds and returns the longest word that can be formed by deleting some characters of the given string `s` without reordering the remaining characters.\n\ninput\n====\nTwo values:\n\n- `s` : The string from which we want to form words.\n- `word_l...
0.780258
Taco_93647
C
[ "can_form", "longest_word" ]
2
[ [ "longest_word", "can_form" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4e6c1eb1c2f36606d0f132c650b54597ce6e550
32c6149c2e0e52c0f232628a1cb91b60691c48d3
v1.0
complete
Taco
Taco_93788_C
def is_prime(n): """ Determines if n is a prime number. Returns True if n is prime, else False. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False """ def process_numbers(numbers): """ Takes a list of integers and determines if each is a prime. Prints "Prime" or...
def is_prime(n): """ Determines if n is a prime number. Returns True if n is prime, else False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False ...
from solution import is_prime, process_numbers import pytest from io import StringIO import sys def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(-1) == False assert...
[ { "docstring": "Determines if n is a prime number.\nReturns True if n is prime, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and determines if each is a prime.\nPrints \"Prime\" or \...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n...
trial_gpt4o_2
{ "original_instruction": "Write a program that reads a series of integers and determines whether each integer is prime or not. The program will read a list of integers terminated by the input value -1, which should not be processed. For each integer, print \"Prime\" if the number is a prime number, otherwise print \...
0.80485
Taco_93788
C
[ "is_prime", "process_numbers" ]
2
[ [ "process_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d8e2f6091da18c87c5d031ac041da539f7a910c6
9572c45d2bfe9758a64c96a0a1e19f2bac1d11f1
v1.0
complete
Taco
Taco_93718_C
def special_prime_sequences(T: int, test_cases: List[Tuple[int, int]]) -> List[str]: """ Determines the lexicographically smallest sequence of length N containing exactly M prime numbers for each test case. If no such sequence exists, returns "SEQUENCE IMPOSSIBLE". >>> special_prime_sequences(3, [...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
def test_special_prime_sequences(): test_cases = [(2, 1), (4, 2), (5, 6)] expected_outputs = ["2 1", "2 3 1 1", "SEQUENCE IMPOSSIBLE"] assert special_prime_sequences(3, test_cases) == expected_outputs test_cases = [(10, 0), (10, 1), (10, 10)] expected_outputs = ["1 1 1 1 1 1 1 1 1 1", "2 1 1 1 1 1 ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate all prime numbers up to a given number n.", "function_declaration": "def generate_primes_up_to(n):", "function_na...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "Problem Statement:\nAlice and Bob love prime numbers and they have decided to play a game with them. They will define a special kind of prime number sequence and need your help to find it.\n\nA sequence of length N is considered special if it contains exactly M prime numbers and these M pri...
0.594944
Taco_93718
C
[ "is_prime", "generate_primes_up_to", "lexicographically_smallest_sequence", "special_prime_sequences" ]
4
[ [ "generate_primes_up_to", "is_prime" ], [ "lexicographically_smallest_sequence", "generate_primes_up_to" ], [ "special_prime_sequences", "lexicographically_smallest_sequence" ] ]
3
[]
false
[]
false
pytest
false
[]
true
077f363a24f3e1ae71789e2f7095f0887f50fc9c
30e8d81d7b17e9099928eb672a6da66de077996e
v1.0
complete
Taco
Taco_93761_C
def game_solver(t: int, cases: List[Tuple[int, ...]]) -> List[int]: """ Determines the maximum possible sum that the first player can collect assuming both players play optimally. >>> game_solver(2, [(4, 1, 2, 9, 4), (3, 4, 4, 5)]) [10, 9] >>> game_solver(1, [(1, 7)]) [7] >>>...
def max_first_player_sum(test_cases): results = [] for array in test_cases: n = len(array) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = array[i] for length in range(2, n + 1): for i in range(n - length + 1): ...
from solution import game_solver def test_game_solver(): t = 2 cases = [(4, 1, 2, 9, 4), (3, 4, 4, 5)] assert game_solver(t, cases) == [10, 9] def test_single_element(): t = 1 cases = [(1, 7)] assert game_solver(t, cases) == [7] def test_two_elements(): t = 1 cases = [(2, 5, 3)] a...
[ { "docstring": null, "function_declaration": "def max_first_player_sum(test_cases):", "function_name": "max_first_player_sum", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def game_solver(t, cases):", "function_name": "game_solver", "parameter...
[ 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 max_first_player_sum(t, cases):\n def dp(arr):\n n = len(arr)\n dp = [[0] * n for _ in range(n)]\n \n for i in range(n):\n ...
trial_gpt4o_3
{ "original_instruction": "Two players are playing a game with an array of integers. They take turns alternately, picking either the first or last element of the array and removing it. Each player's goal is to maximize the sum of the integers they have picked. Write a function that determines the maximum possible sum...
0.690244
Taco_93761
C
[ "max_first_player_sum", "game_solver" ]
2
[ [ "game_solver", "max_first_player_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4373e0d7e0823582e451d997da5c4fcc0cf90554
c3c539e130be878173341ea315c88985bdbbb7b8
v1.0
complete
Taco
Taco_93555_C
def process_great_wall_of_china_data(input_str: str) -> str: """ The Great Wall of China is one of the most iconic symbols of China’s rich history. Various sections of the wall attract vast numbers of tourists throughout the year. In order to manage the influx of visitors more effectively, the authorities need a sy...
def average_visitors(data): result = [] for dataset in data: d, s = dataset[0] visitors = dataset[1:] averages = [] for section in range(s): total_visitors = sum(visitors[day][section] for day in range(d)) average = total_visitors / d averages...
from solution import process_great_wall_of_china_data def test_example_1(): input_str = """3 4 120 130 140 150 130 140 150 160 140 150 160 170 2 3 60 70 80 90 100 110 0 0""" expected_output = """130.00 140.00 150.00 160.00 75.00 85.00 95.00""" assert process_great_wall_of_china_data(input_str) == expected_...
[ { "docstring": null, "function_declaration": "def average_visitors(data):", "function_name": "average_visitors", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(input_str...
[ 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 average_visitors(dataset):\n \"\"\"\n Calculate the average number of visitors per section over a given period.\n Args:\n dataset (list of tuples):...
trial_gpt4o_1
{ "original_instruction": "The Great Wall of China is one of the most iconic symbols of China’s rich history. Various sections of the wall attract vast numbers of tourists throughout the year. In order to manage the influx of visitors more effectively, the authorities need a system that can perform quick analyses bas...
0.584809
Taco_93555
C
[ "average_visitors", "parse_input", "format_output", "process_great_wall_of_china_data" ]
4
[ [ "process_great_wall_of_china_data", "average_visitors" ], [ "process_great_wall_of_china_data", "format_output" ], [ "process_great_wall_of_china_data", "parse_input" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
85b2c980f4dbe4eaa37946c4368347fe9fb106cd
a7f8cb855df6ae5d096640ac77013c09408c8815
v1.0
complete
Taco
Taco_93841_C
def min_product_equalizable_substrings(t, strings): """ For each string in strings, determine the minimum number of Product-Equalizable substrings it can be divided into, or -1 if not possible. >>> min_product_equalizable_substrings(3, ["aabb", "cdeffedc", "abcdef"]) == [-1, 1, -1] >>> min_product_equa...
def get_prime_numbers(n): """ Generates a list of the first n prime numbers using the Sieve of Eratosthenes. """ primes = [] candidate = 2 while len(primes) < n: is_prime = all(candidate % prime != 0 for prime in primes) if is_prime: primes.append(candidate) c...
from solution import min_product_equalizable_substrings def test_example_cases(): assert min_product_equalizable_substrings(3, ["aabb", "cdeffedc", "abcdef"]) == [-1, 1, -1] def test_single_letter(): assert min_product_equalizable_substrings(1, ["z"]) == [-1] def test_two_identical_characters(): assert m...
[ { "docstring": "Generates a list of the first n prime numbers using the Sieve of Eratosthenes.", "function_declaration": "def get_prime_numbers(n):", "function_name": "get_prime_numbers", "parameter_list": "(n)" }, { "docstring": "Checks if a given string s can be divided into Product-Equali...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef generate_prime_mapping():\n \"\"\"\n Generate a mapping of characters to the first 26 prime numbers.\n \"\"\"\n def is_prime(n):\n ...
trial_gpt4o_5
{ "original_instruction": "Mary loves playing with strings and numbers. She has found a unique way to look at strings by associating numbers with each character. She assigns each lowercase letter of the alphabet a distinct prime number, starting from the smallest prime number, 2. For instance:\n\n'a' -> 2,\n'b' -> 3,...
0.662952
Taco_93841
C
[ "get_prime_numbers", "is_product_equalizable", "min_product_equalizable_substrings" ]
3
[ [ "min_product_equalizable_substrings", "get_prime_numbers" ], [ "min_product_equalizable_substrings", "is_product_equalizable" ] ]
2
[]
false
[]
false
pytest
true
[]
true
66e44b762bad96dfe92cc5bbfc950501fc30ec69
4727748d6d01350a8d5e05f53b5b290c1c686687
v1.0
complete
Taco
Taco_93317_C
def largest_square_with_coins(grid): """ Find the largest square subgrid that contains only coins. Parameters: grid (List[List[int]]): A grid of NxN cells with 1s representing coins and 0s representing empty cells. Returns: int: The size of the largest square subgrid that contains only...
def largest_square_with_coins(grid): N = len(grid) dp = [[0] * N for _ in range(N)] max_side = 0 for i in range(N): for j in range(N): if grid[i][j] == 1: if i == 0 or j == 0: dp[i][j] = 1 else: dp[i][j] = min(d...
import pytest from solution import solve_large_square_with_coins, parse_input def test_largest_square_with_coins(): input_data = "2\n4\n1 1 1 0\n1 1 0 0\n1 1 1 1\n0 1 1 1\n5\n1 0 1 1 1\n1 1 1 1 1\n0 1 1 1 1\n1 1 1 1 1\n0 1 1 0 1" test_cases = parse_input(input_data) results = solve_large_square_with_coins(...
[ { "docstring": null, "function_declaration": "def largest_square_with_coins(grid):", "function_name": "largest_square_with_coins", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve_large_square_with_coins(test_cases):", "function_name": "solve_larg...
[ 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 largest_square_subgrid(T, test_cases):\n def size_of_largest_square(grid, N):\n if N == 0:\n return 0\n \n # dp[i][j] will b...
trial_gpt4o_2
{ "original_instruction": "You are given a grid of NxN cells. Each cell can either contain a coin (represented by a 1) or be empty (represented by a 0). Your task is to find the largest square subgrid that contains only coins.\n\n-----Input-----\nThe first line contains an integer T denoting the number of test cases....
0.599817
Taco_93317
C
[ "largest_square_with_coins", "solve_large_square_with_coins", "parse_input" ]
3
[ [ "solve_large_square_with_coins", "largest_square_with_coins" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
e428f5dec4ec1c1eddd46378114265a2168df1d9
3b601aff4743c75cfc527d5238b450a7a03532b5
v1.0
complete
Taco
Taco_93496_C
from typing import List, Tuple def preprocess_positions(positions: List[int]) -> List[int]: """ Preprocess the positions to allow efficient range queries. >>> preprocess_positions([5, 2, 10, 7, 12]) [2, 5, 7, 10, 12] """ def count_treasures_in_range(positions: List[int], l: int, r: int) -> int...
from bisect import bisect_left, bisect_right def preprocess_positions(positions): """ Preprocess the positions to allow efficient range queries. """ return sorted(positions) def count_treasures_in_range(positions, l, r): """ Counts the number of treasure positions within the range [l, r]. ...
from solution import preprocess_positions, count_treasures_in_range, process_test_case, solve def test_preprocess_positions(): assert preprocess_positions([5, 2, 10, 7, 12]) == [2, 5, 7, 10, 12] def test_count_treasures_in_range(): positions = preprocess_positions([2, 5, 7, 10, 12]) assert count_treasures...
[ { "docstring": "Preprocess the positions to allow efficient range queries.", "function_declaration": "def preprocess_positions(positions):", "function_name": "preprocess_positions", "parameter_list": "(positions)" }, { "docstring": "Counts the number of treasure positions within the range [l...
[ 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 preprocess_treasure_positions(treasure_positions):\n \"\"\"\n Preprocess the list of treasure positions to enable efficient query answering.\n \"\"\"\...
trial_gpt4o_1
{ "original_instruction": "Professor Dumbledore has a new idea for encouraging teamwork among Hogwarts students. He has decided to organize a treasure hunt in the Forbidden Forest. Each team, consisting of n students, is required to find hidden treasures. The location of these treasures is described by a list of posi...
0.576328
Taco_93496
C
[ "preprocess_positions", "count_treasures_in_range", "process_test_case", "solve" ]
4
[ [ "process_test_case", "count_treasures_in_range" ], [ "process_test_case", "preprocess_positions" ], [ "solve", "process_test_case" ] ]
3
[ "process_test_case" ]
false
[]
false
pytest
true
[]
true
f5908231b604aefb1b6c1a4bc4be33a8eca5b585
56ca676fd8f62a6e272932371e9dec29978d2f1a
v1.0
complete
Taco
Taco_93821_C
def process_messages(test_cases): """ Process multiple test cases of encoding and decoding messages based on the Caesar Cipher technique. Args: - test_cases: A list of tuples where each tuple contains: - a character 'E' or 'D' indicating whether to encode or decode the message - a string, t...
def caesar_cipher_char(char, shift): """ Shift a character by the specified number of positions in the alphabet. Wraps around the alphabet if necessary. """ return chr(((ord(char) - ord('A') + shift) % 26) + ord('A')) def caesar_cipher(message, shift, encode=True): """ Encodes or decodes a ...
from solution import process_messages def test_encode_message(): assert process_messages([('E', 'HELLO', 3)]) == ['KHOOR'] def test_decode_message(): assert process_messages([('D', 'KHOOR', 3)]) == ['HELLO'] def test_encode_with_wrap_around(): assert process_messages([('E', 'XYZ', 3)]) == ['ABC'] def te...
[ { "docstring": "Shift a character by the specified number of positions in the alphabet.\nWraps around the alphabet if necessary.", "function_declaration": "def caesar_cipher_char(char, shift):", "function_name": "caesar_cipher_char", "parameter_list": "(char, shift)" }, { "docstring": "Encod...
[ 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 shift_character(c, k):\n \"\"\"\n Shifts a single character by k positions in the alphabet. Wraps around if necessary.\n \"\"\"\n return chr((ord(c...
trial_gpt4o_2
{ "original_instruction": "Alice is participating in a cryptography challenge where she needs to encode and decode messages using a special technique. The technique involves shifting characters in the alphabet by a fixed number of positions. This method is a variant of the Caesar Cipher.\n\nAlice needs your help to a...
0.646634
Taco_93821
C
[ "caesar_cipher_char", "caesar_cipher", "process_messages" ]
3
[ [ "caesar_cipher", "caesar_cipher_char" ], [ "process_messages", "caesar_cipher" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8e7087c928bd25cc188272bddd038e8dbbd55f5f
13aa1b07e9ed1e5b5048f0bbc3112597e28ca483
v1.0
complete
Taco
Taco_93769_C
def find_nearest_empty(parking_lot): """ This function finds the coordinates of the nearest empty parking space from the top-left corner. It returns a tuple (row, column) of the nearest empty space. """ pass def park_car(parking_lot): """ This function parks a car in the nearest available e...
def find_nearest_empty(parking_lot): """ This function finds the coordinates of the nearest empty parking space from the top-left corner. It returns a tuple (row, column) of the nearest empty space. """ for i in range(len(parking_lot)): for j in range(len(parking_lot[0])): if par...
def find_nearest_empty(parking_lot): for i in range(len(parking_lot)): for j in range(len(parking_lot[0])): if parking_lot[i][j] == 'E': return i, j return -1, -1 def park_car(parking_lot): i, j = find_nearest_empty(parking_lot) if i != -1 and j != -1: parkin...
[ { "docstring": "This function finds the coordinates of the nearest empty parking space from the top-left corner.\nIt returns a tuple (row, column) of the nearest empty space.", "function_declaration": "def find_nearest_empty(parking_lot):", "function_name": "find_nearest_empty", "parameter_list": "(...
[ 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 find_nearest_empty(parking_lot):\n \"\"\"\n This function finds the coordinates of the nearest empty parking space from the top-left corner.\n It retu...
trial_gpt4o_0
{ "original_instruction": "You are the manager of a parking lot with multiple rows of parking spaces. Each parking space can be either empty or occupied by a car. Cars are arriving at the parking lot one by one, and you want to park them in the most efficient way. Specifically, you want to ensure that the cars are pa...
0.503522
Taco_93769
C
[ "find_nearest_empty", "park_car", "process_parking_lot", "main" ]
4
[ [ "park_car", "find_nearest_empty" ], [ "process_parking_lot", "park_car" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3aba5b19b79921503b159c203fc3ced4dd3b3e7c
8316c07db2c6fe50df0e9e14938f8217aefd16e5
v1.0
complete
Taco
Taco_94070_C
def is_prime(n: int) -> bool: """ Returns True if n is a prime number, otherwise False. """ # Implement the logic to determine if a number n is prime. def prime_sum_result(Y: int, B: int) -> str: """ Checks if the sum of Y and B is a prime number. If it is, returns "Prime"; otherwise "Not P...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ 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 ...
from solution import is_prime, prime_sum_result 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 assert is_prime(25) == False assert is_prime(97) == T...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks if the sum of Y and B is a prime number.\nIf it is, returns \"Prime\"; otherwise \"Not Prime\".",...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns whether a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(...
trial_gpt4o_2
{ "original_instruction": "Given two integers, Y and B, which are within the range of 1 to 100 (inclusive), your task is to determine whether their sum is a prime number. If their sum is a prime number, print \"Prime\"; otherwise, print \"Not Prime\".\n\n-----Constraints-----\n - 1 \\leq Y, B \\leq 100\n - All input ...
0.774951
Taco_94070
C
[ "is_prime", "prime_sum_result" ]
2
[ [ "prime_sum_result", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
edc6a78d944b0c8c3116c6d620daa7a4aebfa369
a850c75e35e0e8a4359898c2b65752abc703ff39
v1.0
complete
Taco
Taco_94084_C
def first_n_happy_numbers(n: int) -> List[int]: """ Generate the list of the first n happy numbers. >>> first_n_happy_numbers(5) [1, 7, 10, 13, 19] >>> first_n_happy_numbers(8) [1, 7, 10, 13, 19, 23, 28, 31] >>> first_n_happy_numbers(1) [1] >>> first_n_happy_numbers(10) [1, 7, 10, 13...
def is_happy(number): seen = set() while number != 1 and number not in seen: seen.add(number) number = sum(int(digit) ** 2 for digit in str(number)) return number == 1 def first_n_happy_numbers(n): happy_numbers = [] num = 1 while len(happy_numbers) < n: if is_happy(num)...
from solution import first_n_happy_numbers def test_first_5_happy_numbers(): assert first_n_happy_numbers(5) == [1, 7, 10, 13, 19] def test_first_8_happy_numbers(): assert first_n_happy_numbers(8) == [1, 7, 10, 13, 19, 23, 28, 31] def test_first_happy_number(): assert first_n_happy_numbers(1) == [1] def...
[ { "docstring": null, "function_declaration": "def is_happy(number):", "function_name": "is_happy", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def first_n_happy_numbers(n):", "function_name": "first_n_happy_numbers", "parameter_list": "(n)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_happy(n):\n \"\"\"\n Returns True if the number n is a happy number, else False.\n \"\"\"\n seen = set()\n while n != 1 and n not in seen:\n ...
trial_gpt4o_2
{ "original_instruction": "Write a function to generate the list of the first n happy numbers.\n\nHappy numbers are defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1, where it will stay, or...
0.583487
Taco_94084
C
[ "is_happy", "first_n_happy_numbers" ]
2
[ [ "first_n_happy_numbers", "is_happy" ] ]
1
[]
false
[]
false
pytest
true
[]
true
784e6774eb194e311bcb215fd6cb0dc99ad7e919
b9fa7f535b666956e458bef7ff7ea4395f062de1