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_86817_C
def jane_array_operations(input_lines: str) -> str: """ Process a series of operations on arrays and provide the max and min values with their positions. Args: input_lines (str): A string containing multiple lines as described in the input format. Returns: str: A string with result...
def process_operations_and_find_extremes(T, cases): results = [] for i in range(T): N, array, Q, operations = cases[i] for op in operations: L, R, V = op for j in range(L-1, R): array[j] += V # Finding the max and min values with their sm...
from solution import jane_array_operations def test_example_case(): input_data = """2 5 1 2 3 4 5 2 1 3 2 2 5 -1 4 1 -1 0 2 3 1 2 3 2 4 -4 1 4 1""" expected_output = """3 4 1 3 1 5 3 -3""" assert jane_array_operations(input_data) == expected_output def test_single_operation(): input_data = """1 4 ...
[ { "docstring": null, "function_declaration": "def process_operations_and_find_extremes(T, cases):", "function_name": "process_operations_and_find_extremes", "parameter_list": "(T, cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_lines):", "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": "def perform_operations(T, test_cases):\n results = []\n for t in range(T):\n N = test_cases[t][\"N\"]\n arr = test_cases[t][\"arr\"]\n Q...
trial_gpt4o_4
{ "original_instruction": "Jane loves playing with arrays and has recently come across a fascinating problem. She wants to perform a series of operations on an array of integers where each operation either increments or decrements a subarray by a specific value. Additionally, after performing all the operations, Jane...
0.567669
Taco_86817
C
[ "process_operations_and_find_extremes", "parse_input", "jane_array_operations" ]
3
[ [ "jane_array_operations", "parse_input" ], [ "jane_array_operations", "process_operations_and_find_extremes" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
230827cb5bbbc06c6142661841e5e0d5d54cdfde
df2eebc7295136138087ba0a0e9817db9506d9dc
v1.0
complete
Taco
Taco_86685_C
def answer_queries(n: int, k: int, nums: List[int], m: int, queries: List[Tuple[int, int]]) -> List[int]: """ Process m queries on an integer array `nums` of length `n` to find the minimum length of any subarray within the range [l; r] that contains at least `k` distinct elements. If there is no suc...
def min_length_subarray_with_k_distinct(nums, k, queries): from collections import defaultdict def min_length_subarray(l, r, k): window_start = l min_length = float('inf') freq = defaultdict(int) distinct_count = 0 for window_end in range(l, r + 1): if f...
def test_basic_example(): nums = [1, 2, 1, 3, 4, 2, 3, 1] queries = [(1, 4), (2, 8), (3, 5)] result = answer_queries(8, 3, nums, 3, queries) assert result == [3, 3, 3] def test_no_possible_subarray(): nums = [1, 2, 1, 1, 1] queries = [(1, 5), (1, 4)] result = answer_queries(5, 3, nums, 2, q...
[ { "docstring": null, "function_declaration": "def min_length_subarray_with_k_distinct(nums, k, queries):", "function_name": "min_length_subarray_with_k_distinct", "parameter_list": "(nums, k, queries)" }, { "docstring": null, "function_declaration": "def answer_queries(n, k, nums, m, que...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_length_subarray_with_k_distinct(a, n, k, queries):\n results = []\n\n def min_length_for_query(l, r):\n min_length = float('inf')\n fre...
trial_gpt4o_1
{ "original_instruction": "You are given an integer array `a` of length `n` and an integer `k`. Your task is to process `m` queries on it. Each query consists of two integers `l` and `r`, you need to find the minimum length of any subarray within the range `[l; r]` that contains at least `k` distinct elements. If the...
0.690472
Taco_86685
C
[ "min_length_subarray_with_k_distinct", "answer_queries" ]
2
[ [ "answer_queries", "min_length_subarray_with_k_distinct" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9b9202d324992f7bb49c72d059ec22477ce3f7c4
c4670841cb4f81a9169794829a5bceed637891c4
v1.0
complete
Taco
Taco_86728_C
def largest_fertile_subrectangle(N: int, M: int, grid: List[List[int]]) -> int: """ Find the area of the largest contiguous subrectangle of fertile cells in the garden. >>> largest_fertile_subrectangle(4, 5, [[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]]) 6 >>> largest_fertile_subr...
def maximalRectangle(matrix): if not matrix: return 0 def largestRectangleArea(heights): stack = [] max_area = 0 heights.append(0) for i in range(len(heights)): while stack and heights[i] < heights[stack[-1]]: h = heights[stack.po...
def test_largest_fertile_subrectangle(): grid1 = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert largest_fertile_subrectangle(4, 5, grid1) == 6 grid2 = [ [1, 1, 1], [1, 1, 1], [1, 1, 1] ] assert largest_fertil...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largest_fertile_subrectangle(N, M, grid):", "function_name": "largest_fertile_subrectan...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def maximalRectangle(matrix):\n if not matrix:\n return 0\n\n max_area = 0\n dp = [0] * len(matrix[0])\n\n for i in range(len(matrix)):\n ...
trial_gpt4o_2
{ "original_instruction": "In a quiet town called Codeville, the local botanist, Alex, is working on growing a special kind of flower that only blooms under specific conditions. Alex has a rectangular grid garden with specific cells classified as 'fertile' or 'barren'. The garden is represented as a 2D grid of size N...
0.578554
Taco_86728
C
[ "maximalRectangle", "largest_fertile_subrectangle" ]
2
[ [ "largest_fertile_subrectangle", "maximalRectangle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
70296bd1674916e8dd41a11352a6933ff232a953
f293bad7cfdd0312ba3928ac67c64b0beb79d816
v1.0
complete
Taco
Taco_86745_C
def is_narcissistic_number(N: int) -> bool: """ Determine if a given number is a Narcissistic number. >>> is_narcissistic_number(153) True >>> is_narcissistic_number(9474) True >>> is_narcissistic_number(123) False """ pass def check_narcissistic_numbers(T: int, numbers: List[int]) ...
def is_narcissistic_number(N): digits = [int(d) for d in str(N)] power = len(digits) return sum(d**power for d in digits) == N def check_narcissistic_numbers(T, numbers): results = [] for number in numbers: if is_narcissistic_number(number): results.append("Yes") else: ...
from solution import is_narcissistic_number, check_narcissistic_numbers def test_is_narcissistic_number(): assert is_narcissistic_number(153) == True assert is_narcissistic_number(9474) == True assert is_narcissistic_number(123) == False assert is_narcissistic_number(370) == True assert is_narcissi...
[ { "docstring": null, "function_declaration": "def is_narcissistic_number(N):", "function_name": "is_narcissistic_number", "parameter_list": "(N)" }, { "docstring": null, "function_declaration": "def check_narcissistic_numbers(T, numbers):", "function_name": "check_narcissistic_number...
[ 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_narcissistic_number(N):\n \"\"\"\n Determine if a number is a narcissistic number.\n \"\"\"\n digits = [int(d) for d in str(N)]\n power = len...
trial_gpt4o_2
{ "original_instruction": "Write a program to determine if a given number is a \"Narcissistic number\" or not. A number is considered narcissistic if the sum of its own digits each raised to the power of the number of digits is equal to the number itself.\n\nFor instance, 153 is a narcissistic number because \\(1^3 +...
0.585154
Taco_86745
C
[ "is_narcissistic_number", "check_narcissistic_numbers" ]
2
[ [ "check_narcissistic_numbers", "is_narcissistic_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a74f035f8f740b10443c8166bb274e2a6201d3f
b1337c0e0de7fb78d4187a45a24af0bf22b52864
v1.0
complete
Taco
Taco_86994_C
from typing import List def prime_matrix_sum(matrix: List[List[int]]) -> int: """ Returns the sum of all prime numbers in a given matrix. >>> prime_matrix_sum([ ... [2, 3, 4], ... [5, 6, 7], ... [8, 9, 10] ... ]) == 17 >>> prime_matrix_sum([[4, 6, 8], [9, 10, 12], [14, 15, 16]])...
from typing import List def is_prime(n: int) -> bool: """Helper function to check if a number is prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False re...
from solution import prime_matrix_sum def test_prime_matrix_sum_basic(): matrix = [ [2, 3, 4], [5, 6, 7], [8, 9, 10] ] assert prime_matrix_sum(matrix) == 17 def test_prime_matrix_sum_empty(): matrix = [ [] ] assert prime_matrix_sum(matrix) == 0 def test_prime_m...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers in a given matrix.", "function_declaration": "def prime_matrix_sum(mat...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(num: int) -> bool:\n if num <= 1:\n return False\n if num == 2: # 2 is a prime number\n return True\n ...
trial_gpt4o_2
{ "original_instruction": "Prime Number Sum in a Matrix\n---------------------------\n\nIn this task, you will write a function that finds and sums all the prime numbers in a given m x n matrix. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\n### Function Si...
0.61156
Taco_86994
C
[ "is_prime", "prime_matrix_sum" ]
2
[ [ "prime_matrix_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cab3bdac06b7f7c49ead8c5920e51d14ae879969
718d2b4be44c75b03285678be9a1c74cd047b996
v1.0
complete
Taco
Taco_86629_C
def is_balanced(number): """ Check if the given number is balanced. A number is balanced if the sum of its digits in the odd positions is equal to the sum of its digits in the even positions. Parameters: number (int): The number to check for balanced property. Returns: bool: Tr...
def is_balanced(number): """ Check if the given number is balanced. A number is balanced if the sum of its digits in the odd positions is equal to the sum of its digits in the even positions. """ num_str = str(number) odd_sum = sum(int(num_str[i]) for i in range(0, len(num_str), 2)) even...
from solution import is_balanced, count_balanced_numbers def test_is_balanced(): assert is_balanced(1234) == False assert is_balanced(4321) == False assert is_balanced(1111) == True assert is_balanced(2222) == True assert is_balanced(123456) == False assert is_balanced(654321) == False asse...
[ { "docstring": "Check if the given number is balanced.\nA number is balanced if the sum of its digits in the odd positions is equal\nto the sum of its digits in the even positions.", "function_declaration": "def is_balanced(number):", "function_name": "is_balanced", "parameter_list": "(number)" },...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_balanced_number(number):\n number_str = str(number)\n odd_sum = sum(int(number_str[i]) for i in range(0, len(number_str), 2))\n even_sum = sum(int(...
trial_gpt4o_3
{ "original_instruction": "Leonardo loves both mathematics and programming. To combine his interests, he often invents problems that involve interesting numerical properties. Recently, he came up with a problem that involves balanced numbers.\n\nA number is called balanced if the sum of its digits in the odd position...
0.75099
Taco_86629
C
[ "is_balanced", "count_balanced_numbers" ]
2
[ [ "count_balanced_numbers", "is_balanced" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fe5b561dfae8cdca487dd4eb7578cab14367e387
f52e3314e9322053c73ef5ef82ebdd36cd112c05
v1.0
complete
Taco
Taco_86837_C
import heapq from typing import List, Tuple def dijkstra(n: int, graph: List[List[Tuple[int, int]]], start: int) -> List[int]: dist = [float('inf')] * n dist[start] = 0 pq = [(0, start)] while pq: current_dist, u = heapq.heappop(pq) if current_dist > dist[u]: c...
import heapq # Using modified Dijkstra's algorithm to find the shortest paths def dijkstra(n, graph, start): dist = [float('inf')] * n dist[start] = 0 pq = [(0, start)] while pq: current_dist, u = heapq.heappop(pq) if current_dist > dist[u]: continue ...
def test_parse_input(): input_str = "2\n4 4\n1 2 4\n2 3 5\n3 4 6\n4 1 7\n3 3\n1 2 3\n2 3 1\n3 1 2\n" expected_output = [ (4, 4, [(1, 2, 4), (2, 3, 5), (3, 4, 6), (4, 1, 7)]), (3, 3, [(1, 2, 3), (2, 3, 1), (3, 1, 2)]) ] assert parse_input(input_str) == expected_output def test_min_max_tr...
[ { "docstring": null, "function_declaration": "def dijkstra(n, graph, start):", "function_name": "dijkstra", "parameter_list": "(n, graph, start)" }, { "docstring": null, "function_declaration": "def min_max_travel_time(test_cases):", "function_name": "min_max_travel_time", "param...
[ 0, 0, 1, 0 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, graph, start):\n distances = [float('inf')] * (n + 1)\n distances[start] = 0\n pq = [(0, start)] # (distance, node)\n ...
trial_gpt4o_3
{ "original_instruction": "In a city, there are N intersections connected by M bidirectional roads. Each road has a specific travel time associated with it. The mayor wants to construct a new subway system comprising only one direct route, which can replace any one of the existing roads. The goal is to minimize the m...
0.710185
Taco_86837
C
[ "dijkstra", "min_max_travel_time", "parse_input", "solve" ]
4
[ [ "min_max_travel_time", "dijkstra" ], [ "solve", "min_max_travel_time" ], [ "solve", "parse_input" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
fef56836b54eb1e8a8c52981f0af84147e08efbe
fb5a6794674f29ed067c5b267362058fc0e4e905
v1.0
complete
Taco
Taco_86798_C
def maximalRectangle(matrix): """ Find the largest rectangle containing only 1s in a grid. :param matrix: List of list of integers representing the grid :return: Integer representing the area of the largest rectangle containing only 1s >>> maximalRectangle([[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1,...
def maximalRectangle(matrix): """ Find the largest rectangle containing only 1s in a grid. :param matrix: List of list of integers representing the grid :return: Integer representing the area of the largest rectangle containing only 1s """ if not matrix: return 0 # Preparation step:...
def test_maximalRectangle(): grid1 = [[1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0]] assert maximalRectangle(grid1) == 6 grid2 = [[0, 1], [1, 1]] assert maximalRectangle(grid2) == 2 grid3 = [[0, 0], [0, 0]] a...
[ { "docstring": "Find the largest rectangle containing only 1s in a grid.\n:param matrix: List of list of integers representing the grid\n:return: Integer representing the area of the largest rectangle containing only 1s", "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximal...
[ 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 maximalRectangle(matrix):\n \"\"\"\n Find the largest rectangle containing only 1s in a grid.\n :param matrix: List of list of integers representing t...
trial_gpt4o_0
{ "original_instruction": "You are given a rectangular grid of size N x M. Each cell in the grid contains either a 0 or a 1. You need to find the size of the largest rectangle containing only 1s.\n\nWrite a function that takes in the grid as a list of lists of integers and returns the area of the largest rectangle co...
0.705438
Taco_86798
C
[ "maximalRectangle", "max_histogram_area" ]
2
[ [ "maximalRectangle", "max_histogram_area" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8054d19e99f284df6e834fb5ddfb98c16e5b0c1e
8a571faaef83a6c01d4ed0da6db083b9fd2cc672
v1.0
complete
Taco
Taco_87100_C
def is_self_dividing(num: int) -> bool: """ Check if a number is self-dividing. :param num: int - input number to be checked :return: bool - True if the number is self-dividing, False otherwise """ pass def self_dividing_numbers(lower: int, upper: int) -> list[int]: """ Returns a l...
def is_self_dividing(num): """ Check if a number is self-dividing. :param num: int - input number to be checked :return: bool - True if the number is self-dividing, False otherwise """ original_num = num while num > 0: digit = num % 10 # If the digit is 0 or the digit do...
from solution import is_self_dividing, self_dividing_numbers def test_is_self_dividing(): assert is_self_dividing(128) == True assert is_self_dividing(12) == True assert is_self_dividing(102) == False assert is_self_dividing(101) == False assert is_self_dividing(1) == True def test_self_dividing_n...
[ { "docstring": "Check if a number is self-dividing.\n\n:param num: int - input number to be checked\n:return: bool - True if the number is self-dividing, False otherwise", "function_declaration": "def is_self_dividing(num):", "function_name": "is_self_dividing", "parameter_list": "(num)" }, { ...
[ 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_self_dividing(number):\n \"\"\"\n Check if a number is a self-dividing number.\n \"\"\"\n original = number\n while number > 0:\n digi...
trial_gpt4o_1
{ "original_instruction": "Write a function to identify whether a number is a \"self-dividing number.\" 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, 128 % 2 == 0, and 128 % 8 == 0. \n\nInput: A lower and upper integer...
0.62449
Taco_87100
C
[ "is_self_dividing", "self_dividing_numbers" ]
2
[ [ "self_dividing_numbers", "is_self_dividing" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0edb509686c200fb859ef3c8a35f0c988a29d02c
d94eed58fbc855e9b499417a273a76454dde9d0c
v1.0
complete
Taco
Taco_87049_C
def library_sort(input_list): """ Sort books based on titles and serial numbers. Args: input_list (List[str]): A list of strings containing the number of books followed by each book's serial number and title. Returns: List[str]: A list of strings with the sorted boo...
def sort_books(datasets): sorted_books = [] for books in datasets: books.sort(key=lambda x: (x[1], x[0])) sorted_books.extend(books) return sorted_books def parse_input(input_list): datasets = [] current_dataset = [] for line in input_list: if line == '0': if...
from solution import library_sort def test_library_sort_case_1(): input_list = [ '3', '123 Hamlet', '456 RomeoAndJuliet', '789 Hamlet', '0' ] expected_output = [ '123 Hamlet', '789 Hamlet', '456 RomeoAndJuliet' ] assert library_sort(in...
[ { "docstring": null, "function_declaration": "def sort_books(datasets):", "function_name": "sort_books", "parameter_list": "(datasets)" }, { "docstring": null, "function_declaration": "def parse_input(input_list):", "function_name": "parse_input", "parameter_list": "(input_list)"...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sort_books(datasets):\n sorted_books = []\n for books in datasets:\n books.sort(key=lambda x: (x[1], x[0]))\n sorted_books.extend(books)\n ...
trial_gpt4o_0
{ "original_instruction": "You are hired to design a sorting algorithm for the local library. Given a number of books, each book is identified by its serial number and has a unique title. The library wants to sort books based on their titles. However, if two titles are the same, then they should be sorted by their se...
0.64284
Taco_87049
C
[ "sort_books", "parse_input", "format_output", "library_sort" ]
4
[ [ "library_sort", "format_output" ], [ "library_sort", "parse_input" ], [ "library_sort", "sort_books" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
6f1d42fff1e5113ec08e42be10e61cfc50040b89
8c9f8eb3ca9ef4b615e83d606cf5b1b001e07d78
v1.0
complete
Taco
Taco_87166_C
def count_palindromic_substrings(s: str) -> int: """Counts the number of palindromic substrings in a given string. Parameters: s (str): The input string consisting of lowercase alphabetic characters. Returns: int: The number of palindromic substrings within the string. >>> count_p...
def count_palindromic_substrings(s): """ Counts and returns the number of palindromic substrings in a given string. """ n = len(s) count = 0 for i in range(n): # Count odd length palindromes with center at i count += count_palindromes_around_center(s, i, i) # Count even l...
from solution import count_palindromic_substrings def test_single_character(): assert count_palindromic_substrings("a") == 1 assert count_palindromic_substrings("z") == 1 def test_two_characters(): assert count_palindromic_substrings("aa") == 3 assert count_palindromic_substrings("ab") == 2 def test_...
[ { "docstring": "Counts and returns the number of palindromic substrings in a given string.", "function_declaration": "def count_palindromic_substrings(s):", "function_name": "count_palindromic_substrings", "parameter_list": "(s)" }, { "docstring": "Expand around center to count palindromes."...
[ 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 count_palindromic_substrings(s):\n \"\"\"\n Counts and returns the number of palindromic substrings in a given string.\n \"\"\"\n n = len(s)\n c...
trial_gpt4o_0
{ "original_instruction": "Marcela is interested in counting the number of palindromic substrings within a given string. A palindromic string is a string that reads the same forwards and backwards. She defines a substring to be a contiguous sequence of characters within a string. For example, in the string \"racecar\...
0.7069
Taco_87166
C
[ "count_palindromic_substrings", "count_palindromes_around_center" ]
2
[ [ "count_palindromic_substrings", "count_palindromes_around_center" ] ]
1
[]
false
[]
false
pytest
true
[]
true
51346a3d6c6118c694bbb61efccb0a796c998351
dd67c94cf808d39d19f9426098dd98fc852f69a8
v1.0
complete
Taco
Taco_87106_C
from itertools import permutations def is_prime(num): """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(0) False >>> is_prime(1) False """ pass def can_form_prime(S): ...
from itertools import permutations 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 can_form_prime(S): for perm ...
import pytest from solution import is_prime, can_form_prime, process_test_cases def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(0) == False assert is_prime(1) == False def test_can_form_prime(): ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def can_form_prime(S):", "function_name": "can_form_prime", "parameter_list": "(S)" }, { "docstring":...
[ 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 itertools\n\ndef is_prime(n):\n \"\"\" Check if a number is prime. \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_2
{ "original_instruction": "Zara loves solving coding problems and puzzles. She has come across an interesting problem related to prime numbers and string permutations. Can you help Zara solve it? \n\n- The problem states that for a given string $S$, she needs to determine if it is possible to rearrange the characters...
0.697576
Taco_87106
C
[ "is_prime", "can_form_prime", "process_test_cases" ]
3
[ [ "can_form_prime", "is_prime" ], [ "process_test_cases", "can_form_prime" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
01a85b379efb84c22e2509dce40bd37521cc1580
8999342b92c10df58a2fa72a924bb37bf076bce3
v1.0
complete
Taco
Taco_86675_C
def fibonacci(n): """ Generates the first n Fibonacci numbers. """ if n == 1: return [0] fib_sequence = [0, 1] for i in range(2, n): fib_sequence.append(fib_sequence[-1] + fib_sequence[-2]) return fib_sequence def fibonacci_spiral_area(n): """ Computes the total area...
def fibonacci(n): """ Generates the first n Fibonacci numbers. """ if n == 1: return [0] fib_sequence = [0, 1] for i in range(2, n): fib_sequence.append(fib_sequence[-1] + fib_sequence[-2]) return fib_sequence def fibonacci_spiral_area(n): """ Computes the total area...
import pytest from solution import fibonacci, fibonacci_spiral_area, compute_areas def test_fibonacci(): assert fibonacci(1) == [0] assert fibonacci(2) == [0, 1] assert fibonacci(3) == [0, 1, 1] assert fibonacci(5) == [0, 1, 1, 2, 3] def test_fibonacci_spiral_area(): assert fibonacci_spiral_area(1...
[ { "docstring": "Generates the first n Fibonacci numbers.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Computes the total area covered by the first n Fibonacci numbers' tiles.", "function_declaration": "def fibonac...
[ 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 fibonacci(n):\n \"\"\"\n Generates the first n Fibonacci numbers.\n \"\"\"\n if n == 1:\n return [0]\n fib_sequence = [0, 1]\n for i i...
trial_gpt4o_0
{ "original_instruction": "**Fibonacci Spiral**\n\nYou are planning to create a wall art installation that uses the Fibonacci sequence to determine the size and arrangement of tiles. Each tile in the installation will be square, and the side length of each tile will correspond to a number in the Fibonacci sequence. \...
0.659418
Taco_86675
C
[ "fibonacci", "fibonacci_spiral_area", "compute_areas" ]
3
[ [ "compute_areas", "fibonacci_spiral_area" ], [ "fibonacci_spiral_area", "fibonacci" ] ]
2
[]
false
[]
false
pytest
true
[]
true
54abac91aa6287d335a7f4931b5f67b769abde8c
072f4c8a58c4867c6dc001efffd7ee0ef12714d7
v1.0
complete
Taco
Taco_87351_C
def prime_matrix(m: int) -> str: """ Alex is fascinated by prime numbers. For his latest project, he wants to generate a matrix of positive integers where the sum of elements in each row, column, and both main diagonals are all prime numbers. Given an integer m, help Alex determine if it is possible to create such ...
import sympy def is_prime(n): """ Returns True if the given number n is prime, else False. """ return sympy.isprime(n) def find_prime_greater_than(n): """ Returns the smallest prime number greater than n. """ prime = n + 1 while not is_prime(prime): prime += 1 return pr...
from solution import prime_matrix def test_prime_small_size_3(): result = prime_matrix(3).split("\n") assert result[0] == "YES" assert all(len(row.split()) == 3 for row in result[1:]) def test_prime_size_2(): assert prime_matrix(2) == "NO" def test_prime_size_5(): result = prime_matrix(5)...
[ { "docstring": "Returns True if the given number n is prime, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number greater than n.", "function_declaration": "def find_prime_great...
[ 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 \"\"\"Check if a number is a prime number.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == ...
trial_gpt4o_4
{ "original_instruction": "Alex is fascinated by prime numbers. For his latest project, he wants to generate a matrix of positive integers where the sum of elements in each row, column, and both main diagonals are all prime numbers. Given an integer $m$, help Alex determine if it is possible to create such an $m \\ti...
0.608068
Taco_87351
C
[ "is_prime", "find_prime_greater_than", "create_matrix", "prime_matrix" ]
4
[ [ "create_matrix", "find_prime_greater_than" ], [ "find_prime_greater_than", "is_prime" ], [ "prime_matrix", "create_matrix" ] ]
3
[]
false
[]
false
pytest
true
[ "sympy" ]
false
c6425da41dda8e104015e30e390ab71184497bf1
04281fc15a77ee58137da30650ca5ffd62c56c71
v1.0
complete
Taco
Taco_87084_C
def count_file_extensions(file_list: List[str]) -> dict: """ Count the number of files for each extension (case-insensitive). Args: file_list (list of str): List of filenames with extensions. Returns: dict: Dictionary with extensions as keys and their counts as values. Example: >>...
def count_file_extensions(file_list): """ Count the number of files for each extension (case-insensitive). Args: file_list (list of str): List of filenames with extensions. Returns: dict: Dictionary with extensions as keys and their counts as values. """ extension_count = {} for fi...
def test_count_file_extensions(): file_list = [ "report.docx", "data.csv", "SCRIPT.JS", "image.PNG", "photo.jpg" ] assert count_file_extensions(file_list) == { "docx": 1, "csv": 1, "js": 1, "png": 1, "jpg": 1 } file_lis...
[ { "docstring": "Count the number of files for each extension (case-insensitive).\n\nArgs:\nfile_list (list of str): List of filenames with extensions.\n\nReturns:\ndict: Dictionary with extensions as keys and their counts as values.", "function_declaration": "def count_file_extensions(file_list):", "fun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def categorize_files_by_extension(n, files):\n \"\"\"\n Categorize files by their extensions and count the number of files\n for each extension in a case-...
trial_gpt4o_2
{ "original_instruction": "A software company is developing an advanced file management system. One of the features they want to implement involves organizing files based on their extensions. Each file in their system is represented by a string in the format \"filename.extension\". The system needs to categorize the ...
0.814513
Taco_87084
C
[ "count_file_extensions", "organize_files_by_extension" ]
2
[ [ "organize_files_by_extension", "count_file_extensions" ] ]
1
[]
false
[]
false
pytest
false
[]
true
74d8217b965ab57790024f194a9c091949458cac
ac2043a674a88a05319b8ff819144ed6eca53030
v1.0
complete
Taco
Taco_87246_C
from typing import List, Tuple def important_nodes(n: int, m: int, edges: List[Tuple[int, int]]) -> List[int]: """ Find the important nodes in an undirected graph. An important node is defined as a node that, if removed along with its incident edges, would increase the number of connected components...
from collections import defaultdict def find_important_nodes(n, m, edges): def dfs(v, parent): nonlocal time visited[v] = True discovery[v] = low[v] = time time += 1 children = 0 for to in graph[v]: if to == parent: continue i...
def test_important_nodes(): assert important_nodes(7, 6, [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7)]) == [2, 3, 4, 5, 6] assert important_nodes(2, 1, [(1, 2)]) == [-1] assert important_nodes(4, 4, [(1, 2), (2, 3), (3, 4), (4, 1)]) == [-1] assert important_nodes(5, 4, [(1, 2), (2, 3), (3, 4), (4, 5)...
[ { "docstring": null, "function_declaration": "def find_important_nodes(n, m, edges):", "function_name": "find_important_nodes", "parameter_list": "(n, m, edges)" }, { "docstring": null, "function_declaration": "def important_nodes(n, m, edges):", "function_name": "important_nodes", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_important_nodes(n, m, edges):\n from collections import defaultdict, deque\n \n def build_graph():\n for u, v in edges:\n graph...
trial_gpt4o_2
{ "original_instruction": "Peter is preparing for a hiking trip in the land of Graphonia, which is a country represented by an undirected graph with `n` nodes and `m` edges. Each node in Graphonia is identified by an integer from 1 to n. Peter wants to discover all the important nodes in Graphonia. An important node ...
0.584047
Taco_87246
C
[ "find_important_nodes", "important_nodes" ]
2
[ [ "important_nodes", "find_important_nodes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9325e1a5796e5692f908862ba3c63dc0f965db7b
29c8556abb64c5b24f7a4670edea7cd5e39fb78d
v1.0
complete
Taco
Taco_87364_C
def get_prefix_sums(arr): """ This function returns the prefix sums of the input array. """ pass def query_sums(prefix_sums, l, r): """ This function returns the sum of the subarray from index l to r (inclusive) using the prefix sums array. """ pass def find_subarray_sums(arr, quer...
def get_prefix_sums(arr): """ This function returns the prefix sums of the input array. """ prefix_sums = [0] * (len(arr) + 1) for i in range(1, len(prefix_sums)): prefix_sums[i] = prefix_sums[i - 1] + arr[i - 1] return prefix_sums def query_sums(prefix_sums, l, r): """ This fun...
def test_get_prefix_sums(): arr = [1, 2, 3, 4, 5] expected = [0, 1, 3, 6, 10, 15] assert get_prefix_sums(arr) == expected def test_query_sums(): prefix_sums = [0, 1, 3, 6, 10, 15] assert query_sums(prefix_sums, 1, 3) == 6 assert query_sums(prefix_sums, 2, 4) == 9 assert query_sums(prefix_su...
[ { "docstring": "This function returns the prefix sums of the input array.", "function_declaration": "def get_prefix_sums(arr):", "function_name": "get_prefix_sums", "parameter_list": "(arr)" }, { "docstring": "This function returns the sum of the subarray from index l to r (inclusive)\nusing...
[ 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 preprocess_sum_array(A):\n \"\"\"Preprocess the array to create a prefix sum array.\"\"\"\n prefix_sum = [0] * (len(A) + 1)\n for i in range(1, len(A)...
trial_gpt4o_2
{ "original_instruction": "In the mystical realm of Atlantis, there exists an ancient legend about a hidden treasure buried deep within the city. To find this treasure, one must solve a challenging problem involving arrays and ranges. The High Council of Atlantis has tasked you with solving this problem.\n\nGiven an ...
0.577935
Taco_87364
C
[ "get_prefix_sums", "query_sums", "find_subarray_sums" ]
3
[ [ "find_subarray_sums", "get_prefix_sums" ], [ "find_subarray_sums", "query_sums" ] ]
2
[]
false
[]
false
pytest
false
[]
true
5d550572db2279720fcf90e0867b8ed1063dac5a
5620645d22fd57483ba9c4f52081853252d97e9b
v1.0
complete
Taco
Taco_87530_C
def possible_to_organize(pairs): """ Determine if it is possible to organize a set of pairs such that all members can "see" each other. >>> possible_to_organize([(1, 4), (2, 3)]) "POSSIBLE" >>> possible_to_organize([(1, 2), (2, 3), (3, 1)]) "IMPOSSIBLE" >>> possible_to_organize([(1, 2)]) "POSSIBLE" ...
def is_bipartite(n, edges): from collections import deque, defaultdict graph = defaultdict(list) for u, v in edges: graph[u].append(v) graph[v].append(u) color = [-1] * (n + 1) def bfs(start): queue = deque([start]) color[start] = 0 while q...
from solution import possible_to_organize def test_possible_to_organize_possible_case(): pairs = [(1, 4), (2, 3)] assert possible_to_organize(pairs) == "POSSIBLE" def test_possible_to_organize_impossible_case(): pairs = [(1, 2), (2, 3), (3, 1)] assert possible_to_organize(pairs) == "IMPOSSIBLE" def t...
[ { "docstring": null, "function_declaration": "def is_bipartite(n, edges):", "function_name": "is_bipartite", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def possible_to_organize(pairs):", "function_name": "possible_to_organize", "parameter_list...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_possible(n, pairs):\n from collections import defaultdict, deque\n \n # Create adjacency list from input pairs\n graph = defaultdict(list)\n ...
trial_gpt4o_4
{ "original_instruction": "The question is to determine if it is possible to organize a set of pairs such that all members can \"see\" each other. Here is the new question:\n\nInput\n\n4 2 1 4 3 2\n1 4\n2 3\n\nOutput\n\nPOSSIBLE", "prompt_id": "00087530", "row_id": 87530, "seed_ids": "[4634]" }
0.505696
Taco_87530
C
[ "is_bipartite", "possible_to_organize" ]
2
[ [ "possible_to_organize", "is_bipartite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2df2cb82c1ec685bd91bd92289cae4708720ac90
20bd0e3cf9378c5c0fa022c79558e5f2c933a0e3
v1.0
complete
Taco
Taco_87561_C
def largest_palindrome(n): """Find the largest palindrome made from the product of two numbers, each with `n` digits. If no such palindrome exists, return -1. - If `n` is less than 1, return -1. >>> largest_palindrome(2) 9009 >>> largest_palindrome(3) 906609 >>> largest_palindrome(1) 9 >>> l...
def is_palindrome(number): return str(number) == str(number)[::-1] def largest_palindrome(n): if n < 1: return -1 max_factor = 10**n - 1 min_factor = 10**(n - 1) largest_palindrome = -1 for i in range(max_factor, min_factor - 1, -1): for j in range(i, min_factor - 1, -1): ...
from solution import largest_palindrome def test_largest_palindrome_2_digits(): assert largest_palindrome(2) == 9009 def test_largest_palindrome_3_digits(): assert largest_palindrome(3) == 906609 def test_largest_palindrome_1_digit(): assert largest_palindrome(1) == 9 def test_largest_palindrome_negativ...
[ { "docstring": null, "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def largest_palindrome(n):", "function_name": "largest_palindrome", "parameter_list": "(n)" ...
[ 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 largest_palindrome(n):\n if n < 1:\n return -1\n\n max_num = 10**n - 1\n min_num = 10**(n-1)\n max_palindrome = -1\n\n for i in range(max...
trial_gpt4o_5
{ "original_instruction": "A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 (91 × 99). Write a function that takes an integer `n` and finds the largest palindrome made from the product of two numbers, each with `n` digits. If no such palindrome...
0.744808
Taco_87561
C
[ "is_palindrome", "largest_palindrome" ]
2
[ [ "largest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
af9ae576d55bf5580aeae834c8a859b532f9c12b
6377216deb5b2de55274a4049ac0894a7dd3c28f
v1.0
complete
Taco
Taco_87448_C
def dungeon_explorer(input_data: str) -> List[str]: """ Determine if the player can reach the exit after updating the magic walls. Parameters: input_data (str): A formatted string containing the dungeon grid and queries. Returns: List[str]: List of "YES" or "NO" for each query. Example: >...
import sys from collections import deque def can_reach_exit(dungeon, N): """ Check if the player can reach the exit in the dungeon starting from (0, 0). """ directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] start = (0, 0) exit_pos = (N - 1, N - 1) if dungeon[start[0]][start[1]] == '#' or...
from solution import dungeon_explorer def test_example_case_1(): input_data = """4 .M#M .#M. M..M ###. 2 1 2 2 3 0""" expected_output = ["YES", "YES"] assert dungeon_explorer(input_data) == expected_output def test_example_case_2(): input_data = """5 ##### #M### ##.## ###M# ####. 1 2 2 0""" expect...
[ { "docstring": "Check if the player can reach the exit in the dungeon starting from (0, 0).", "function_declaration": "def can_reach_exit(dungeon, N):", "function_name": "can_reach_exit", "parameter_list": "(dungeon, N)" }, { "docstring": "Update the state of the magic wall at (x, y) if the ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\nfrom collections import deque\n\ndef can_reach_exit(dungeon, N):\n \"\"\"\n Check if the player can reach the exit in the dungeon starting from (...
trial_gpt4o_0
{ "original_instruction": "Dungeon Explorer is an adventurous game where a player needs to navigate through a dungeon to reach the exit. The dungeon is represented as an N x N grid, containing areas that are either walls or open spaces. The player starts at the top-left corner (1, 1) and needs to reach the bottom-rig...
0.488724
Taco_87448
C
[ "can_reach_exit", "update_magic_wall", "process_dungeon", "dungeon_explorer" ]
4
[ [ "dungeon_explorer", "process_dungeon" ], [ "process_dungeon", "can_reach_exit" ], [ "process_dungeon", "update_magic_wall" ] ]
3
[]
false
[]
false
pytest
true
[]
true
7762d77e144a3e33587d200a386ad5b43c80b295
185d188b130fda6f59dd73986ece192054cd1e95
v1.0
complete
Taco
Taco_87270_C
def shortest_path_in_labyrinth(R: int, C: int, labyrinth: List[str]) -> int: """ Determine the shortest path from the entrance ('E') to the treasure ('T') in a rectangular grid of cells. Return the length of this path, or -1 if no such path exists. :param R: Number of rows in the grid :param C:...
from collections import deque def shortest_path_in_labyrinth(R, C, labyrinth): def find_start_and_end(grid): start = end = None for r in range(R): for c in range(C): if grid[r][c] == 'E': start = (r, c) elif grid[r][c] == 'T': ...
def test_find_shortest_path_case_1(): R = 6 C = 7 labyrinth = [ "E......", ".###...", ".#.....", ".#.###.", "....#T.", "......."] assert shortest_path_in_labyrinth(R, C, labyrinth) == 11 def test_find_shortest_path_case_2(): R = 5 C = 5 labyri...
[ { "docstring": null, "function_declaration": "def shortest_path_in_labyrinth(R, C, labyrinth):", "function_name": "shortest_path_in_labyrinth", "parameter_list": "(R, C, labyrinth)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "paramet...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_labyrinth(R, C, labyrinth):\n def find_start_and_end(grid):\n start = end = None\n for r in ...
trial_gpt4o_0
{ "original_instruction": "In an ancient kingdom, there is a legend of treasure buried in a labyrinth of tunnels. The king has tasked you with writing a program to help treasure hunters navigate the labyrinth. The labyrinth is represented as a rectangular grid of cells, where certain cells may have walls that block m...
0.627595
Taco_87270
C
[ "shortest_path_in_labyrinth", "solve" ]
2
[ [ "solve", "shortest_path_in_labyrinth" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e1c8a9fc1e5f73a765b1cc43d9fd50951449bd6b
86a0ab14f9e13f6cbf5d16e8066cef59809a93e1
v1.0
complete
Taco
Taco_87007_C
from typing import List, Tuple def max_subarray_sum(arr: List[int]) -> int: """Returns the sum of the maximum subarray in the array. >>> max_subarray_sum([1, 2, 3, 4, 5]) == 15 >>> max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6 >>> max_subarray_sum([-1, -2, -3]) == -1 """ pass def min_...
def max_subarray_sum(arr): """ Returns the sum of the maximum subarray in the array. """ max_sum = current_sum = arr[0] for num in arr[1:]: current_sum = max(num, current_sum + num) max_sum = max(max_sum, current_sum) return max_sum def min_energy(arr): """ Returns the m...
def test_max_subarray_sum(): assert max_subarray_sum([1, 2, 3, 4, 5]) == 15 assert max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6 assert max_subarray_sum([-1, -2, -3]) == -1 assert max_subarray_sum([4, -1, 2, 1]) == 6 def test_min_energy(): assert min_energy([1, 2, 3, 4, 5]) == 1 assert...
[ { "docstring": "Returns the sum of the maximum subarray in the array.", "function_declaration": "def max_subarray_sum(arr):", "function_name": "max_subarray_sum", "parameter_list": "(arr)" }, { "docstring": "Returns the minimum energy in the list.", "function_declaration": "def min_energ...
[ 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 kadane_algorithm(arr):\n \"\"\"\n Function to find the maximum subarray sum using Kadane's Algorithm.\n \"\"\"\n max_current = max_global = arr[0]\...
trial_gpt4o_1
{ "original_instruction": "Birds are migrating, and they take flight in groups. Each bird is represented by its energy level. The Bird Leader wants to know the group’s strength, which is defined as the sum of the maximum subarray in the energies. Additionally, the Bird Leader is curious if the group has any weak link...
0.565147
Taco_87007
C
[ "max_subarray_sum", "min_energy", "bird_flight_analysis" ]
3
[ [ "bird_flight_analysis", "max_subarray_sum" ], [ "bird_flight_analysis", "min_energy" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3936fa2cd7c7428fc4969c20e5c5e183e39e0957
0921dd76f8ebaa0299977895d5a01ca957e752b2
v1.0
complete
Taco
Taco_86641_C
import math from typing import List def extractAndSortPrimes(arr: List[int]) -> List[int]: """ Given an unsorted array of integers, return a new array containing all the prime numbers from the original array, sorted in descending order. A prime number is defined as a number greater than 1 that has no posi...
import math def is_prime(num): if num <= 1: return False for i in range(2, math.isqrt(num) + 1): if num % i == 0: return False return True def extractAndSortPrimes(arr): primes = [num for num in arr if is_prime(num)] primes.sort(reverse=True) return primes
from solution import extractAndSortPrimes def test_example_1(): assert extractAndSortPrimes([10, 15, 3, 7, 11, 18, 29]) == [29, 11, 7, 3] def test_example_2(): assert extractAndSortPrimes([4, 6, 8, 10, 12]) == [] def test_no_primes(): assert extractAndSortPrimes([1, 4, 6, 8, 10, 12, 14, 15]) == [] def t...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def extractAndSortPrimes(arr):", "function_name": "extractAndSortPrimes", "parameter_list": "(arr)" } ]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\" Returns True if n is a prime number, False otherwise \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_2
{ "original_instruction": "Given an unsorted array of integers, write a function that returns a new array containing all the prime numbers from the original array, sorted in descending order. A prime number is defined as a number greater than 1 that has no positive divisors other than 1 and itself. If there are no pr...
0.656303
Taco_86641
C
[ "is_prime", "extractAndSortPrimes" ]
2
[ [ "extractAndSortPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d0b63ecded0dc7f395dd0afdfa0defed73393f1
1c823cc19e8b25cfda43d699e57b7c0b81c19e46
v1.0
complete
Taco
Taco_87486_C
def check_supplies_network(n: int, m: int, roads: List[Tuple[int, int]]) -> str: """ Check if the supply distribution network is effectively designed. Args: n (int): Number of shelters. m (int): Number of connecting roads. roads (List[Tuple[int, int]]): List of tuples where each tuple represents a ...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] ...
from solution import check_supplies_network def test_valid_network(): assert check_supplies_network(4, 3, [(1, 2), (2, 3), (3, 4)]) == "valid" def test_invalid_network(): assert check_supplies_network(5, 5, [(1, 2), (1, 3), (2, 3), (3, 4), (4, 5)]) == "invalid" def test_minimum_network(): assert check_su...
[ { "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 is_valid_network(n, m, roads):\n if m != n - 1:\n return \"invalid\"\n\n from collections import defaultdict, deque\n graph = defaultdict(list)...
trial_gpt4o_2
{ "original_instruction": "A common problem faced by urban planners is the distribution of shelters in a city prone to sudden natural disasters. In the city, there are n shelters and m connecting roads between them. Each shelter can only store a limited number of supplies. A major challenge is ensuring that after a d...
0.626199
Taco_87486
C
[ "find", "union", "is_valid_network", "check_supplies_network" ]
4
[ [ "check_supplies_network", "is_valid_network" ], [ "is_valid_network", "find" ], [ "is_valid_network", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
f5d37dd80d2e27e8c0918064ad2605a3ca6e4129
bd762974b22a347de5d572552f8da5a71684f8b8
v1.0
complete
Taco
Taco_87222_C
from typing import List, Tuple def process_test_cases(T: int, test_cases: List[Tuple[int, List[int], List[Tuple[int, int]]]]) -> List[List[int]]: """ For each node in the tree, find the difference between the maximum value and the minimum value among all the nodes present in its subtree, including the node it...
from collections import defaultdict class TreeNode: def __init__(self, value): self.value = value self.children = [] self.min_value = value self.max_value = value def build_tree(N, values, edges): tree = [TreeNode(values[i]) for i in range(N)] for u, v in edges: tre...
from solution import process_test_cases def test_example_case(): T = 1 test_cases = [ (5, [1, 3, 7, 4, 6], [(1, 2), (1, 3), (3, 4), (3, 5)]) ] expected = [ [6, 0, 3, 0, 0] ] assert process_test_cases(T, test_cases) == expected def test_single_node(): T = 1 test_cases = ...
[]
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 1 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_subtree_extremes(values, edges):\n from collections import defaultdict, deque\n import sys\n \n # Build the tree\n tree = defaultdict(list)...
trial_gpt4o_9
{ "original_instruction": "------Read problems statements in Hindi,\nMandarin chinese\n, Russian and Vietnamese as well. ------ \n\nA binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child. You are given a binary tree with $N$ nodes. Each no...
0.583033
Taco_87222
C
[ "build_tree", "dfs", "solve", "process_test_cases" ]
4
[ [ "process_test_cases", "solve" ], [ "solve", "build_tree" ], [ "solve", "dfs" ] ]
3
[ "process_test_cases" ]
false
[ "TreeNode" ]
true
pytest
true
[]
true
2115cc0df4bb37f00d83c3f194da95bcb3bf5332
4ea31a5956377c82f2abb77d5b78b8d1ddeb055a
v1.0
complete
Taco
Taco_87362_C
def search_word_in_grid(grid, word): """ Determine if a specific word exists in a grid by moving in any of the 8 possible directions. >>> search_word_in_grid([['a', 'b', 'c', 'f'], ['b', 'd', 'e', 'f'], ['d', 'h', 'a', 'g'], ['e', 'h', 'k', 'f']], 'beak') 'YES' >>> search_word_in_grid([['a', 'b', 'c', '...
def search_word_in_grid(grid, word): R = len(grid) C = len(grid[0]) word_len = len(word) # Directions: right, left, down, up, diagonals directions = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] def is_valid(x, y): return 0 <= x < R and 0 <= y < C ...
from solution import search_word_in_grid def test_sample_input(): grid = [ ['a', 'b', 'c', 'f'], ['b', 'd', 'e', 'f'], ['d', 'h', 'a', 'g'], ['e', 'h', 'k', 'f'] ] word = "beak" assert search_word_in_grid(grid, word) == "YES" def test_word_not_present(): grid = [ ...
[ { "docstring": null, "function_declaration": "def search_word_in_grid(grid, word):", "function_name": "search_word_in_grid", "parameter_list": "(grid, word)" }, { "docstring": null, "function_declaration": "def word_search_in_grid():", "function_name": "word_search_in_grid", "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 find_word(grid, word):\n R, C = len(grid), len(grid[0])\n word_len = len(word)\n \n def is_valid(x, y):\n return 0 <= x < R and 0 <= y < C\n...
trial_gpt4o_3
{ "original_instruction": "John has found a mysterious grid of characters. Each cell in the grid contains a lowercase English letter. John is fascinated with finding words in this grid by starting at any cell and moving in any of the 8 possible directions (left, right, up, down, and the four diagonals). He now seeks ...
0.597539
Taco_87362
C
[ "search_word_in_grid", "word_search_in_grid" ]
2
[ [ "word_search_in_grid", "search_word_in_grid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ebd774075a1a98898aae904f8a5bb06fcddc4aa6
803f9a077bff70e03b1f71c5a27c7a3e5cfc9dbd
v1.0
complete
Taco
Taco_87683_C
def can_form_palindrome(s: str) -> str: """ Checks if the input string can be rearranged to form a palindrome. >>> can_form_palindrome("civic") 'YES' >>> can_form_palindrome("ivicc") 'YES' >>> can_form_palindrome("hello") 'NO' """ pass def check_palindrome_possibility(strings: List[str]) -> Lis...
def can_form_palindrome(s): """ Checks if the input string can be rearranged to form a palindrome. """ from collections import Counter # Count the frequency of each character in the string char_count = Counter(s) # A string can be rearranged to form a palindrome if at most one character has ...
from solution import can_form_palindrome, check_palindrome_possibility def test_single_character(): assert can_form_palindrome("a") == "YES" def test_even_length_palindrome(): assert can_form_palindrome("abccba") == "YES" def test_odd_length_palindrome(): assert can_form_palindrome("abcba") == "YES" def...
[ { "docstring": "Checks if the input string can be rearranged to form a palindrome.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def check_palindrome_possibility(st...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef can_form_palindrome(s):\n \"\"\"\n Returns 'YES' if the string `s` can be rearranged to form a palindrome, otherwise '...
trial_gpt4o_2
{ "original_instruction": "Write a function that checks if a given string can be rearranged to form a palindrome. A palindrome is a word that reads the same forwards and backwards.\n\nFor example, \"level\" and \"radar\" are palindromes. However, \"hello\" is not.\n\nTo check if the string can be rearranged to form a...
0.780407
Taco_87683
C
[ "can_form_palindrome", "check_palindrome_possibility" ]
2
[ [ "check_palindrome_possibility", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c0537ec7f42ce0a9f8f4a36f1ac290384d904486
2fef5ecd3d61bab9739ac762fcafa042963ce1f5
v1.0
complete
Taco
Taco_87644_C
def is_prime(num: int) -> bool: """ Determines if a number is a prime number. """ # Your code here def smallest_prime_with_prime_sum(n: int) -> int: """ Returns the smallest prime number p such that p and p + n are both prime numbers. >>> smallest_prime_with_prime_sum(10) 3 >>> smal...
def is_prime(num): """ Determines if a number is a prime number. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False ...
from solution import is_prime, smallest_prime_with_prime_sum 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_smallest_prime_with_prime_sum(): ...
[ { "docstring": "Determines if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number p such that p and p + n are both prime numbers.", "function_declaration": ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from sympy import isprime\n\ndef find_smallest_prime_pair(n):\n \"\"\"\n Finds the smallest prime number p such that both p and p + n are prime numbers.\n ...
trial_gpt4o_1
{ "original_instruction": "Alex is fascinated by prime numbers and sequences. Every day, he writes down all the prime numbers in a list and tries to find interesting patterns in them. One day, he came across a challenge: He needs to determine the smallest prime number `p` such that `p + n` is also a prime number for ...
0.763907
Taco_87644
C
[ "is_prime", "smallest_prime_with_prime_sum" ]
2
[ [ "smallest_prime_with_prime_sum", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8136f38abda4b10a1235a3144d565258b72f57a4
39e2210079765b7fb64bf710a8dd878c5d228c79
v1.0
complete
Taco
Taco_87350_C
def generate_ip_addresses(s: str) -> List[str]: """ Generate all possible valid IP address combinations that can be formed by inserting three dots into the string. An IP address consists of four integer numbers between 0 and 255, separated by dots. Do not use leading zeros unless the segment is exactly '0'....
from typing import List def is_valid(segment: str) -> bool: """ Check if the segment is a valid IP address segment. An IP address segment is valid if: - It is not empty. - It does not have leading zeros unless it is "0". - It is a number between 0 and 255. """ return len(segment) > 0 an...
from solution import generate_ip_addresses def test_generate_ip_addresses(): assert generate_ip_addresses("25525511135") == ["255.255.11.135", "255.255.111.35"] assert generate_ip_addresses("0000") == ["0.0.0.0"] assert generate_ip_addresses("1111") == ["1.1.1.1"] assert generate_ip_addresses("010010")...
[ { "docstring": "Check if the segment is a valid IP address segment.\nAn IP address segment is valid if:\n- It is not empty.\n- It does not have leading zeros unless it is \"0\".\n- It is a number between 0 and 255.", "function_declaration": "def is_valid(segment):", "function_name": "is_valid", "par...
[ 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 typing import List\n\ndef generate_ip_addresses(s: str) -> List[str]:\n def is_valid(segment: str) -> bool:\n \"\"\"\n Check if a segment of ...
trial_gpt4o_4
{ "original_instruction": "Write a function that accepts a string of digits and generates all possible valid IP address combinations that can be formed by inserting three dots into the string. An IP address consists of four integer numbers between 0 and 255, separated by dots (e.g., '192.168.0.1'). Do not use leading...
0.621389
Taco_87350
C
[ "is_valid", "generate_ip_addresses" ]
2
[ [ "generate_ip_addresses", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
242a005038b41d1778f09753e093c00abed2b6cd
f2b653a08ce9ab6ed47ee5025b4931407983d4cd
v1.0
complete
Taco
Taco_87617_C
def find_highest_expression(expressions: List[str]) -> str: """ Evaluates mathematical expressions and returns the one that yields the highest result. >>> find_highest_expression(['3+4', '10-5', '6*2']) '6*2' >>> find_highest_expression(['1+1', '2+2', '1+1']) '2+2' >>> find_highest_expression([...
def evaluate_expression(expression): """ Evaluates a single mathematical expression in string form. Supports +, -, *, / operators. """ return eval(expression) def find_highest_expression(expressions): """ Finds the mathematical expression from the list that yields the highest result. If...
from solution import find_highest_expression def test_find_highest_expression_basic(): expressions = ['3+4', '10-5', '6*2'] assert find_highest_expression(expressions) == '6*2' def test_find_highest_expression_multiple_highest(): expressions = ['1+1', '2+2', '1+1'] assert find_highest_expression(expre...
[ { "docstring": "Evaluates a single mathematical expression in string form.\nSupports +, -, *, / operators.", "function_declaration": "def evaluate_expression(expression):", "function_name": "evaluate_expression", "parameter_list": "(expression)" }, { "docstring": "Finds the mathematical expr...
[ 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 evaluate_expression(expr):\n \"\"\"\n Evaluates a mathematical expression in string format.\n Supported operators: +, -, *, /\n \"\"\"\n try:\n ...
trial_gpt4o_4
{ "original_instruction": "You are given an array of strings representing mathematical expressions. Each expression will contain two numbers and an operator (+, -, *, or /). Your task is to evaluate these expressions and return the one that yields the highest result.\n\nIf the highest result is negative or zero, or i...
0.561036
Taco_87617
C
[ "evaluate_expression", "find_highest_expression" ]
2
[ [ "find_highest_expression", "evaluate_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d15073c88e631ca839c02c3dd9c677a32894a715
041f76f693ff6ee9c223ff0512f91f910fe5cadd
v1.0
complete
Taco
Taco_86716_C
from typing import List, Union, Tuple def schedule_presentation(M: int, A: int, durations: List[int]) -> Union[str, List[Tuple[int, int]]]: """ Schedules the presentations for authors without overlapping time slots. Parameters: M (int): The total duration of the exhibition. A (int): The nu...
def schedule_presentation(M, A, durations): """ Schedules the presentations for authors without overlapping time slots. Parameters: M (int): The total duration of the exhibition. A (int): The number of authors. durations (list of int): List of presentation durations each author ...
from solution import schedule_presentation, format_schedule def test_sample_input_1(): M = 10 A = 3 durations = [3, 3, 4] expected = [(0, 3), (3, 6), (6, 10)] assert schedule_presentation(M, A, durations) == expected def test_sample_input_2(): M = 5 A = 2 durations = [3, 3] expecte...
[ { "docstring": "Schedules the presentations for authors without overlapping time slots.\n\nParameters:\n M (int): The total duration of the exhibition.\n A (int): The number of authors.\n durations (list of int): List of presentation durations each author requires.\n\nReturns:\n list or str: \"No Sc...
[ 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 create_schedule(total_duration, num_authors, durations):\n \"\"\"\n Creates a schedule for authors' presentations ensuring no overlap.\n :param total_...
trial_gpt4o_1
{ "original_instruction": "A local library is organizing a book exhibition where multiple authors will present their books. Each author has a particular time slot during which they will discuss their book collections. The exhibition must ensure that there is no overlap between any two authors' presentations, as it wi...
0.581109
Taco_86716
C
[ "schedule_presentation", "format_schedule" ]
2
[ [ "format_schedule", "schedule_presentation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
36b2dcaff6b64d63ffcd13b5eb131c0a26370196
197a3bf78ce99688565938ea7104b14707b6bcbe
v1.0
complete
Taco
Taco_87274_C
def is_prime(num): """ Determines if a number is prime. """ # Implement this function to check if a number is prime. def sum_of_primes(n, elements): """ Returns the sum of prime numbers in a list of n elements. """ # Implement this function to return the sum of prime numbers in the list...
def is_prime(num): """ Determines if a number is prime. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def sum_of_primes(n, elements): """ Returns the sum of prime numbers in a list of n element...
from solution import is_prime, sum_of_primes, process_input def test_is_prime(): # Test prime numbers assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(13) == True # Test non-prime numbers assert is_prime(1) == False assert is_prime(4) == F...
[ { "docstring": "Determines if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of prime numbers in a list of n elements.", "function_declaration": "def sum_of_primes(n, elements):"...
[ 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 Determines if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1...
trial_gpt4o_0
{ "original_instruction": "Create a program that reads an integer n (1 <= n <= 100) representing the number of elements in a list, followed by n integers (each between -1000 and 1000). The program should output the sum of all prime numbers in the list. If there are no prime numbers, the program should output 0.\n\nIn...
0.711742
Taco_87274
C
[ "is_prime", "sum_of_primes", "process_input" ]
3
[ [ "process_input", "sum_of_primes" ], [ "sum_of_primes", "is_prime" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
fd14481d2e11da838b5736dc661cf6b2ab911e65
0164a60387786532c283e6e9e549100d12e34fcd
v1.0
complete
Taco
Taco_87774_C
def is_happy_number(n): """ Check if a given number is a happy number. Parameters: n (int): The number to check. Returns: bool: True if the number is a happy number, False otherwise. >>> is_happy_number(19) True >>> is_happy_number(2) False >>> is_happy_number(1) True ...
def is_happy_number(n): def get_next_number(num): return sum(int(digit) ** 2 for digit in str(num)) seen = set() while n != 1 and n not in seen: seen.add(n) n = get_next_number(n) return n == 1 def happy_number_check(n): return "YES" if is_happy_number(n) else "NO"
from solution import is_happy_number, happy_number_check def test_happy_number(): assert is_happy_number(19) == True assert is_happy_number(2) == False assert is_happy_number(1) == True assert is_happy_number(7) == True assert is_happy_number(10) == True def test_happy_number_check(): assert h...
[ { "docstring": null, "function_declaration": "def is_happy_number(n):", "function_name": "is_happy_number", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def happy_number_check(n):", "function_name": "happy_number_check", "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_number(n):\n \"\"\"\n Determines if a given number n is a happy number.\n \n Parameters:\n n (int): The number to be checked.\n \n ...
trial_gpt4o_2
{ "original_instruction": "A number is called a happy number if repeatedly replacing it with the sum of the squares of its digits eventually leads to 1. If not, it will cycle through a sequence that does not include 1. Write a program to determine if a given positive integer is a happy number or not.\n\n-----Constrai...
0.685666
Taco_87774
C
[ "is_happy_number", "happy_number_check" ]
2
[ [ "happy_number_check", "is_happy_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b52f51871bcee3df69870fd6212d229596eb59d9
4484d966dd72f3fbe1e6445087b4e38d4af30d42
v1.0
complete
Taco
Taco_87208_C
def split_array_into_power_of_two_sums(N: int, K: int, arr: List[int]) -> str: """ Determines if it is possible to split the array 'arr' of length 'N' into exactly 'K' contiguous non-empty subarrays such that the sum of elements in each subarray is a power of two. >>> split_array_into_power_of_two_sums...
def is_power_of_two(n): """ Helper function to check if a given number n is a power of two. """ return (n & (n - 1)) == 0 and n != 0 def split_array_into_power_of_two_sums(N, K, arr): """ Determines if it is possible to split the array 'arr' of length 'N' into exactly 'K' contiguous non-em...
from solution import split_array_into_power_of_two_sums def test_example1(): N, K = 5, 3 arr = [1, 2, 4, 8, 16] assert split_array_into_power_of_two_sums(N, K, arr) == "NO" def test_example2(): N, K = 6, 2 arr = [3, 1, 2, 2, 5, 8] assert split_array_into_power_of_two_sums(N, K, arr) == "NO" d...
[ { "docstring": "Helper function to check if a given number n is a power of two.", "function_declaration": "def is_power_of_two(n):", "function_name": "is_power_of_two", "parameter_list": "(n)" }, { "docstring": "Determines if it is possible to split the array 'arr' of length 'N' into exactly...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_power_of_two(n):\n \"\"\"\n Check if a number is a power of two.\n \"\"\"\n return n > 0 and (n & (n - 1)) == 0\n\ndef can_split_into_k_subarray...
trial_gpt4o_3
{ "original_instruction": "## Problem Statement\n\nYou are given an integer array `arr` of length `N` and an integer `K`. Your task is to determine if it is possible to split the array `arr` into exactly `K` contiguous non-empty subarrays such that the sum of elements in each subarray is a power of two. If it is poss...
0.625043
Taco_87208
C
[ "is_power_of_two", "split_array_into_power_of_two_sums" ]
2
[ [ "split_array_into_power_of_two_sums", "is_power_of_two" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a1571aa337795fbac871b2ffcca2a6b286b405dc
7791c93e287f4c84c4d10dd18e28de57d1df4138
v1.0
complete
Taco
Taco_87638_C
def auction_results(n: int, items: list) -> list: """ Determines if each item's highest bid meets or exceeds its minimum price. :param n: number of items :param items: list of tuples containing (name, minimum price, highest bid) :return: list of "YES" or "NO" for each item """ ...
def auction_results(n, items): """ Determines if each item's highest bid meets or exceeds its minimum price. :param n: number of items :param items: list of tuples containing (name, minimum price, highest bid) :return: list of "YES" or "NO" for each item """ results = [] for item in ite...
from solution import process_auction_input def test_auction_results_example1(): n = 3 raw_items = [ "Painting 100 150", "Vase 200 180", "Sculpture 300 300" ] assert process_auction_input(n, raw_items) == ["YES", "NO", "YES"] def test_auction_results_example2(): n = 4 ra...
[ { "docstring": "Determines if each item's highest bid meets or exceeds its minimum price.\n\n:param n: number of items\n:param items: list of tuples containing (name, minimum price, highest bid)\n:return: list of \"YES\" or \"NO\" for each item", "function_declaration": "def auction_results(n, items):", ...
[ 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 check_bids(n, items):\n results = []\n for item in items:\n name, price, bid = item\n if bid >= price:\n results.append(\"YES\")...
trial_gpt4o_1
{ "original_instruction": "Miko is organizing a charity auction and has a list of items, each with a specified minimum price. Some bids have already been placed on the items, but Miko needs to determine if the current highest bid meets or exceeds the minimum price for each item.\n\nWrite a program that helps Miko by ...
0.523269
Taco_87638
C
[ "auction_results", "process_auction_input" ]
2
[ [ "process_auction_input", "auction_results" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6597e2a1971efadd2fc062b2a96f5cc64aeeb3c0
fe54f4023f8828abc30074cc57cc15ff189b66e3
v1.0
complete
Taco
Taco_88011_C
def max_trades(crop_values, initial_crop_value, available_trades): """ Function to calculate the maximum number of trades that can be performed starting with the initial crop value. Parameters: crop_values (list of int): List of crop values. initial_crop_value (int): Initial crop value. ava...
def max_trades(crop_values, initial_crop_value, available_trades): """ Function to calculate the maximum number of trades that can be performed starting with the initial crop value. Parameters: crop_values (list of int): List of crop values. initial_crop_value (int): Initial crop value. ava...
import pytest from solution import max_trades, process_test_cases, from_input_string, to_output_string def test_max_trades(): assert max_trades([10, 20, 30, 40, 50], 20, 3) == 3 assert max_trades([15, 25, 10], 10, 2) == 2 def test_process_test_cases(): T = 2 test_cases = [ (5, [10, 20, 30, 40,...
[ { "docstring": "Function to calculate the maximum number of trades that can be performed starting with the initial crop value.\n\nParameters:\ncrop_values (list of int): List of crop values.\ninitial_crop_value (int): Initial crop value.\navailable_trades (int): Number of crops available to trade.\n\nReturns:\n...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_trades(num_crops, crop_values, initial_value, available_trades):\n \"\"\"\n Returns the maximum number of trades that can be performed in one day giv...
trial_gpt4o_4
{ "original_instruction": "In Farmville, there's a unique currency system where crops can be traded directly with each other without using any money. Each crop has a certain trading value, and the farmers want to maximize their trades beneficially.\n\nYou are given a list of crops and their respective values. Each da...
0.617879
Taco_88011
C
[ "max_trades", "process_test_cases", "from_input_string", "to_output_string" ]
4
[ [ "process_test_cases", "max_trades" ] ]
1
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
4aaea6cb2a0157f2638499fc8f3534ec7976756e
d83ef28eb983f37905e0da370584de60e76d617c
v1.0
complete
Taco
Taco_87970_C
def min_delivery_time(num_vehicles, num_packages, capacities, delivery_times): """ Calculate the minimum total delivery time for given packages and vehicles. Parameters: - num_vehicles: int - The number of vehicles. - num_packages: int - The number of packages. - capacities: List[int] - A list conta...
def min_delivery_time(num_vehicles, num_packages, capacities, delivery_times): delivery_times.sort() min_total_time = 0 for i in range(num_packages): min_total_time += delivery_times[i] return min_total_time def solve_delivery_problem(): import sys input = sys.stdin.read data = in...
def test_min_delivery_time(): assert min_delivery_time(2, 5, [3, 2], [1, 2, 3, 4, 5]) == 15 assert min_delivery_time(3, 4, [2, 2, 1], [4, 5, 6, 7]) == 22 assert min_delivery_time(1, 1, [1], [10]) == 10 assert min_delivery_time(2, 5, [3, 2], [6, 7, 8, 9, 10]) == 40 def test_solve_delivery_problem(monkey...
[ { "docstring": null, "function_declaration": "def min_delivery_time(num_vehicles, num_packages, capacities, delivery_times):", "function_name": "min_delivery_time", "parameter_list": "(num_vehicles, num_packages, capacities, delivery_times)" }, { "docstring": null, "function_declaration"...
[ 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_delivery_time(V, P, capacities, delivery_times):\n \"\"\"\n Returns the minimum total delivery time when the packages are optimally assigned to the v...
trial_gpt4o_2
{ "original_instruction": "Problem\n\nA major delivery company is optimizing its delivery routes and needs your help to compute the minimum time it will take to deliver all the packages. The company operates a fleet of delivery vehicles, each with a maximum capacity of packages it can carry. Each delivery vehicle can...
0.598957
Taco_87970
C
[ "min_delivery_time", "solve_delivery_problem" ]
2
[ [ "solve_delivery_problem", "min_delivery_time" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8c0277676b9ddb1a846b40be594fb2d1d321b806
aabafe7dc2c652a977c0f3eb46e50cfff96f67ec
v1.0
complete
Taco
Taco_87813_C
import math from typing import List, Tuple def is_covered(W: int, H: int, sensors: List[Tuple[int, int]], R: int) -> bool: """ Check if the sensors can cover the entire rectangular area. Parameters: W (int): Width of the rectangular area. H (int): Height of the rectangular area. sensors...
import math def is_covered(W, H, sensors, R): # A function to check if each point in the rectanglar area is covered by at least one sensor def point_covered(x, y): for (sx, sy) in sensors: if math.sqrt((sx - x)**2 + (sy - y)**2) <= R: return True return False fo...
from solution import is_covered, analyze_coverage, read_input_data, main def test_is_covered(): assert is_covered(5, 5, [(1, 1), (1, 4), (4, 1), (4, 4)], 2) == True assert is_covered(10, 10, [(1, 1), (1, 9), (9, 1), (9, 9), (5, 5)], 3) == False def test_analyze_coverage(): test_cases = [ ((5, 5, 4...
[ { "docstring": null, "function_declaration": "def is_covered(W, H, sensors, R):", "function_name": "is_covered", "parameter_list": "(W, H, sensors, R)" }, { "docstring": null, "function_declaration": "def analyze_coverage(test_cases):", "function_name": "analyze_coverage", "param...
[ 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_covered(W, H, sensors, R):\n def is_point_covered(x, y):\n for sx, sy in sensors:\n if math.hypot(sx - x, sy - y) <= R:\...
trial_gpt4o_4
{ "original_instruction": "A company wants to place a number of sensors in a rectangular area to monitor environmental conditions. Each sensor has a specific range represented by a circle with a given radius. The goal is to determine if it is possible to cover the entire rectangular area with the given sensors. You n...
0.598725
Taco_87813
C
[ "is_covered", "analyze_coverage", "read_input_data", "main" ]
4
[ [ "analyze_coverage", "is_covered" ] ]
1
[ "read_input_data" ]
false
[]
false
pytest
true
[]
true
e595a4bf6e05e32447f0f0bec80c849c5afdf217
f762bf15661c5ef2574add59389e7c08d40a7472
v1.0
complete
Taco
Taco_88058_C
def product_except_self(nums: List[int]) -> List[int]: """ Given a list of integers, return a new list where each element is the product of all the elements in the original list except the one at the current index. >>> product_except_self([1, 2, 3, 4]) [24, 12, 8, 6] >>> product_except_se...
def product_except_self(nums): """ Returns a list such that each element is the product of all other elements except itself. """ n = len(nums) if n == 0: return [] # Initialize the result array with 1 result = [1] * n # Calculate the left products left_product = 1 f...
def test_product_except_self(): assert input_to_output("1 2 3 4") == "24 12 8 6" assert input_to_output("2 3 4 5") == "60 40 30 24" assert input_to_output("1 1 1 1") == "1 1 1 1" assert input_to_output("0 1 2 3") == "6 0 0 0" assert input_to_output("1 2 3") == "6 3 2" assert input_to_output("5")...
[ { "docstring": "Returns a list such that each element is the product of all other elements except itself.", "function_declaration": "def product_except_self(nums):", "function_name": "product_except_self", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def in...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def product_except_self(nums):\n \"\"\"\n This function returns a new list where each element \n is the product of all the elements in the input list exce...
trial_gpt4o_1
{ "original_instruction": "Given a list of integers, you are tasked with creating a new list where each element in the new list is the product of all the elements in the original list except the one at the current index.\n\nInput\n\nThe input consists of a single line containing a space-separated list of integers `a_...
0.671932
Taco_88058
C
[ "product_except_self", "input_to_output" ]
2
[ [ "input_to_output", "product_except_self" ] ]
1
[]
false
[]
false
pytest
false
[]
true
74c5312f7d7d5ca22a09fd41abeebd1595b65c6b
8f4da09afc0a1be15ce0a516ba717df081813893
v1.0
complete
Taco
Taco_88209_C
def solve(m, n, garden): """ Mary wants to plant new flowers in some of the empty cells but ensure that no two adjacent cells (vertically or horizontally) contain flowers. >>> solve(3, 3, [ ".#.", "...", "..#" ]) 4 >>> solve(4, 4, [ "....", "....", "....
def max_flowers(garden): m = len(garden) n = len(garden[0]) count = 0 for r in range(m): for c in range(n): if garden[r][c] == '.': if (r == 0 or garden[r - 1][c] != 'F') and (c == 0 or garden[r][c - 1] != 'F'): garden[r][c] = 'F' ...
from solution import solve def test_example_1(): assert solve(3, 3, [ ".#.", "...", "..#" ]) == 4 def test_example_2(): assert solve(4, 4, [ "....", "....", "....", "...." ]) == 8 def test_single_cell_with_plant(): assert solve(1, 1, ["#"]) ...
[ { "docstring": null, "function_declaration": "def max_flowers(garden):", "function_name": "max_flowers", "parameter_list": "(garden)" }, { "docstring": null, "function_declaration": "def solve(m, n, garden):", "function_name": "solve", "parameter_list": "(m, n, garden)" } ]
[ 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_flowers(m, n, garden):\n def is_valid(x, y):\n return 0 <= x < m and 0 <= y < n and garden[x][y] == '.'\n\n def can_plant(x, y):\n # Ch...
trial_gpt4o_3
{ "original_instruction": "Mary, a professional gardener, has a rectangular garden divided into an m x n grid of cells, where each cell can either contain a plant or be empty. Mary wants to plant new flowers in some of the empty cells, but she wants to ensure that no two adjacent cells (vertically or horizontally) co...
0.608698
Taco_88209
C
[ "max_flowers", "solve" ]
2
[ [ "solve", "max_flowers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
04a0bd420fafefb4bcf54e0dd0f4d748e17bcfed
3183dc6296e394b04ebd33f98bdead3f04751b43
v1.0
complete
Taco
Taco_87817_C
from typing import List def min_steps_to_reach_end(grid: List[str]) -> int: """ Determine the minimum number of steps required to move from the top-left corner (0,0) to the bottom-right corner (N-1,N-1) of the grid. You can move up, down, left, or right, and you cannot move through obstacles. If it is not poss...
from collections import deque def min_steps_to_reach_end(grid): N = len(grid) if grid[0][0] == 'X' or grid[N-1][N-1] == 'X': return -1 # If start or end is blocked directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(0, 0, 0)]) # (row, col, steps) visited = set((0, 0)) wh...
import pytest from solution import process_input_output, min_steps_to_reach_end def test_single_case_1(): input_str = "1\n3\n...\n.X.\n...\n" expected_output = [4] assert process_input_output(input_str) == expected_output def test_single_case_2(): input_str = "1\n3\n.X.\nX..\n...\n" expected_outpu...
[ { "docstring": null, "function_declaration": "def min_steps_to_reach_end(grid):", "function_name": "min_steps_to_reach_end", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve(grid_cases):", "function_name": "solve", "parameter_list": "(grid_cas...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_steps(grid):\n N = len(grid)\n if grid[0][0] == 'X' or grid[N-1][N-1] == 'X':\n return -1\n \n directio...
trial_gpt4o_2
{ "original_instruction": "You are given a grid of size N x N with obstacles represented by 'X' and free cells represented by '.'. Your task is to determine the minimum number of steps required to move from the top-left corner (0,0) to the bottom-right corner (N-1,N-1) of the grid. You can move up, down, left, or rig...
0.708479
Taco_87817
C
[ "min_steps_to_reach_end", "solve", "process_input_output" ]
3
[ [ "process_input_output", "solve" ], [ "solve", "min_steps_to_reach_end" ] ]
2
[ "process_input_output" ]
false
[]
false
pytest
true
[]
true
d3a208b225e32e4e2547c4586e46fed9ae1ae472
3c7d310402669313662465f62ef4f92289f4d2ae
v1.0
complete
Taco
Taco_88394_C
def solve_islands_problem(m: int, n: int, input_grid_str: str) -> int: """ Determine the number of distinct islands in a grid. >>> solve_islands_problem(4, 5, "11000\n11000\n00100\n00011") 3 >>> solve_islands_problem(3, 3, "111\n010\n111") 1 >>> solve_islands_problem(3, 2, "01\n10\n01") 3 ...
def count_islands(m, n, grid): def dfs(x, y): if x < 0 or x >= m or y < 0 or y >= n or grid[x][y] == '0': return grid[x][y] = '0' # Mark the cell as visited for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]: dfs(x + dx, y + dy) islands = 0 for i in range(m): ...
from solution import solve_islands_problem def test_case_1(): m, n = 4, 5 grid_str = "11000\n11000\n00100\n00011" assert solve_islands_problem(m, n, grid_str) == 3 def test_case_2(): m, n = 3, 3 grid_str = "111\n010\n111" assert solve_islands_problem(m, n, grid_str) == 1 def test_case_3(): ...
[ { "docstring": null, "function_declaration": "def count_islands(m, n, grid):", "function_name": "count_islands", "parameter_list": "(m, n, grid)" }, { "docstring": null, "function_declaration": "def solve_islands_problem(m, n, input_grid_str):", "function_name": "solve_islands_proble...
[ 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 num_distinct_islands(grid):\n \"\"\"\n Returns the number of distinct islands in the grid.\n \n grid: list of list of str: The grid given as list o...
trial_gpt4o_2
{ "original_instruction": "You've been given a rectangular grid with `m` rows and `n` columns where each cell contains either a '0' (empty cell) or a '1' (land cell). The grid represents a map of a fictive Archipelago, and you need to find the number of distinct islands on this map. An island is defined as a group of...
0.605475
Taco_88394
C
[ "count_islands", "solve_islands_problem" ]
2
[ [ "solve_islands_problem", "count_islands" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e29f18fd48765635abb3a1dda6da5d83a600e440
754021765aefd619aba6e88842276f948110303e
v1.0
complete
Taco
Taco_88185_C
def solve(n: int, m: int, edge_list: List[Tuple[int, int, int]]) -> Union[int, str]: """ In a dense forest, there exists a network of magical trees connected by mystical paths. Each mystical path has an associated weight which influences magical energy flow between the trees it connects. This network is represented...
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 root_x != root_y: if rank[root_x] > rank[root_y]: parent[root_y] = root_x elif r...
def test_example_1(): n = 4 m = 5 edge_list = [ (1, 2, 3), (1, 3, 1), (2, 3, 3), (3, 4, 6), (1, 4, 5) ] assert solve(n, m, edge_list) == 9 def test_example_2(): n = 3 m = 1 edge_list = [ (1, 2, 2) ] assert solve(n, m, edge_list) ==...
[ { "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": "class DisjointSet:\n def __init__(self, n):\n self.parent = [i for i in range(n)]\n self.rank = [0] * n\n\n def find(self, x):\n if self...
trial_gpt4o_1
{ "original_instruction": "In a dense forest, there exists a network of magical trees connected by mystical paths. Each mystical path has an associated weight which influences magical energy flow between the trees it connects. This network is represented as an undirected graph where nodes are trees and edges are the ...
0.720365
Taco_88185
C
[ "find", "union", "minimum_spanning_tree", "solve" ]
4
[ [ "minimum_spanning_tree", "find" ], [ "minimum_spanning_tree", "union" ], [ "solve", "minimum_spanning_tree" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
f76e4c8d9ba718ab92221c4700407744c1ba1c15
995faf2df5f049cd8692c597dd5e1cb5fb2232a1
v1.0
complete
Taco
Taco_88154_C
def evaluate_postfix(expression: str) -> int: """ Evaluate a postfix mathematical expression. >>> evaluate_postfix("5 1 2 + 4 * + 3 -") 14 >>> evaluate_postfix("3 4 + 2 * 7 /") 2 >>> evaluate_postfix("4 2 3 * + 6 -") 4 """ def evaluate_multiple_postfix(expressions: List[str]) -> List[int]: """ ...
def evaluate_postfix(expression): stack = [] tokens = expression.split() for token in tokens: if token.isdigit(): stack.append(int(token)) else: second_operand = stack.pop() first_operand = stack.pop() if token == '+': result = ...
from solution import evaluate_postfix, evaluate_multiple_postfix def test_evaluate_postfix(): assert evaluate_postfix("5 1 2 + 4 * + 3 -") == 14 assert evaluate_postfix("3 4 + 2 * 7 /") == 2 assert evaluate_postfix("4 2 3 * + 6 -") == 4 assert evaluate_postfix("2 3 +") == 5 assert evaluate_postfix(...
[ { "docstring": null, "function_declaration": "def evaluate_postfix(expression):", "function_name": "evaluate_postfix", "parameter_list": "(expression)" }, { "docstring": null, "function_declaration": "def evaluate_multiple_postfix(expressions):", "function_name": "evaluate_multiple_p...
[ 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 evaluate_postfix(expr):\n \"\"\"\n Evaluates a postfix expression and returns the result.\n\n Args:\n expr (str): The postfix expression to evaluat...
trial_gpt4o_1
{ "original_instruction": "You need to develop a program that evaluates postfix mathematical expressions (also known as Reverse Polish Notation). Postfix expressions are mathematical expressions in which each operator follows all of its operands. For example, the postfix expression `5 1 2 + 4 * + 3 -` evaluates to `1...
0.541945
Taco_88154
C
[ "evaluate_postfix", "evaluate_multiple_postfix" ]
2
[ [ "evaluate_multiple_postfix", "evaluate_postfix" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b1b76f933273db88a3e1a5935fa1139bcd930342
ec701a219eb57d501a62431f8c6771c77f0b53c3
v1.0
complete
Taco
Taco_88059_C
def determine_season(day: int) -> str: """ Determines the season for a given day of the year. Args: day (int): The day of the year (1 to 365). Returns: str: The season corresponding to the given day. """ # Your code here def categorize_flowers(flower_days: List[int]) -> List[str]: ...
def determine_season(day): """ Determines the season for a given day of the year. Args: day (int): The day of the year (1 to 365). Returns: str: The season corresponding to the given day. """ if 60 <= day <= 151: return "Spring" elif 152 <= day <= 243: return "Summe...
from solution import categorize_flowers, determine_season def test_determine_season(): assert determine_season(60) == "Spring" assert determine_season(151) == "Spring" assert determine_season(152) == "Summer" assert determine_season(243) == "Summer" assert determine_season(244) == "Autumn" asse...
[ { "docstring": "Determines the season for a given day of the year.\n\nArgs:\nday (int): The day of the year (1 to 365).\n\nReturns:\nstr: The season corresponding to the given day.", "function_declaration": "def determine_season(day):", "function_name": "determine_season", "parameter_list": "(day)" ...
[ 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 determine_season(day):\n if 60 <= day <= 151:\n return \"Spring\"\n elif 152 <= day <= 243:\n return \"Summer\"\n elif 244 <= day <= 334...
trial_gpt4o_2
{ "original_instruction": "Jenny has a garden with different types of flowers. She wants to categorize them based on their blooming season. Each flower can only bloom in one of the four seasons: Spring, Summer, Autumn, or Winter.\n\nJenny has a list of flowers with the day of the year they start blooming (1 to 365). ...
0.559332
Taco_88059
C
[ "determine_season", "categorize_flowers" ]
2
[ [ "categorize_flowers", "determine_season" ] ]
1
[]
false
[]
false
pytest
true
[]
true
05a6897d9b814880db30d1d4477f2ee6ced4d374
b7c9178bdab4d8909704837cc0639756acc26b9f
v1.0
complete
Taco
Taco_88400_C
import math from typing import List, Tuple def calc_distance(c1: Tuple[int, int], c2: Tuple[int, int]) -> float: """Calculate the Euclidean distance between two points.""" return math.sqrt((c1[0] - c2[0]) ** 2 + (c1[1] - c2[1]) ** 2) def min_total_cost_to_connect_castles(castles: List[Tuple[int, int]]) -> flo...
import math import heapq class DisjointSet: def __init__(self, n): self.parent = list(range(n)) self.rank = [1] * n def find(self, a): if self.parent[a] == a: return a self.parent[a] = self.find(self.parent[a]) # Path compression return self.parent[a] ...
from solution import min_total_cost_to_connect_castles def test_example_1(): castles = [(0, 0), (0, 1), (1, 0), (1, 1)] result = min_total_cost_to_connect_castles(castles) assert abs(result - 3.000000) < 1e-6 def test_example_2(): castles = [(0, 0), (1, 1), (2, 2)] result = min_total_cost_to_conne...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nimport heapq\n\nclass DisjointSet:\n def __init__(self, n):\n self.parent = list(range(n))\n self.rank = [1] * n\n\n def find(self...
trial_gpt4o_0
{ "original_instruction": "In the kingdom of Geometrica, there are several castles located on the x-y plane. Each castle is represented by its coordinates (xi, yi). The king wants to ensure that all castles are connected by building the minimum number of roads, such that each road connects two castles directly. A roa...
0.562577
Taco_88400
C
[ "calc_distance", "min_total_cost_to_connect_castles" ]
2
[ [ "min_total_cost_to_connect_castles", "calc_distance" ] ]
1
[]
false
[ "DisjointSet" ]
true
pytest
true
[]
true
bb8d0569badbdadc6190c351f8891c462b80320e
bee8764e7ae3854a926e075ab00aecd40d51b2f7
v1.0
complete
Taco
Taco_88377_C
from typing import List, Tuple def minimum_total_travel_time(test_cases: List[Tuple[int, int, List[Tuple[int, int, int]]]]) -> List[int]: """ Determine the minimum total travel time required to connect all cities for each test case. Each test case consists of: - n: the number of cities - m: th...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yr...
from solution import minimum_total_travel_time def test_case_1(): test_cases = [ (4, 5, [ (0, 1, 1), (0, 2, 2), (0, 3, 3), (1, 2, 1), (2, 3, 1), ]), ] assert minimum_total_travel_time(test_cases) == [3] def test_case_2(): 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)" }, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_0
{ "original_instruction": "The Kingdom of Booleania is known for its large network of road systems. The king of Booleania has decided to start a new project to improve the transportation system between cities. To minimize travel time, the king wants to ensure that the network of roads is efficiently connected, such t...
0.694839
Taco_88377
C
[ "find", "union", "kruskal_mst", "minimum_total_travel_time" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimum_total_travel_time", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
2e80f99ceb5318f7e987f776bb110f98a26812c5
45909168e19b585c42896d1de3cc99b8663c1e9f
v1.0
complete
Taco
Taco_88438_C
from typing import List def is_prime(num: int) -> bool: """ Determine if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(9) False >>> is_prime(11) True """ pass def next_prime(n: int) -> int: """ Give...
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 next_prime(n): if n <=...
from solution import is_prime, next_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(11) == True def test_next_prime(): assert next_prime(7) == 11 assert n...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def next_prime(n):", "function_name": "next_prime", "parameter_list": "(n)" } ]
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_3
{ "original_instruction": "Alice has recently learned about prime numbers and their significance in cryptography. To help her practice, Bob gave her a task: Given a number n, find the closest prime number greater than n. If there are multiple prime numbers at the same distance, return the smaller one.\n\nYour task is...
0.799248
Taco_88438
C
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2a0fd262454af5c723c70fb1ef5d5dfa75ee9591
d004fe7f97d44acc4376809cefefaf8f4cc202c6
v1.0
complete
Taco
Taco_88447_C
from typing import List, Tuple def preprocess_prefix_sums(scores: List[int]) -> List[int]: """Computes the prefix sums for the given scores array.""" pass def range_sum_queries(scores: List[int], queries: List[Tuple[int, int]]) -> List[int]: """Given an array of scores and a list of queries, returns the s...
def preprocess_prefix_sums(scores): """ Computes the prefix sums for the given scores array. """ prefix_sums = [0] * (len(scores) + 1) for i in range(1, len(prefix_sums)): prefix_sums[i] = prefix_sums[i-1] + scores[i-1] return prefix_sums def range_sum_queries(scores, queries): """ ...
from solution import range_sum_queries def test_range_sum_queries_basic(): scores = [1, 7, 3, 0, 9, 4] queries = [[1, 3], [0, 4], [2, 5]] assert range_sum_queries(scores, queries) == [10, 20, 16] def test_range_sum_queries_single_element(): scores = [5] queries = [[0, 0]] assert range_sum_quer...
[ { "docstring": "Computes the prefix sums for the given scores array.", "function_declaration": "def preprocess_prefix_sums(scores):", "function_name": "preprocess_prefix_sums", "parameter_list": "(scores)" }, { "docstring": "Given an array of scores and a list of queries, returns the sum of ...
[ 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 prefix_sum(scores):\n \"\"\"\n Generates the prefix sum array for the given scores.\n \"\"\"\n n = len(scores)\n prefix = [0] * (n + 1)\n for...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers scores, you are tasked with performing multiple queries on this array. Each query is defined by a range [l, r] (inclusive) for which you need to find the sum of the scores. Your task is to efficiently process these queries using prefix sums to provide the sum of e...
0.583316
Taco_88447
C
[ "preprocess_prefix_sums", "range_sum_queries" ]
2
[ [ "range_sum_queries", "preprocess_prefix_sums" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eb84c0bfd968a6a1628b5b58d2457cd548d4e56e
51f4cc74b2dd27f5cccd07d5a1ac699a10755325
v1.0
complete
Taco
Taco_88160_C
from typing import List, Tuple def is_prime(n: int) -> bool: """Returns whether the given number is prime.""" # Implement the prime checking logic here def sum_of_primes_in_range(a: int, b: int) -> int: """Returns the sum of all unique prime numbers in the range [a, b].""" # Implement the sum of prime...
def is_prime(n): """ Checks 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 s...
from solution import is_prime, sum_of_primes_in_range, compute_prime_sums def test_is_prime(): assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(11) def test_sum_of_primes_in_range(): assert sum...
[ { "docstring": "Checks if a number is prime. ", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all unique prime numbers in the range [a, b]. ", "function_declaration": "def sum_of_primes_in_range(a, b...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sympy\n\ndef sum_primes_in_range(a, b):\n \"\"\"\n Given two integers a and b, return the sum of all prime numbers in the range [a, b], inclusive.\n ...
trial_gpt4o_4
{ "original_instruction": "A wizard in the kingdom of Algorithmia has recently learned the art of prime summation. To practice his new skills, he wants to write a program that will help him find the sum of all unique prime numbers present in given ranges of integers. Given two integers a and b, the program should com...
0.674216
Taco_88160
C
[ "is_prime", "sum_of_primes_in_range", "compute_prime_sums" ]
3
[ [ "compute_prime_sums", "sum_of_primes_in_range" ], [ "sum_of_primes_in_range", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
81ea9f27cee255a1b41cf126f3e1931c9eff8ae2
a7036053e8dd82a3f30fabdcb27bec4d75b4cde9
v1.0
complete
Taco
Taco_88341_C
import random from typing import List def miller_rabin(n: int, k: int = 5) -> bool: """Helper function to run the Miller-Rabin primality test.""" if n <= 1: return False if n <= 3: return True if n % 2 == 0: return False # Write n as d*2^r + 1 r, d = 0, n - 1 wh...
import random def miller_rabin(n, k=5): if n <= 1: return False if n <= 3: return True if n % 2 == 0: return False # Write n as d*2^r + 1 r, d = 0, n - 1 while d % 2 == 0: r += 1 d //= 2 def is_composite(a): if pow(a, d, n) == 1: ...
from solution import primality_test def test_primality_sample_input(): assert primality_test([2, 17, 18, 19, 20]) == ["YES", "YES", "NO", "YES", "NO"] def test_primality_small_primes(): assert primality_test([3, 5, 7, 11, 13]) == ["YES", "YES", "YES", "YES", "YES"] def test_primality_small_composites(): ...
[ { "docstring": null, "function_declaration": "def miller_rabin(n, k=5):", "function_name": "miller_rabin", "parameter_list": "(n, k=5)" }, { "docstring": null, "function_declaration": "def primality_test(numbers):", "function_name": "primality_test", "parameter_list": "(numbers)"...
[ 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 miller_rabin_primality_test(n, k=5):\n import random\n\n def is_prime(n, d, s):\n a = random.randint(2, n - 2)\n x = pow(a, d, n)\n ...
trial_gpt4o_2
{ "original_instruction": "Alex is a budding software engineer and wants to create a program that can detect prime numbers efficiently. He is aware that checking larger numbers for primality can be time-consuming, and thus intends to use a probabilistic method called the Miller-Rabin primality test.\n\nYour task is t...
0.707252
Taco_88341
C
[ "miller_rabin", "primality_test" ]
2
[ [ "primality_test", "miller_rabin" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6c10bf4331f5a529bc9e5b6d93c824eb1b7d2280
6369278680d25bc34764f1f54150aa72aa337a07
v1.0
complete
Taco
Taco_88374_C
from typing import List def find_closest_matches(dictionary: List[str], words_to_check: List[str]) -> List[str]: """ Given a list of words (the dictionary) and a list of words to check, find the closest match from the dictionary for each word to check based on the Levenshtein distance. If there are ...
from typing import List def levenshtein_distance(s1: str, s2: str) -> int: """ Compute the Levenshtein distance between two strings s1 and s2. """ if len(s1) < len(s2): return levenshtein_distance(s2, s1) if len(s2) == 0: return len(s1) previous_row = range(len(s2) + 1) fo...
from solution import find_closest_matches def test_exact_match(): dictionary = ["apple", "banana", "carrot"] words_to_check = ["apple"] assert find_closest_matches(dictionary, words_to_check) == ["apple"] def test_single_edit_distance(): dictionary = ["apple", "banana", "carrot"] words_to_check = ...
[ { "docstring": "Compute the Levenshtein distance between two strings s1 and s2.", "function_declaration": "def levenshtein_distance(s1, s2):", "function_name": "levenshtein_distance", "parameter_list": "(s1, s2)" }, { "docstring": null, "function_declaration": "def find_closest_matches(d...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef levenshtein_distance(s1: str, s2: str) -> int:\n \"\"\"\n Compute the Levenshtein distance between two strings s1 and s2.\n ...
trial_gpt4o_0
{ "original_instruction": "You are working at a software company where you need to implement a feature that auto-suggests corrections for misspelled words using a given dictionary. To achieve this, you decide to utilize a simple heuristic based on the Levenshtein distance (edit distance). The Levenshtein distance bet...
0.598756
Taco_88374
C
[ "levenshtein_distance", "find_closest_matches" ]
2
[ [ "find_closest_matches", "levenshtein_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8c5b0cd9263dbc60d12dddfece2445042b71939c
cccc5cbf2edf363af7db81bbc00bfe4ed579e201
v1.0
complete
Taco
Taco_88216_C
def min_buses_needed(T: int, test_cases: List[Tuple[int, List[int], List[int]]]) -> List[int]: """ Determine the minimum number of buses required to cover all the routes without any overlap. Args: T (int): Number of test cases. test_cases (List[Tuple[int, List[int], List[int]]]): Each test cas...
def min_buses_needed(T, test_cases): results = [] for i in range(T): N = test_cases[i][0] start_times = test_cases[i][1] end_times = test_cases[i][2] intervals = sorted(zip(start_times, end_times), key=lambda x: x[1]) count = 0 last_end_time = 0 ...
from solution import min_buses_needed def test_single_test_case(): T = 1 test_cases = [ (3, [1, 3, 5], [4, 8, 9]) ] assert min_buses_needed(T, test_cases) == [2] def test_multiple_test_cases(): T = 2 test_cases = [ (3, [1, 3, 5], [4, 8, 9]), (4, [2, 4, 6, 7], [5, 7, 8,...
[ { "docstring": null, "function_declaration": "def min_buses_needed(T, test_cases):", "function_name": "min_buses_needed", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def get_min_buses(T, test_cases):", "function_name": "get_min_buses", "pa...
[ 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 min_buses_needed(T, test_cases):\n results = []\n for i in range(T):\n N = test_cases[i][0]\n start_times = test_cases[i][1]\n end_t...
trial_gpt4o_0
{ "original_instruction": "A new startup Byteland Transit is planning to open a bus service that operates between different locations in the city. To ensure smooth operations, they need an optimal schedule to avoid any overlaps in bus services. Each bus route has a start and end time, and a bus route is considered ac...
0.647102
Taco_88216
C
[ "min_buses_needed", "get_min_buses" ]
2
[ [ "get_min_buses", "min_buses_needed" ] ]
1
[]
false
[]
false
pytest
true
[]
true
229bd0a7a5fcb62cb28c2698dcf1d078f08794ea
cad58981c93e9d9a83c90157026bbfffa97efd1a
v1.0
complete
Taco
Taco_88416_C
def is_valid_path(grid, n, m): """ Determines if there is a valid path from top-left to bottom-right in the grid such that each move to an adjacent cell (right or down) has an elevation difference of at most 2 units. """ pass def can_patrol(T, test_cases): """ For each test case, checks if ther...
def is_valid_path(grid, n, m): from collections import deque directions = [(0, 1), (1, 0)] visited = [[False for _ in range(m)] for _ in range(n)] queue = deque([(0, 0)]) visited[0][0] = True while queue: x, y = queue.popleft() if x == n - 1 and y == m - 1: return ...
import pytest from solution import parse_input, can_patrol def test_can_patrol(): input_data = "2\n3 3\n1 2 3\n2 3 4\n3 4 5\n3 3\n1 3 5\n6 8 10\n11 13 15\n" T, test_cases = parse_input(input_data) results = can_patrol(T, test_cases) assert results == ["YES", "NO"] def test_single_case_yes(): input...
[ { "docstring": null, "function_declaration": "def is_valid_path(grid, n, m):", "function_name": "is_valid_path", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def can_patrol(T, test_cases):", "function_name": "can_patrol", "parameter_list": "(T...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "def is_valid_path(grid, n, m):\n \"\"\"\n Determines if there is a valid path from the top-left to the bottom-right cell\n by onl...
trial_gpt4o_2
{ "original_instruction": "The kingdom of Keploria is under attack by an army of goblins that march in from the east. The kingdom's defensive strategy requires understanding the patterns in which the goblins approach. The goblins' marching paths can be represented as a grid where each cell contains an integer height ...
0.602992
Taco_88416
C
[ "is_valid_path", "can_patrol", "parse_input" ]
3
[ [ "can_patrol", "is_valid_path" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
201580922b1445fad4407ead056eeea795fff68a
88ac8239bcdf31ebd6aa53be9720a08b519b5575
v1.0
complete
Taco
Taco_88462_C
def can_partition_into_three_palindromic_parts(s: str) -> str: """ Determine if it is possible to partition the string into three non-empty parts such that each part is a palindrome. >>> can_partition_into_three_palindromic_parts("abcbdd") == "YES" >>> can_partition_into_three_palindromic_parts("abcd") == "...
def is_palindrome(sub): return sub == sub[::-1] def can_partition_into_three_palindromic_parts(s): n = len(s) for i in range(1, n - 1): for j in range(i + 1, n): if is_palindrome(s[:i]) and is_palindrome(s[i:j]) and is_palindrome(s[j:]): return "YES" return "NO"
from solution import can_partition_into_three_palindromic_parts def test_example_1(): assert can_partition_into_three_palindromic_parts("abcbdd") == "YES" def test_example_2(): assert can_partition_into_three_palindromic_parts("abcd") == "NO" def test_example_3(): assert can_partition_into_three_palindro...
[ { "docstring": null, "function_declaration": "def is_palindrome(sub):", "function_name": "is_palindrome", "parameter_list": "(sub)" }, { "docstring": null, "function_declaration": "def can_partition_into_three_palindromic_parts(s):", "function_name": "can_partition_into_three_palindr...
[ 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_palindrome(s):\n \"\"\"\n Helper function to determine if a given string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef can_partition_...
trial_gpt4o_2
{ "original_instruction": "You are given a string s and you need to determine if it is possible to partition the string into three non-empty parts such that each part is a palindrome.\n\n-----Input-----\n\nThe input contains a single string s (1 ≤ |s| ≤ 5000) consisting of lowercase English letters.\n\n-----Output---...
0.676284
Taco_88462
C
[ "is_palindrome", "can_partition_into_three_palindromic_parts" ]
2
[ [ "can_partition_into_three_palindromic_parts", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d2d8aabc98884cc69cc91249b9fc646f7ac0b963
1439214d85a0ca63dd82620aff64464c72d7d36b
v1.0
complete
Taco
Taco_87625_C
from typing import List, Tuple def can_robots_reach_goals(M: int, N: int, Ax: int, Ay: int, Bx: int, By: int, Gx1: int, Gy1: int, Gx2: int, Gy2: int, grid: List[str]) -> str: """ Determines if both robots, Alice and Bob, can reach their respective goals without colliding. Args: M (int): number of rows in t...
from collections import deque def is_valid_move(x, y, grid, M, N): return 0 <= x < M and 0 <= y < N and grid[x][y] == '.' def bfs(grid, M, N, start, goal): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] queue = deque([(start[0], start[1], 0)]) visited = set((start[0], start[1])) while queue: ...
def test_can_robots_reach_goals(): # Test case 1 M, N = 4, 4 Ax, Ay = 0, 0 Bx, By = 3, 3 Gx1, Gy1 = 3, 0 Gx2, Gy2 = 0, 3 grid = [ "..#.", "..#.", ".#..", "..#." ] assert can_robots_reach_goals(M, N, Ax, Ay, Bx, By, Gx1, Gy1, Gx2, Gy2, grid) == "YES" ...
[ { "docstring": null, "function_declaration": "def is_valid_move(x, y, grid, M, N):", "function_name": "is_valid_move", "parameter_list": "(x, y, grid, M, N)" }, { "docstring": null, "function_declaration": "def bfs(grid, M, N, start, goal):", "function_name": "bfs", "parameter_li...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_valid(x, y, M, N, grid):\n return 0 <= x < M and 0 <= y < N and grid[x][y] == '.'\n\ndef bfs(start, goal, M, N, grid):\n...
trial_gpt4o_1
{ "original_instruction": "Two robots, Alice and Bob, are placed on a two-dimensional grid. The grid has dimensions MxN. Alice and Bob can both move up, down, left, or right, but they can't move into cells occupied by obstacles. Alice and Bob start from their initial positions and try to reach their respective goal p...
0.639147
Taco_87625
C
[ "is_valid_move", "bfs", "can_robots_reach_goals", "solve" ]
4
[ [ "bfs", "is_valid_move" ], [ "can_robots_reach_goals", "bfs" ], [ "solve", "can_robots_reach_goals" ] ]
3
[]
false
[]
false
pytest
false
[]
true
bafdaa2709c2676544fa2bb2b38cb3c85d2f56ca
6255bd50e838aebad420ca7c8ae0d9e904c9486c
v1.0
complete
Taco
Taco_88298_C
import math from typing import List, Tuple def euclidean_distance(x1: int, y1: int, x2: int, y2: int) -> float: """Calculate the Euclidean distance between two points (x1, y1) and (x2, y2). >>> euclidean_distance(1, 1, 1, 2) 1.0 >>> euclidean_distance(2, 3, 2, 4) 1.0 >>> euclidean_distance(3, 3...
import math def euclidean_distance(x1, y1, x2, y2): return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) def calculate_max_connection_value(n, m, segments): total_connection_value = 0 for i in range(m): x1, y1, x2, y2 = segments[i] total_connection_value += euclidean_distance(x1, y1, x2, y2) ...
import math from solution import calculate_max_connection_value, euclidean_distance def test_euclidean_distance(): assert math.isclose(euclidean_distance(1, 1, 1, 2), 1.0, rel_tol=1e-9) assert math.isclose(euclidean_distance(2, 3, 2, 4), 1.0, rel_tol=1e-9) assert math.isclose(euclidean_distance(3, 3, 4, 3)...
[ { "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 calculate_max_connection_value(n, m, segments):", "function_name": ...
[ 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.125
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_distance(x1, y1, x2, y2):\n \"\"\"\n Calculate the Euclidean distance between two points (x1, y1) and (...
trial_gpt4o_8
{ "original_instruction": "Driveway is a simple strategic game involving placing segments on a grid and achieving the maximum connection value. The game is played on an n x n grid where you can place segments horizontally or vertically. Each segment has a length of 1 and a weight of 1. Positions are identified by coo...
0.61956
Taco_88298
C
[ "euclidean_distance", "calculate_max_connection_value" ]
2
[ [ "calculate_max_connection_value", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
25c95dde130e53eaaec25241ed4f11ceae8a0899
1fd427742b1243611548fcc33b1ee2aa0d4b5632
v1.0
complete
Taco
Taco_88510_C
def maximalRectangle(matrix): """ Find the area of the largest rectangle containing only 1s in a given binary matrix. >>> maximalRectangle([ ... [1, 0, 1, 0, 0], ... [1, 0, 1, 1, 1], ... [1, 1, 1, 1, 1], ... [1, 0, 0, 1, 0] ... ]) 6 >>> maximalRectangle([ ... ...
def maximalRectangle(matrix): if not matrix: return 0 max_area = 0 rows, cols = len(matrix), len(matrix[0]) heights = [0] * cols for row in matrix: for i in range(cols): heights[i] = heights[i] + 1 if row[i] == 1 else 0 max_area = max(max_area, larg...
from solution import maximalRectangle def test_maximalRectangle_example1(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert maximalRectangle(matrix) == 6 def test_maximalRectangle_example2(): matrix = [ [0, 1, 0], [...
[ { "docstring": null, "function_declaration": "def maximalRectangle(matrix):", "function_name": "maximalRectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largestRectangleArea(heights):", "function_name": "largestRectangleArea", "paramete...
[ 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 maximalRectangle(matrix):\n if not matrix:\n return 0\n\n max_area = 0\n rows, cols = len(matrix), len(matrix[0])\n heights = [0] * cols\n\n...
trial_gpt4o_0
{ "original_instruction": "Dexter is playing a new game for coding practice. The game consists of a series of challenges where he needs to determine the largest rectangular submatrix, within a given binary matrix, that has all 1s. A binary matrix is a matrix where each element is either 0 or 1.\n\nDexter wants to wri...
0.678521
Taco_88510
C
[ "maximalRectangle", "largestRectangleArea" ]
2
[ [ "maximalRectangle", "largestRectangleArea" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86e9160586e191b4e37a10c466fc7cfb42cbe86d
f652f7537413dcd24c41a20ccbd61762a47a1c62
v1.0
complete
Taco
Taco_88555_C
def probability_equal_zeros_ones(dna1: str, dna2: str) -> str: """ Calculate the probability that the offspring of two Trivellea plants will have a DNA string with an equal number of 0s and 1s. Arguments: dna1 -- binary DNA string of the first parent plant dna2 -- binary DNA string of the seco...
def calculate_xor_dna(dna1, dna2): """ Helper function to calculate the XOR DNA string from two binary DNA strings. """ return ''.join(str(int(b1) ^ int(b2)) for b1, b2 in zip(dna1, dna2)) def probability_equal_zeros_ones(dna1, dna2): """ Calculate the probability that the offspring of two Triv...
from solution import probability_equal_zeros_ones def test_odd_length_dna(): assert probability_equal_zeros_ones("101", "010") == "0.00000" def test_equal_zeros_ones(): assert probability_equal_zeros_ones("1100", "1010") == "1.00000" assert probability_equal_zeros_ones("1111", "0000") == "0.00000" def te...
[ { "docstring": "Helper function to calculate the XOR DNA string from two binary DNA strings.", "function_declaration": "def calculate_xor_dna(dna1, dna2):", "function_name": "calculate_xor_dna", "parameter_list": "(dna1, dna2)" }, { "docstring": "Calculate the probability that the offspring ...
[ 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 probability_of_equal_0s_1s(parent1, parent2):\n \"\"\"\n Returns the probability of producing an offspring with an equal number of 0s and 1s.\n \"\"\"...
trial_gpt4o_9
{ "original_instruction": "In a galaxy far, far away, there exists a unique species of flowering plants called Trivelleas. Each Trivellea plant has a binary DNA string of length n. The binary DNA string determines the color of the plant. Two Trivellea plants can be cross-pollinated to produce a new offspring Trivelle...
0.534786
Taco_88555
C
[ "calculate_xor_dna", "probability_equal_zeros_ones" ]
2
[ [ "probability_equal_zeros_ones", "calculate_xor_dna" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5aa85916561f7ed241983f34c8e28fa7fc7040e
c42c1cf7d7042f63778798dbd51e719191538f58
v1.0
complete
Taco
Taco_88381_C
def find_pairs_with_difference_k(nums, k): """ Determines if there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is equal to k. Examples: >>> find_pairs_with_difference_k([10, 15, 3, 7], 5) "YES" >>> find_pairs_with_differenc...
def find_pairs_with_difference_k(nums, k): """ Determines if there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is equal to k. """ num_set = set(nums) for num in nums: if (num + k) in num_set or (num - k) in num_set: ...
from solution import find_pairs_with_difference_k, solve, parse_input def test_find_pairs_with_difference_k(): assert find_pairs_with_difference_k([10, 15, 3, 7], 5) == "YES" assert find_pairs_with_difference_k([1, 2, 3, 4], 3) == "YES" assert find_pairs_with_difference_k([1, 5, 9, 14], 6) == "NO" asse...
[ { "docstring": "Determines if there are two distinct indices i and j in the array such that\nthe absolute difference between nums[i] and nums[j] is equal to k.", "function_declaration": "def find_pairs_with_difference_k(nums, k):", "function_name": "find_pairs_with_difference_k", "parameter_list": "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_pairs_with_difference(test_cases):\n results = []\n \n for k, array in test_cases:\n found = False\n num_set = set(array)\n ...
trial_gpt4o_2
{ "original_instruction": "India's prime minister has launched a new initiative to encourage students to study more mathematics. As part of this initiative, he introduced a coding competition. The problem to be solved is as follows:\n\nGiven an array of integers and an integer k, determine whether there are two disti...
0.682938
Taco_88381
C
[ "find_pairs_with_difference_k", "solve", "parse_input" ]
3
[ [ "solve", "find_pairs_with_difference_k" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
b501ebcf3143ca42271ffea03b3d563e05f6dd45
db3e6835fe3bb84042a61f8bd6c208f3a08a77ae
v1.0
complete
Taco
Taco_88491_C
def length_of_LIS(arr): """ Function to determine the length of the longest increasing subsequence. >>> length_of_LIS([10, 22, 9, 33, 21, 50, 41, 60]) 5 >>> length_of_LIS([3, 10, 2, 1, 20, 19]) 3 """ def longest_increasing_subsequence(test_cases): """ Function to process multiple test cases...
def length_of_LIS(arr): """ Function to determine the length of the longest increasing subsequence. """ if not arr: return 0 dp = [1] * len(arr) for i in range(1, len(arr)): for j in range(i): if arr[i] > arr[j]: dp[i] = max(dp[i], dp[j] + 1) ...
import pytest from solution import parse_input, longest_increasing_subsequence, length_of_LIS def test_length_of_LIS(): assert length_of_LIS([10, 22, 9, 33, 21, 50, 41, 60]) == 5 assert length_of_LIS([3, 10, 2, 1, 20, 19]) == 3 assert length_of_LIS([]) == 0 assert length_of_LIS([5]) == 1 assert len...
[ { "docstring": "Function to determine the length of the longest increasing subsequence.", "function_declaration": "def length_of_LIS(arr):", "function_name": "length_of_LIS", "parameter_list": "(arr)" }, { "docstring": "Function to process multiple test cases and return the results of longes...
[ 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 length_of_lis(cards):\n \"\"\"\n Calculates the length of the longest increasing subsequence in a list of cards.\n \n Args:\n cards (list of int...
trial_gpt4o_1
{ "original_instruction": "Zara is playing a card game where she makes sequences of cards placed in a row. The game allows only increasing sequences, where each card's number must be greater than the number of the previous card. Zara wants to know the length of the longest increasing subsequence she can make from a g...
0.646839
Taco_88491
C
[ "length_of_LIS", "longest_increasing_subsequence", "parse_input" ]
3
[ [ "longest_increasing_subsequence", "length_of_LIS" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
0b00906c1dc64f5818627f7cc76071c9586ef888
569eb867d752d9418f454a404525fb4806408d96
v1.0
complete
Taco
Taco_88474_C
def three_sum_exists(nums, target): """ This function checks whether there exists any trio of numbers within the array that add up to the target. Parameters: nums (list): A list of integers. target (int): The target sum. Returns: str: "YES" if there exists such a trio, otherwise "...
def three_sum_exists(nums, target): """ This function checks whether there exists any trio of numbers within the array that add up to the target. Parameters: nums (list): A list of integers. target (int): The target sum. Returns: str: "YES" if there exists such a trio, otherwise "N...
from solution import three_sum_exists def test_sample_input_1(): assert three_sum_exists([1, 2, 3, 4, 5, 6], 10) == "YES" def test_sample_input_2(): assert three_sum_exists([1, 2, 3, 7, 8], 20) == "NO" def test_no_possible_trio(): assert three_sum_exists([1, 1, 1, 1], 10) == "NO" def test_all_negative_n...
[ { "docstring": "This function checks whether there exists any trio of numbers within the array that add up to the target.\n\nParameters:\nnums (list): A list of integers.\ntarget (int): The target sum.\n\nReturns:\nstr: \"YES\" if there exists such a trio, otherwise \"NO\".", "function_declaration": "def th...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_trio_with_sum(arr, target):\n \"\"\"\n Checks if there exists a trio in the array that sums to the target value.\n\n Args:\n arr: List[int], t...
trial_gpt4o_2
{ "original_instruction": "You are given an array of integers. You are required to find out if any three distinct elements in the array sum up to a given target number.\n\nWrite a function that checks if there exists any trio of numbers within the array that add up to the target.\n\n------ Input Format ------\n- The ...
0.686988
Taco_88474
C
[ "three_sum_exists", "trio_sum_solver" ]
2
[ [ "trio_sum_solver", "three_sum_exists" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83d4a3672f8e84cd9aaa97fb6c8886d12c39a29b
1ea5843caf3445eab6d994b1437c9b82384646a8
v1.0
complete
Taco
Taco_88569_C
def is_balanced(sequence: str) -> str: """ Check if the given sequence of brackets is balanced. :param sequence: String containing the sequence of brackets. :return: 'YES' if the sequence is balanced, 'NO' otherwise. >>> is_balanced("()") 'YES' >>> is_balanced("([])") 'YES' >>> is_...
def is_balanced(sequence): """ Check if the given sequence of brackets is balanced. :param sequence: String containing the sequence of brackets. :return: 'YES' if the sequence is balanced, 'NO' otherwise. """ bracket_map = {')': '(', ']': '[', '}': '{'} open_brackets = {'(', '[', '{'} s...
from solution import evaluate_sequences, is_balanced def test_is_balanced(): assert is_balanced("()") == 'YES' assert is_balanced("([])") == 'YES' assert is_balanced("{[()()]}") == 'YES' assert is_balanced("(") == 'NO' assert is_balanced("([)]") == 'NO' assert is_balanced("{[(])}") == 'NO' ...
[ { "docstring": "Check if the given sequence of brackets is balanced.\n\n:param sequence: String containing the sequence of brackets.\n:return: 'YES' if the sequence is balanced, 'NO' otherwise.", "function_declaration": "def is_balanced(sequence):", "function_name": "is_balanced", "parameter_list": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_balanced(sequence):\n stack = []\n matching_bracket = {')': '(', ']': '[', '}': '{'}\n\n for char in sequence:\n if char in matching_bracket...
trial_gpt4o_2
{ "original_instruction": "Write a program that evaluates whether a series of brackets is correctly balanced. A correctly balanced sequence of brackets is one in which every opening bracket of a given type has a matching closing bracket of the same type, in the correct order.\n\nThere are three types of brackets to b...
0.682422
Taco_88569
C
[ "is_balanced", "evaluate_sequences" ]
2
[ [ "evaluate_sequences", "is_balanced" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a9b7d026e101f25606ccd41983347ab7c561ffa
86006cfe5d7fed75d57ec1ee252f18e15c6b0f93
v1.0
complete
Taco
Taco_88718_C
def shift_sentence(sentence: str) -> str: """ Replace each character in the sentence with its succeeding character in the alphabet. If the character is 'z' or 'Z', it should wrap around to 'a' or 'A', respectively. Maintain the case of the original character and avoid altering spaces and punctuation. ...
def shift_char(c): if 'a' <= c <= 'y' or 'A' <= c <= 'Y': return chr(ord(c) + 1) elif c == 'z': return 'a' elif c == 'Z': return 'A' else: return c def shift_sentence(sentence): return ''.join(shift_char(c) for c in sentence)
from solution import shift_sentence def test_single_lowercase_letter(): assert shift_sentence("a") == "b" assert shift_sentence("m") == "n" def test_single_uppercase_letter(): assert shift_sentence("A") == "B" assert shift_sentence("M") == "N" def test_wrap_around_lowercase(): assert shift_senten...
[ { "docstring": null, "function_declaration": "def shift_char(c):", "function_name": "shift_char", "parameter_list": "(c)" }, { "docstring": null, "function_declaration": "def shift_sentence(sentence):", "function_name": "shift_sentence", "parameter_list": "(sentence)" } ]
[ 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 shift_characters(sentence):\n def shift_char(c):\n if 'a' <= c <= 'z':\n return chr((ord(c) - ord('a') + 1) % 26 + ord('a'))\n elif...
trial_gpt4o_2
{ "original_instruction": "You are given a sentence in the form of a string. Write a function to replace each character in the sentence with its succeeding character in the alphabet. If the character is 'z' or 'Z', it should wrap around to 'a' or 'A', respectively. Maintain the case of the original character and avoi...
0.589036
Taco_88718
C
[ "shift_char", "shift_sentence" ]
2
[ [ "shift_sentence", "shift_char" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5ee82b87f16b1a27601fd60bd344577db72dd933
5bebae2e9840b4c585aabd8a6490f7c2cc3559a9
v1.0
complete
Taco
Taco_88622_C
def knapsack(W, n, items): """ Solves the 0/1 Knapsack problem for optimizing warehouse inventory. W: Integer, capacity of the warehouse. n: Integer, number of different types of items. items: List of tuples [(wi, vi), ..., (wn, vn)], where wi is the weight and vi is the value. >>> knapsack(50,...
def knapsack(W, n, items): """ Solves the 0/1 Knapsack problem. W: Integer, capacity of the warehouse. n: Integer, number of different types of items. items: List of tuples [(wi, vi), ..., (wn, vn)] """ dp = [0] * (W + 1) for weight, value in items: for j in range(W, weight ...
from solution import knapsack, process_warehouse_data def test_knapsack(): assert knapsack(50, 3, [(10, 60), (20, 100), (30, 120)]) == 220 assert knapsack(100, 2, [(50, 200), (50, 300)]) == 500 assert knapsack(10, 1, [(10, 100)]) == 100 assert knapsack(10, 1, [(11, 100)]) == 0 assert knapsack(15, 3...
[ { "docstring": "Solves the 0/1 Knapsack problem.\nW: Integer, capacity of the warehouse.\nn: Integer, number of different types of items.\nitems: List of tuples [(wi, vi), ..., (wn, vn)]", "function_declaration": "def knapsack(W, n, items):", "function_name": "knapsack", "parameter_list": "(W, n, it...
[ 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 knapsack(W, items):\n \"\"\"\n Function to find the maximum value of items that can be stored in a warehouse with given capacity.\n \n Parameters:\...
trial_gpt4o_3
{ "original_instruction": "You are in charge of optimizing the inventory for a warehouse. The warehouse has a limited capacity, and you need to determine the optimal way to store different types of items to maximize the total value of the inventory. Each type of item has a specific weight and value, and you cannot st...
0.578694
Taco_88622
C
[ "knapsack", "process_warehouse_data" ]
2
[ [ "process_warehouse_data", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2b3853059796b6cbb6e6b3eb7ac7df3b2ca14254
7fd7721f4327c56818b7ff508466f1f7712d4449
v1.0
complete
Taco
Taco_88696_C
from typing import List def is_prime(n: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True """ # Solution code here def any_prime_permutation(num: int) -> str: """Check if any permu...
from itertools import permutations def is_prime(n): """Check if a number is a prime number.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return Tru...
from solution import is_prime, any_prime_permutation, process_test_cases def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(11) == True assert is_prime(25) == False def test_any_prime_permutation(): ...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Check if any permutation of the digits of num is a prime number.", "function_declaration": "def any_prime_permutation...
[ 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 permutations\n\ndef is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= ...
trial_gpt4o_2
{ "original_instruction": "Problem:\n\nNina loves playing with numbers, especially prime numbers. One day, she decided to play a game where she picks any number and checks if any arrangement of its digits is a prime number.\n\nInput:\n\nThe first line contains an integer T, the number of test cases. The next T lines ...
0.704421
Taco_88696
C
[ "is_prime", "any_prime_permutation", "process_test_cases" ]
3
[ [ "any_prime_permutation", "is_prime" ], [ "process_test_cases", "any_prime_permutation" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
11fa9aeb48e9df0a061de8319fc54a655eb96a33
39b6c83e7edca97857b044c8a645832777ebed18
v1.0
complete
Taco
Taco_88647_C
def find_triplet_sum(array: List[int], target: int) -> bool: """ Determine whether there are three distinct integers in the array that add up to the target sum. >>> find_triplet_sum([-1, 2, 1, -4, 2], 0) True >>> find_triplet_sum([1, 2, 3, 4, 5], 50) False >>> find_triplet_sum([-5,...
def find_triplet_sum(array, target): """ Determine whether there are three distinct integers in the array that add up to the target sum. Returns: bool: True if such a triplet exists, else False. """ array.sort() N = len(array) for i in range(N - 2): left = i + 1 ...
from solution import find_triplet_sum def test_find_triplet_sum_exists(): array = [-1, 2, 1, -4, 2] target = 0 assert find_triplet_sum(array, target) == True def test_find_triplet_sum_not_exists(): array = [1, 2, 3, 4, 5] target = 50 assert find_triplet_sum(array, target) == False def test_al...
[ { "docstring": "Determine whether there are three distinct integers in the array \nthat add up to the target sum.\n\nReturns:\n bool: True if such a triplet exists, else False.", "function_declaration": "def find_triplet_sum(array, target):", "function_name": "find_triplet_sum", "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 has_triplet_sum(arr, target):\n \"\"\"\n Determines whether there are three distinct integers in the array that add up to the target sum.\n\n :param a...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers, and a target sum, determine whether there are three distinct integers in the array that add up to the target sum. You need to return a boolean indicating the presence of such a triplet.\n\nInput\nThe first line contains 2 integers N and target denoting the number...
0.797866
Taco_88647
C
[ "find_triplet_sum", "solve" ]
2
[ [ "solve", "find_triplet_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
629c2dc88c5f74258ab5d5bc15595ddd4042f147
3ef34d7035409de3d323f8d1e0be62e857699c60
v1.0
complete
Taco
Taco_88708_C
def distinct_substrings_count(s): """ Returns the number of distinct substrings in the given string s. """ pass def malfunction_check(t, limits_and_strings): """ Returns a list of results ("NO MALFUNCTION" or "MALFUNCTION") for each test case. Args: - t (int): number of test cases ...
def distinct_substrings_count(s): """ Returns the number of distinct substrings in the given string s. """ n = len(s) substrings = set() for i in range(n): for j in range(i + 1, n + 1): substrings.add(s[i:j]) return len(substrings) def malfunction_check(t, limits_and_str...
from solution import malfunction_check def test_malfunction_check_no_malfunction(): assert malfunction_check(1, [(10, "abc")]) == ["NO MALFUNCTION"] def test_malfunction_check_malfunction(): assert malfunction_check(1, [(5, "ababa")]) == ["MALFUNCTION"] def test_malfunction_check_multiple_cases(): assert...
[ { "docstring": "Returns the number of distinct substrings in the given string s.", "function_declaration": "def distinct_substrings_count(s):", "function_name": "distinct_substrings_count", "parameter_list": "(s)" }, { "docstring": "Returns a list of results (\"NO MALFUNCTION\" or \"MALFUNCT...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_distinct_substrings(s):\n \"\"\"\n Function to count the number of distinct substrings in a string.\n \"\"\"\n n = len(s)\n substrings = s...
trial_gpt4o_2
{ "original_instruction": "The resistance group has captured an alien device which is able to analyze patterns in strings. They have discovered that the device can identify distinct substrings within a given string. However, the device starts to malfunction if there are too many distinct substrings to analyze. For a ...
0.703449
Taco_88708
C
[ "distinct_substrings_count", "malfunction_check" ]
2
[ [ "malfunction_check", "distinct_substrings_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
01022984d25ea6996744be0fd0172c86c874278d
c0ad0822751a4e19b06fe072d57df4fa5f51268a
v1.0
complete
Taco
Taco_88916_C
def nextPrime(N: int) -> int: """ Returns the smallest prime number greater than N. >>> nextPrime(10) 11 >>> nextPrime(17) 19 >>> nextPrime(1) 2 >>> nextPrime(23) 29 >>> nextPrime(1000000) 1000003 """
import math def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def nextPrime(N):...
from solution import nextPrime def test_next_prime_after_10(): assert nextPrime(10) == 11 def test_next_prime_after_17(): assert nextPrime(17) == 19 def test_next_prime_after_1(): assert nextPrime(1) == 2 def test_next_prime_after_23(): assert nextPrime(23) == 29 def test_next_prime_after_1000000()...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the smallest prime number greater than N.", "function_declaration": "def nextPrime(N):", "function_name": "nextPrime", "parameter_l...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num < 2:\n return False\n if num in (2, 3):\n ...
trial_gpt4o_2
{ "original_instruction": "Given a positive integer N, the task is to find the smallest prime number greater than N.\n\nExample 1:\nInput:\nN = 10\nOutput:\n11\nExplanation:\nThe smallest prime number greater than 10 is 11.\n\nExample 2:\nInput:\nN = 17\nOutput:\n19\nExplanation:\nThe smallest prime number greater th...
0.751075
Taco_88916
C
[ "is_prime", "nextPrime" ]
2
[ [ "nextPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
afb1d375f382d676b8531e834f5131f417f82e58
df394e616f19c8275a5fd1515cf2bbb3c5209702
v1.0
complete
Taco
Taco_88564_C
def find_path(grid: List[List[int]]) -> int: """ Given a grid of 0s and 1s, determines if there is a path from the top row to the bottom row using only cells containing 1. Movement can be horizontal, vertical, or diagonal. >>> find_path([ ... [1, 0, 0, 1, 0], ... [1, 1, 0, 0, 0], .....
def find_path(grid): """ Given a grid of 0s and 1s, determines if there is a path from the top row to the bottom row using only cells containing 1. Movement can be horizontal, vertical, or diagonal. """ R = len(grid) C = len(grid[0]) def dfs(x, y, visited): if x == R - 1: # Rea...
def test_find_path_exists(): R, C = 5, 5 flat_grid = [ 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1 ] assert solution(R, C, flat_grid) == 1 def test_find_path_does_not_exist(): R, C = 5, 5 flat_grid = [ 1, 0, 0, 0, 0, ...
[ { "docstring": "Given a grid of 0s and 1s, determines if there is a path from the top row to the bottom row\nusing only cells containing 1. Movement can be horizontal, vertical, or diagonal.", "function_declaration": "def find_path(grid):", "function_name": "find_path", "parameter_list": "(grid)" ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_reach_bottom(R, C, grid):\n def dfs(r, c, visited):\n if r == R - 1:\n return True\n visited.add((r, c))\n directions = ...
trial_gpt4o_2
{ "original_instruction": "Alice is an avid gardener, and she has a peculiar way of arranging her garden. She plants flowers in a rectangular grid, where each cell can either be empty or have a flower. \n\nShe wants to determine if there is a path that starts from any cell in the top row and ends at any cell in the b...
0.693625
Taco_88564
C
[ "find_path", "solution" ]
2
[ [ "solution", "find_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
888f5d910dc3c65b98fedda33a9c83a604b6c7ce
ee4dfe38ff008f2bcc8e6a881ef08b084d30d19f
v1.0
complete
Taco
Taco_88512_C
def first_unique_integer(test_cases): """ For each test case, returns the first unique integer in the list of integers. If no unique integer is found, returns -1. >>> first_unique_integer([[4, 5, 1, 2, 5, 1, 4, 3], [1, 2, 2, 1, 3, 4, 3, 3], [7, 7, 7, 6, 6, 6, 5, 5, 5], [9]]) [2, 4, -1, 9] >>> f...
def first_unique_integer(test_cases): """ For each test case, returns the first unique integer in the list of integers. If no unique integer is found, returns -1. """ results = [] for case in test_cases: count = {} for num in case: if num in count: ...
from solution import find_first_unique_integers, first_unique_integer def test_find_first_unique_integers(): assert find_first_unique_integers(4, [ [4, 5, 1, 2, 5, 1, 4, 3], [1, 2, 2, 1, 3, 4, 3, 3], [7, 7, 7, 6, 6, 6, 5, 5, 5], [9] ]) == [2, 4, -1, 9] assert find_first_...
[ { "docstring": "For each test case, returns the first unique integer in the list of integers.\nIf no unique integer is found, returns -1.", "function_declaration": "def first_unique_integer(test_cases):", "function_name": "first_unique_integer", "parameter_list": "(test_cases)" }, { "docstri...
[ 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 first_unique_integer(lst):\n \"\"\"\n Given a list of integers, returns the first unique integer.\n If there is no unique integer, returns -1.\n \"...
trial_gpt4o_2
{ "original_instruction": "In a given list of integers, you need to identify the first unique integer (an integer that appears exactly once in the list).\n\n------ Input: ------\n\nFirst line contains a single integer T, the number of test cases.\n\nEach of the next T lines contains a list of space-separated integers...
0.643796
Taco_88512
C
[ "first_unique_integer", "find_first_unique_integers" ]
2
[ [ "find_first_unique_integers", "first_unique_integer" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc66f214a7834c68de2fcc3dbebae84ce06d327a
f0694eb7c492cf5a0e9e046b0a4fbcf2254c9d7a
v1.0
complete
Taco
Taco_88971_C
def minimum_highway_length(n: int, highways: List[Tuple[int, int, int]]) -> int: """ Determine the minimum length of new highways required to ensure all towns are connected. >>> minimum_highway_length(4, [(1, 2, 3), (3, 4, 5)]) == 8 >>> minimum_highway_length(4, [(1, 2, 3), (2, 3, 4), (3, 4, 5)]) == 0 "...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) # Path compression 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[r...
from solution import minimum_highway_length def test_no_highways(): assert minimum_highway_length(4, []) == 0 def test_some_highways(): assert minimum_highway_length(4, [(1, 2, 3), (3, 4, 5)]) == 8 def test_already_connected(): assert minimum_highway_length(4, [(1, 2, 3), (2, 3, 4), (3, 4, 5)]) == 0 ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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 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_7
{ "original_instruction": "In a land far away, there exist towns connected by highways. The king of this land has decreed that all citizens must be able to travel between any two towns. To achieve this, he plans to build some additional highways. Each highway connects exactly two towns and has a unique length. The ob...
0.709853
Taco_88971
C
[ "find", "union", "minimum_highway_length", "main" ]
4
[ [ "minimum_highway_length", "find" ], [ "minimum_highway_length", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
d3113f0a2a2f6a3019fad03ec7f4e9e92da8e4ee
df7f313e8f03da737649ed2659afd0117c02ebea
v1.0
complete
Taco
Taco_88997_C
def is_prime(num: int) -> bool: """ Helper function to determine if a number is a prime. """ # Implementation here def sum_of_primes(n: int) -> int: """ Returns the sum of all prime numbers below the given positive integer n. Examples: >>> sum_of_primes(10) 17 >>> sum_of_pr...
def is_prime(num): """ Helper function to determine if a number is a prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while (i * i) <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import sum_of_primes def test_sum_of_primes_below_10(): assert sum_of_primes(10) == 17 def test_sum_of_primes_below_20(): assert sum_of_primes(20) == 77 def test_sum_of_primes_below_2(): assert sum_of_primes(2) == 0 def test_sum_of_primes_below_1(): assert sum_of_primes(1) == 0 def te...
[ { "docstring": "Helper function to determine if a number is a prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers below the given positive integer n.", "function_declaration"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is a prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "# Sum of Primes\n\nCreate a function that finds the sum of all prime numbers below a given positive integer `n`. Recall that a prime number is a number greater than 1 that has no positive divisors other than 1 and itself.\n\nThe function should return the sum as an integer.\n\n## Example\n\...
0.757368
Taco_88997
C
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b5e70a01c051858d1ee0fe007a7c9ad2a1aea7c7
eaaf24afc132840f8c53454f1dd2d8e67d9cfa31
v1.0
complete
Taco
Taco_89154_C
def minimal_spanning_tree(N: int, roads: List[Tuple[int, int, int]]) -> int: """ Finds the minimal sum of all road lengths forming a fully connected network. Args: N (int): Number of intersections. roads (List[Tuple[int, int, int]]): List of roads where each tuple is (u, v, L). Return...
def minimal_spanning_tree(N, roads): """ Finds the minimal sum of all road lengths forming a fully connected network. Args: N (int): Number of intersections. roads (list of tuples): List of roads where each tuple is (u, v, L). Returns: int: Minimal sum of road lengths in the spanni...
def test_minimal_spanning_tree(): # Test case 1 N = 4 roads = [(1, 2, 1), (1, 3, 3), (2, 3, 1), (3, 4, 1), (4, 1, 6)] assert minimal_spanning_tree(N, roads) == 3 # Test case 2 N = 3 roads = [(1, 2, 1), (2, 3, 3), (1, 3, 4)] assert minimal_spanning_tree(N, roads) == 4 # Test...
[ { "docstring": "Finds the minimal sum of all road lengths forming a fully connected network.\n\nArgs:\nN (int): Number of intersections.\nroads (list of tuples): List of roads where each tuple is (u, v, L).\n\nReturns:\nint: Minimal sum of road lengths in the spanning tree.", "function_declaration": "def mi...
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_minimal_road_network(N, M, roads):\n \"\"\"\n Find the minimal sum of all road lengths forming a fully connected network (a spanning tree).\n \n ...
trial_gpt4o_8
{ "original_instruction": "In a small town, there exists a network of N intersections connected by bidirectional roads. The town council has a problem; they want to determine whether it is possible to remove some roads such that the road network remains fully connected, but the number and length of the roads are mini...
0.668507
Taco_89154
C
[ "minimal_spanning_tree", "run_solution" ]
2
[ [ "run_solution", "minimal_spanning_tree" ] ]
1
[]
false
[]
false
pytest
false
[]
true
4cbb968444a2d013422400ca141c020f09148d0b
2f5b7a1bc53234b95e2c305756fa64d21d09a1b0
v1.0
complete
Taco
Taco_88914_C
def solve(t: int, test_cases: List[Tuple[int, int, List[Tuple[int, int, int]], int, List[Tuple[int, int]]]]) -> List[List[int]]: """ Calculate the shortest guaranteed path for each given query in multiple test cases. >>> solve(1, [(5, 6, [(1, 2, 10), (1, 3, 3), (2, 3, 1), (2, 4, 2), (3, 5, 6), (4, 5, 7)], 3, [(...
import heapq def dijkstra_shortest_path(n, graph, start, end): distances = {node: float('inf') for node in range(1, n + 1)} distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) if current_di...
from solution import solve def test_single_case(): t = 1 test_cases = [ ( 5, 6, [ (1, 2, 10), (1, 3, 3), (2, 3, 1), (2, 4, 2), (3, 5, 6), (4, 5, 7) ], 3, ...
[ { "docstring": null, "function_declaration": "def dijkstra_shortest_path(n, graph, start, end):", "function_name": "dijkstra_shortest_path", "parameter_list": "(n, graph, start, end)" }, { "docstring": null, "function_declaration": "def process_queries(n, edges, queries):", "function...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, src, n):\n dist = [float('inf')] * n\n dist[src] = 0\n min_heap = [(0, src)]\n \n while min_heap:\n curre...
trial_gpt4o_4
{ "original_instruction": "Alice loves solving problems using graphs. She has recently encountered an interesting problem where she needs to find the shortest path in a weighted, undirected graph. However, the graph has a special property: every edge can disappear at any given moment. \n\nDue to this, Alice wants to ...
0.650037
Taco_88914
C
[ "dijkstra_shortest_path", "process_queries", "solve" ]
3
[ [ "process_queries", "dijkstra_shortest_path" ], [ "solve", "process_queries" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
3bd9675ef8d11aa63a845a9e7d4efed5f54c830d
f5dfb3417ba52c459c74fa8ea2a2612308d23be6
v1.0
complete
Taco
Taco_89249_C
def isSumOfPrimesPrime(N: int) -> str: """ Given a number N, generate all the prime numbers less than or equal to N and check whether the sum of these prime numbers is also a prime number. >>> isSumOfPrimesPrime(10) "Yes" >>> isSumOfPrimesPrime(20) "No" >>> isSumOfPrimesPrime(2) "Yes" >>...
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 isSumOfPrime...
from solution import isSumOfPrimesPrime def test_example_1(): assert isSumOfPrimesPrime(10) == "Yes" def test_example_2(): assert isSumOfPrimesPrime(20) == "No" def test_small_prime(): assert isSumOfPrimesPrime(2) == "Yes" def test_small_non_prime(): assert isSumOfPrimesPrime(4) == "Yes" def test_l...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def isSumOfPrimesPrime(N):", "function_name": "isSumOfPrimesPrime", "parameter_list": "(N)" } ]
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True...
trial_gpt4o_3
{ "original_instruction": "Given a number N, you need to generate all the prime numbers less than or equal to N and check whether the sum of these prime numbers is also a prime number.\n\nExample 1:\nInput: N = 10\nOutput: \"No\"\nExplanation: The prime numbers <= 10 are [2, 3, 5, 7]. Their sum is 2+3+5+7 = 17, which...
0.760187
Taco_89249
C
[ "is_prime", "isSumOfPrimesPrime" ]
2
[ [ "isSumOfPrimesPrime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2b5c9915f7c20c6b53f2bb9450849f03aa71603
a95b953c033ade3eb16aafd1e2239f050cc2469a
v1.0
complete
Taco
Taco_89177_C
def longestPowerOf2Subseq(arr: List[int]) -> int: """ Find the length of the longest subsequence such that every element in the subsequence is an increasing power of 2 sequence. >>> longestPowerOf2Subseq([3, 10, 4, 8, 16, 20]) 3 >>> longestPowerOf2Subseq([1, 2, 4, 8, 3, 6, 12]) 4 """
def is_power_of_2(x): """ Helper function to check if a number is a power of 2. """ return (x != 0) and (x & (x - 1)) == 0 def longestPowerOf2Subseq(arr): """ Finds the length of the longest subsequence such that every element in the subsequence is an increasing power of 2 sequence. """ pow...
from solution import longestPowerOf2Subseq def test_longestPowerOf2Subseq_example1(): assert longestPowerOf2Subseq([3, 10, 4, 8, 16, 20]) == 3 def test_longestPowerOf2Subseq_example2(): assert longestPowerOf2Subseq([1, 2, 4, 8, 3, 6, 12]) == 4 def test_longestPowerOf2Subseq_no_powers_of_2(): assert longe...
[ { "docstring": "Helper function to check if a number is a power of 2. ", "function_declaration": "def is_power_of_2(x):", "function_name": "is_power_of_2", "parameter_list": "(x)" }, { "docstring": "Finds the length of the longest subsequence such that every element\nin the subsequence is an...
[ 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 longestPowerOf2Subseq(nums):\n def is_power_of_2(x):\n return (x & (x - 1)) == 0 and x > 0\n\n powers_of_2 = sorted([num for num in nums if is_pow...
trial_gpt4o_4
{ "original_instruction": "Given a list of integers, you are required to find out the length of the longest subsequence such that every element in the subsequence is an increasing power of 2 sequence.\n\nExample 1:\nInput: [3, 10, 4, 8, 16, 20]\nOutput: 3\nExplanation:\nThe longest subsequence that forms an increasin...
0.643441
Taco_89177
C
[ "is_power_of_2", "longestPowerOf2Subseq" ]
2
[ [ "longestPowerOf2Subseq", "is_power_of_2" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81b526bf2888690328dcc19a0f2c46848934a0fd
c53952601d481eb90fe951e783c9bca6fe80f781
v1.0
complete
Taco
Taco_89100_C
def longest_common_prefix(strs): """ Returns the longest common prefix of an array of strings. """ if not strs: return 0 # The shortest string will limit the comparison of the common prefix. min_length = min(len(s) for s in strs) for i in range(min_length): char = s...
def longest_common_prefix(strs): """ Returns the longest common prefix of an array of strings. """ if not strs: return 0 # The shortest string will limit the comparison of the common prefix. min_length = min(len(s) for s in strs) for i in range(min_length): char = s...
def test_longest_common_prefix(): assert longest_common_prefix(["spaghetti", "spanakopita", "spicy"]) == 2 assert longest_common_prefix(["pizza", "pizzicato"]) == 4 assert longest_common_prefix(["applepie", "applejuice", "applecrumble", "appletart"]) == 5 assert longest_common_prefix([""]) == 0 asse...
[ { "docstring": "Returns the longest common prefix of an array of strings.", "function_declaration": "def longest_common_prefix(strs):", "function_name": "longest_common_prefix", "parameter_list": "(strs)" }, { "docstring": null, "function_declaration": "def find_longest_common_prefix_len...
[ 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 longest_common_prefix_length(dishes):\n \"\"\"\n Finds the length of the longest common prefix among all the given dishes.\n \n Args:\n dishes (...
trial_gpt4o_3
{ "original_instruction": "Chef needs your help to analyze customer preferences in his restaurant. He is interested in finding out the most common prefix length of dishes that different customers order. For this problem, you are given an array of strings, where each string represents the name of a dish ordered by a c...
0.722656
Taco_89100
C
[ "longest_common_prefix", "find_longest_common_prefix_length", "process_input" ]
3
[ [ "find_longest_common_prefix_length", "longest_common_prefix" ], [ "process_input", "find_longest_common_prefix_length" ] ]
2
[ "process_input" ]
false
[]
false
pytest
false
[]
true
82fee6fc82d3bc2b2dfccbb20bae61f1c37b31fb
36ffc59178f2c4d63a7845d9eb0183e56a760c53
v1.0
complete
Taco
Taco_89468_C
from typing import List def check_prime_subarray(arr: List[int]) -> str: """ Derek loves puzzles involving prime numbers. Given an integer array `arr`, determine if there exists any subarray (contiguous part of the array) such that the sum of its elements is a prime number. A prime number is a number ...
from typing import List def is_prime(num: int) -> bool: """ Determines if a number is a prime number. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False p = 3 while p * p <= num: if num % p == 0: return False ...
from solution import check_prime_subarray def test_prime_subarray_exists(): assert check_prime_subarray([2, 3, -5, 5, 6]) == "YES" assert check_prime_subarray([5]) == "YES" assert check_prime_subarray([3, 7, 1, 2]) == "YES" def test_no_prime_subarray(): assert check_prime_subarray([4, 6, 8]) == "NO" ...
[ { "docstring": "Determines if a number is a prime number.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Checks if there exists any subarray whose sum is a prime number.", "function_declaration": "def check_prime_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\nimport math\n\ndef is_prime(num: int) -> bool:\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= ...
trial_gpt4o_2
{ "original_instruction": "Derek loves puzzles involving prime numbers. He recently came up with a new type of puzzle. Given an integer array `arr` of length `N`, he asks you to determine if there exists any subarray (contiguous part of the array) such that the sum of its elements is a prime number.\n\nA prime number...
0.719264
Taco_89468
C
[ "is_prime", "check_prime_subarray" ]
2
[ [ "check_prime_subarray", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
34b249a5955c2aa3ba3a8e604dd299eaf218e7e7
33eb614ca9e353ddc86076080ca9c5178a55ca30
v1.0
complete
Taco
Taco_88884_C
from typing import List def sort_by_frequency(arr: List[int]) -> List[int]: """ Sort the array in ascending order based on the frequency of the values. If multiple values have the same frequency, they should appear in ascending order. Args: arr: List of integers to be sorted Returns: ...
from collections import Counter def sort_by_frequency(arr): """ Sort the array in ascending order based on the frequency of the values. If multiple values have the same frequency, they should appear in ascending order. """ count = Counter(arr) # Sort primarily by frequency, secondarily by value...
from solution import sort_by_frequency, formatted_output def test_sort_by_frequency_case_1(): assert formatted_output(6, [4, 5, 6, 5, 4, 3]) == "3 6 4 4 5 5" def test_sort_by_frequency_case_2(): assert formatted_output(5, [9, 9, 4, 8, 8]) == "4 8 8 9 9" def test_sort_by_frequency_single_element(): as...
[ { "docstring": "Sort the array in ascending order based on the frequency of the values.\nIf multiple values have the same frequency, they should appear in ascending order.", "function_declaration": "def sort_by_frequency(arr):", "function_name": "sort_by_frequency", "parameter_list": "(arr)" }, ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef sort_by_frequency(arr):\n \"\"\"\n Sorts the array based on the frequency of the values. Values with the same\n fre...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers, you need to implement a function that sorts the array in ascending order based on the frequency of the values. If multiple values have the same frequency, they should appear in ascending order.\n\nInput\n\nFirst line contains an integer n, the number of elements ...
0.641897
Taco_88884
C
[ "sort_by_frequency", "formatted_output" ]
2
[ [ "formatted_output", "sort_by_frequency" ] ]
1
[]
false
[]
false
pytest
true
[]
true
379a032bb0a753c07d542aa9972396bcce18c731
dc5f7e18112614c21037b930e25760270c420fef
v1.0
complete
Taco
Taco_89431_C
def find_shortest_path(input_str: str) -> int: """ Determine the shortest path from a starting station to an ending station using the given network of tracks in a monorail system. The function takes a string input representing the network, the start and end stations and returns the shortest distanc...
from collections import deque def shortest_path_monorail(num_stations, num_tracks, tracks, start, end): # Create the graph as an adjacency list graph = {i: [] for i in range(1, num_stations + 1)} for u, v in tracks: graph[u].append(v) graph[v].append(u) # BFS to find the short...
from solution import find_shortest_path def test_shortest_path_case1(): input_data = "6 7\n1 2\n2 3\n2 4\n3 4\n4 5\n5 6\n3 6\n1 6" assert find_shortest_path(input_data) == 3 def test_shortest_path_case2(): input_data = "5 5\n1 2\n1 3\n2 4\n3 4\n4 5\n1 5" assert find_shortest_path(input_data) == 3 def...
[ { "docstring": null, "function_declaration": "def shortest_path_monorail(num_stations, num_tracks, tracks, start, end):", "function_name": "shortest_path_monorail", "parameter_list": "(num_stations, num_tracks, tracks, start, end)" }, { "docstring": null, "function_declaration": "def fin...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(N, M, edges, start, end):\n \"\"\"\n Returns the shortest path from start station to end station in the gi...
trial_gpt4o_2
{ "original_instruction": "In a futuristic city-state named Proglandia, the government has implemented a public transportation system powered by monorails. The monorail network consists of several interconnected stations and straight tracks uniting them. Each station is identified by a unique integer.\n\nThe monorail...
0.66281
Taco_89431
C
[ "shortest_path_monorail", "find_shortest_path" ]
2
[ [ "find_shortest_path", "shortest_path_monorail" ] ]
1
[]
false
[]
false
pytest
true
[]
true
60c3743eea3ec72f71ee817c29533bc2e4c58010
afea1b818083bcd352b5d9de44133ad862902f30
v1.0
complete
Taco
Taco_89381_C
def is_prime(num: int) -> bool: """ Determine if a number is a prime. >>> is_prime(2) True >>> is_prime(4) False """ # Implementation here def precompute_prime_sums(arr: List[int]) -> List[int]: """ Precompute the prefix sums of prime numbers in the array. >>> precompute_prime_sums(...
def is_prime(num): if num <= 1: return False if num == 2: return True # 2 is the only even prime number if num % 2 == 0: return False # other even numbers are not prime for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True...
from solution import is_prime, precompute_prime_sums, power_value def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(17) == True def test_...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def precompute_prime_sums(arr):", "function_name": "precompute_prime_sums", "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 sieve_of_eratosthenes(max_num):\n \"\"\"\n Function to perform the Sieve of Eratosthenes to find all primes up to max_num inclusive.\n Returns a list ...
trial_gpt4o_2
{ "original_instruction": "In a mystical land, there is a game played with arrays where the players derive the \"Power Value\" of a subarray. The Power Value of a subarray is defined as the sum of all prime numbers within that segment.\n\nGiven an array of non-negative integers and a number of queries, each query ask...
0.630436
Taco_89381
C
[ "is_prime", "precompute_prime_sums", "power_value" ]
3
[ [ "power_value", "precompute_prime_sums" ], [ "precompute_prime_sums", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cad78b87ee55ab5d51c1dc64403acd2b62928619
33ee7976eedb8fd288295a543a5621b89644628a
v1.0
complete
Taco
Taco_88936_C
def floyd_warshall(n, edges): """ Floyd-Warshall algorithm to determine the shortest distance between all pairs of nodes. """ pass def shortest_distances(n, edges, queries): """ Find the shortest distance between pairs of cities in a given representation of Geeklandia. Args: n : int : ...
def floyd_warshall(n, edges): """ Floyd-Warshall algorithm to determine the shortest distance between all pairs of nodes. """ # Initialize distance array dist = [[float('inf')] * (n + 1) for _ in range(n + 1)] # Distance from any node to itself is 0 for i in range(1, n + 1): dis...
def test_floyd_warshall_basic(): edges = [(1, 2, 4), (1, 3, 2), (2, 3, 1), (3, 4, 7)] n = 4 dist = floyd_warshall(n, edges) assert dist[1][4] == 9 assert dist[2][4] == 8 assert dist[1][1] == 0 def test_shortest_distances(): n = 4 edges = [(1, 2, 4), (1, 3, 2), (2, 3, 1), (3, 4, 7)] ...
[ { "docstring": "Floyd-Warshall algorithm to determine the shortest distance between all pairs of nodes.", "function_declaration": "def floyd_warshall(n, edges):", "function_name": "floyd_warshall", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def shorte...
[ 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 floyd_warshall(n, edges):\n dist = [[float('inf')] * (n + 1) for _ in range(n + 1)]\n \n for i in range(1, n + 1):\n dist[i][i] = 0\n \n...
trial_gpt4o_1
{ "original_instruction": "The kingdom of Geeklandia is represented as an undirected graph with `n` cities connected by `m` bidirectional roads. The cities are numbered from `1` to `n`. Each road has a certain length (positive integer). The citizens of Geeklandia want to know the shortest route between any two cities...
0.649261
Taco_88936
C
[ "floyd_warshall", "shortest_distances" ]
2
[ [ "shortest_distances", "floyd_warshall" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e464a7351212ca4c390445c806879cde5c739996
dd3a4b1446a0b3a9c881b8b5471fa4d56c0ec2b9
v1.0
complete
Taco
Taco_89315_C
class LibraryCatalog: def __init__(self): self.catalog = {} self.book_categories = {} def add_book(self, book_id: int, categories: List[str]) -> None: """ Adds a book with book_id to the catalog under the specified categories. """ pass def remove_book(self, book_id:...
class LibraryCatalog: def __init__(self): self.catalog = {} self.book_categories = {} def add_book(self, book_id, categories): if book_id in self.book_categories: return self.book_categories[book_id] = set(categories) for category in categories: ...
from solution import simulate_library_operations def test_add_and_get_books(): commands = """add_book 1 fiction mystery add_book 2 science fiction add_book 3 mystery get_books_by_category fiction get_books_by_category mystery remove_book 1 get_books_by_category fiction get_books_by_category mystery end""" resu...
[]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class LibraryCatalog:\n def __init__(self):\n self.catalog = {}\n self.book_categories = {}\n \n def add_book(self, book_id, categories):\n ...
trial_gpt4o_0
{ "original_instruction": "A large literature library wants to maintain a catalog of all books. Each book can belong to multiple categories and the library wants to keep track of the catalog efficiently. \n\nYour task is to create a system to manage the library's book catalog, allowing efficient insertion, deletion, ...
0.509887
Taco_89315
C
[ "process_commands", "simulate_library_operations" ]
2
[ [ "simulate_library_operations", "process_commands" ] ]
1
[]
false
[ "LibraryCatalog" ]
true
pytest
true
[]
true
668dcf153782ed525cc462e89de0a3b8025cdb44
29e434fa5a44a096a2fe2e1535581be4025d5b38
v1.0
complete
Taco
Taco_89342_C
def find_number_of_islands(test_cases: List[List[List[int]]]) -> List[int]: """ Determine the number of unique islands in each test case provided. Args: test_cases (List): A list containing the test cases, where each test case is a 2D grid represented by a list of lists of integers (0's and 1's). ...
def dfs(grid, x, y, visited): n = len(grid) m = len(grid[0]) stack = [(x, y)] while stack: cx, cy = stack.pop() if (cx, cy) in visited: continue visited.add((cx, cy)) for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1)]: nx, ny = cx + dx, cy + dy ...
from solution import find_number_of_islands, parse_input def test_example_case_1(): input_str = "2\n4 5\n1 1 0 0 0\n1 1 0 1 1\n0 0 0 1 1\n0 0 0 1 0\n3 3\n1 0 1\n0 1 0\n1 0 1\n" test_cases = parse_input(input_str) assert find_number_of_islands(test_cases) == [2, 5] def test_single_island(): input_str =...
[ { "docstring": null, "function_declaration": "def dfs(grid, x, y, visited):", "function_name": "dfs", "parameter_list": "(grid, x, y, visited)" }, { "docstring": null, "function_declaration": "def num_islands(grid):", "function_name": "num_islands", "parameter_list": "(grid)" }...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_islands(grid, n, m):\n def dfs(x, y):\n if x < 0 or x >= n or y < 0 or y >= m or grid[x][y] == 0:\n return\n grid[x][y] = 0 ...
trial_gpt4o_1
{ "original_instruction": "Given a 2D grid of size N x M, your task is to determine the number of unique islands. An island is formed by connected groups of '1's (land) on the grid. Connectivity is determined by horizontal or vertical adjacency, i.e., all horizontally or vertically neighboring cells forming a group o...
0.56294
Taco_89342
C
[ "dfs", "num_islands", "find_number_of_islands", "parse_input" ]
4
[ [ "find_number_of_islands", "num_islands" ], [ "num_islands", "dfs" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
f3cc81a0e7cfd1f8c80c194f4ea94cca745cd7be
7d2e90318962a4496b16e17d2497ac0998807d8d
v1.0
complete
Taco
Taco_88883_C
def is_subsequence(s: str, word: str) -> bool: """ Check if `word` is a subsequence of `s`. >>> is_subsequence("abcde", "a") True >>> is_subsequence("abcde", "ace") True >>> is_subsequence("abcde", "acd") True >>> is_subsequence("abcde", "bb") False """ def num_matching_subseq(s...
def is_subsequence(s, word): """ Returns True if word is a subsequence of s. """ it = iter(s) return all(char in it for char in word) def num_matching_subseq(s, words): """ Returns the count of words that are subsequences of s. """ return sum(is_subsequence(s, word) for word in word...
from solution import is_subsequence, num_matching_subseq def test_is_subsequence(): assert is_subsequence("abcde", "a") == True assert is_subsequence("abcde", "ace") == True assert is_subsequence("abcde", "acd") == True assert is_subsequence("abcde", "bb") == False assert is_subsequence("abcdefg", ...
[ { "docstring": "Returns True if word is a subsequence of s.", "function_declaration": "def is_subsequence(s, word):", "function_name": "is_subsequence", "parameter_list": "(s, word)" }, { "docstring": "Returns the count of words that are subsequences of s.", "function_declaration": "def ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_subsequence(s, word):\n \"\"\"\n Returns True if word is a subsequence of s.\n \"\"\"\n it = iter(s)\n return all(char in it for char in word...
trial_gpt4o_0
{ "original_instruction": "You are given a string `s` and an array of strings `words`. Your task is to determine the number of strings in `words` that are subsequences of `s`. A subsequence of a string is defined as a new string generated from the original string with some characters deleted without changing the rela...
0.722811
Taco_88883
C
[ "is_subsequence", "num_matching_subseq" ]
2
[ [ "num_matching_subseq", "is_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d38aa971dbf124b409693cef9fffd36c53864140
1bf9fbc357cc0f5010c97360bc7d054f4fd9a2d0
v1.0
complete
Taco
Taco_89582_C
def sum_of_proper_divisors(n: int) -> int: """ Calculate the sum of all proper divisors of n. >>> sum_of_proper_divisors(6) 6 >>> sum_of_proper_divisors(28) 28 >>> sum_of_proper_divisors(9) 4 >>> sum_of_proper_divisors(12) 16 >>> sum_of_proper_divisors(1) # edge case ...
def sum_of_proper_divisors(n): """ Calculate the sum of all proper divisors of n. """ if n <= 1: return 0 divisors_sum = 1 for i in range(2, int(n**0.5) + 1): if n % i == 0: divisors_sum += i if i != n // i: divisors_sum += n // i retur...
import pytest from solution import sum_of_proper_divisors, is_prime, process_test_cases def test_sum_of_proper_divisors(): assert sum_of_proper_divisors(6) == 6 assert sum_of_proper_divisors(28) == 28 assert sum_of_proper_divisors(9) == 4 assert sum_of_proper_divisors(12) == 16 assert sum_of_proper...
[ { "docstring": "Calculate the sum of all proper divisors of n.", "function_declaration": "def sum_of_proper_divisors(n):", "function_name": "sum_of_proper_divisors", "parameter_list": "(n)" }, { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_proper_divisors(n):\n \"\"\"\n Calculate the sum of all proper divisors of n.\n \"\"\"\n proper_divisors_sum = 1 # 1 is always a proper div...
trial_gpt4o_2
{ "original_instruction": "Anna is studying prime numbers and their interesting properties. She comes across a unique problem related to prime numbers and their divisors. She wants to write a program to solve this problem but needs your help to do so.\n\nYou need to calculate the sum of all proper divisors of a given...
0.709794
Taco_89582
C
[ "sum_of_proper_divisors", "is_prime", "process_test_cases" ]
3
[ [ "process_test_cases", "is_prime" ], [ "process_test_cases", "sum_of_proper_divisors" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
c61f17b04321dfcd979c81670447f2f487e78316
5f90da0aa11d0e9e8966c6c42777eeded3c97a80
v1.0
complete
Taco
Taco_90101_C
def find_kth_largest(nums: List[int], k: int) -> int: """ Find the k-th largest element in the list of distinct integers. >>> find_kth_largest([3, 2, 1, 5, 6, 4], 2) 5 >>> find_kth_largest([7, 10, 4, 3, 20, 15], 3) 10 >>> find_kth_largest([50, 30, 20, 70, 60], 4) 30 """
import random def quick_select(nums, low, high, k): pivot = nums[high] i = low for j in range(low, high): if nums[j] > pivot: nums[i], nums[j] = nums[j], nums[i] i += 1 nums[i], nums[high] = nums[high], nums[i] if i == k: return nums[i] elif i < k: ...
from solution import find_kth_largest def test_find_kth_largest_example1(): assert find_kth_largest([3, 2, 1, 5, 6, 4], 2) == 5 def test_find_kth_largest_example2(): assert find_kth_largest([7, 10, 4, 3, 20, 15], 3) == 10 def test_find_kth_largest_example3(): assert find_kth_largest([50, 30, 20, 70, 60],...
[ { "docstring": null, "function_declaration": "def quick_select(nums, low, high, k):", "function_name": "quick_select", "parameter_list": "(nums, low, high, k)" }, { "docstring": null, "function_declaration": "def find_kth_largest(nums, k):", "function_name": "find_kth_largest", "...
[ 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_kth_largest(nums, k):\n \"\"\"\n Returns the k-th largest element in the given list of distinct integers.\n \"\"\"\n heap = nu...
trial_gpt4o_2
{ "original_instruction": "You are given a list of `n` distinct integers and a positive integer `k`. Your task is to implement a function `find_kth_largest(nums, k)` that returns the `k`-th largest element in the list.\n\nThe list is not necessarily sorted, and you should aim for an efficient algorithm with a time co...
0.796028
Taco_90101
C
[ "quick_select", "find_kth_largest" ]
2
[ [ "find_kth_largest", "quick_select" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f16e318cd06df36022f72205bb114fc36ffd6c4f
edfef9515f2c7ba993a9c6f45705a2f01550726a
v1.0
complete
Taco
Taco_89693_C
def reduce_array(arr): """ Reduces the array by compressing contiguous subarrays of the same value. :param arr: List[int] - array of integers :return: List[int] - reduced array after compression >>> reduce_array([1, 1, 2, 2, 2, 3, 3]) [1, 2, 3] >>> reduce_array([4, 4, 4, 4, 4]) [4] ...
def reduce_array(arr): n = len(arr) reduced_arr = [] i = 0 while i < n: current_value = arr[i] j = i while j < n and arr[j] == current_value: j += 1 reduced_arr.append(current_value) i = j return reduced_arr def emilias_algorithm(T, ...
from solution import reduce_array, emilias_algorithm def test_reduce_array(): assert reduce_array([1, 1, 2, 2, 2, 3, 3]) == [1, 2, 3] assert reduce_array([4, 4, 4, 4, 4]) == [4] assert reduce_array([1, 1, 2, 3, 3, 3, 2, 2]) == [1, 2, 3, 2] def test_emilias_algorithm(): test_cases = [ (7, [1, 1...
[ { "docstring": null, "function_declaration": "def reduce_array(arr):", "function_name": "reduce_array", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def emilias_algorithm(T, test_cases):", "function_name": "emilias_algorithm", "parameter_list": "(T, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compress_sequence(arr):\n \"\"\"\n Compresses the array by collapsing longest contiguous subarrays of the same value.\n The process is repeated until ...
trial_gpt4o_2
{ "original_instruction": "Emilia loves solving problems involving arrays and sequence manipulation. She's designed a special sequence transformation algorithm and needs your help to implement it.\n\nGiven an integer array `arr`, Emilia's algorithm finds the longest contiguous subarray where all elements are of the s...
0.561762
Taco_89693
C
[ "reduce_array", "emilias_algorithm" ]
2
[ [ "emilias_algorithm", "reduce_array" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c67b91b9c7a03fe3ad3536ef1c29959db00d8511
6ed15ddba2edfabf2f527851c7e4205b4556124d
v1.0
complete
Taco
Taco_89512_C
def sieve_of_eratosthenes(n): """ Implements the Sieve of Eratosthenes algorithm to find all primes up to and including `n`, and returns a list of these prime numbers. """ pass def sum_of_primes(n): """ Returns the sum of all prime numbers less than or equal to `n`. """ pass def pr...
import itertools def sieve_of_eratosthenes(n): """ Implements the Sieve of Eratosthenes algorithm to find all primes up to and including `n`, and returns a list of these prime numbers. """ is_prime = [True] * (n + 1) p = 2 while (p * p <= n): if (is_prime[p] == True): fo...
import pytest from solution import process_input_and_output def test_sample_input_1(): input_values = [2, 10, 20] expected_output = [17, 77] assert process_input_and_output(input_values) == expected_output def test_small_input(): input_values = [2, 1, 2] expected_output = [0, 2] assert process...
[ { "docstring": "Implements the Sieve of Eratosthenes algorithm to find all primes up to and\nincluding `n`, and returns a list of these prime numbers.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"\n This function uses the Sieve of Eratosthenes algorithm to find all prime numbers up to n.\n \"\"\"\n is_prime ...
trial_gpt4o_2
{ "original_instruction": "Write a program that takes an integer `n` as input, finds all the prime numbers less than or equal to `n`, and returns the sum of these prime numbers. A prime number is defined as any number greater than 1 that is not divisible by any number other than 1 and itself.\n\nINPUT\nThe first line...
0.616078
Taco_89512
C
[ "sieve_of_eratosthenes", "sum_of_primes", "process_input_and_output" ]
3
[ [ "process_input_and_output", "sum_of_primes" ], [ "sum_of_primes", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
db2ecbedbd8df91c670b70a1e60a10206ed138f9
806fbcc22263ef161d608acd847f5fae59f545a0
v1.0
complete
Taco
Taco_89857_C
from typing import List def largest_square_with_prime_digit_sum(nums: List[int]) -> int: """ You are given a list of integers nums. Your task is to find the largest integer in the list which is a perfect square whose digit sum (sum of its digits) is a prime number. If no such integer exists, return -...
import math 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 ...
from solution import largest_square_with_prime_digit_sum def test_example_case(): assert largest_square_with_prime_digit_sum([16, 25, 36, 49, 50]) == 49 def test_single_element_prime_digit_sum(): assert largest_square_with_prime_digit_sum([49]) == 49 assert largest_square_with_prime_digit_sum([25]) == 25 ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculate the sum of digits of a number.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(math.sqrt(n)) + 1):\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a list of integers nums. Your task is to find the largest integer in the list which is a perfect square whose digit sum (sum of its digits) is a prime number. If no such integer exists, return -1.\n\nExample 1:\nInput: nums = [16, 25, 36, 49, 50]\nOutput: 49\nExplanation:\n16 ...
0.687392
Taco_89857
C
[ "is_prime", "digit_sum", "largest_square_with_prime_digit_sum" ]
3
[ [ "largest_square_with_prime_digit_sum", "digit_sum" ], [ "largest_square_with_prime_digit_sum", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
60f5af1cd0fe2ad52cd80c339bf6975e9a52f9cd
60be43ae32b7c5fb239179a0294d213c46a4ba35
v1.0
complete
Taco
Taco_89414_C
def quickselect(arr, low, high, k): """ A utility function to perform the Quickselect algorithm. """ def partition(arr, low, high): """ A utility function to perform the partitioning for Quickselect. """ def find_kth_smallest_element(n, k, arr): """ Given a list of distinct integers, find the kth ...
def quickselect(arr, low, high, k): if low == high: return arr[low] pivot_index = partition(arr, low, high) if pivot_index == k: return arr[pivot_index] elif pivot_index < k: return quickselect(arr, pivot_index + 1, high, k) else: return quickselect(arr, low, piv...
from solution import find_kth_smallest_element def test_kth_smallest_element(): assert find_kth_smallest_element(6, 3, [7, 10, 4, 3, 20, 15]) == 7 assert find_kth_smallest_element(5, 1, [1, 2, 3, 4, 5]) == 1 assert find_kth_smallest_element(5, 5, [1, 2, 3, 4, 5]) == 5 assert find_kth_smallest_element(5...
[ { "docstring": null, "function_declaration": "def quickselect(arr, low, high, k):", "function_name": "quickselect", "parameter_list": "(arr, low, high, k)" }, { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_l...
[ 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 quickselect(arr, low, high, k):\n \"\"\"\n Helper function to perform the Quickselect algorithm.\n \"\"\"\n if low == high: # If the list contains...
trial_gpt4o_2
{ "original_instruction": "Given a list of distinct integers, we want to determine the kth smallest element in the list using the Quickselect algorithm. Quickselect is a selection algorithm to find the kth smallest element in an unordered list. It is related to the QuickSort sorting algorithm.\n\nYour task is to impl...
0.59865
Taco_89414
C
[ "quickselect", "partition", "find_kth_smallest_element" ]
3
[ [ "find_kth_smallest_element", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2cd5949626abc279a800aca5d086915230355be4
11c8a9c34d2cd88ed51e9b632152181ff15dec78
v1.0
complete
Taco
Taco_89111_C
def record_height_and_query_growth(n, operations): """ Record the height of the plant on given days and query the average growth rate over periods. :param n: number of operations :param operations: list of operations :return: list of results for each query operation Examples: >>> recor...
def record_height_and_query_growth(n, operations): """ Record the height of the plant on given days and query the average growth rate over periods. :param n: number of operations :param operations: list of operations :return: list of results for each query operation """ heights = {} ...
def test_basic_functionality(): operations = [ "record 1 3", "record 2 8", "record 3 10", "record 4 15", "record 5 18", "query 2 5" ] assert plant_growth_operations(6, operations) == ["3.3333"] def test_small_sample(): operations = [ "record 1 0",...
[ { "docstring": "Record the height of the plant on given days and query the average growth rate over periods.\n\n:param n: number of operations\n:param operations: list of operations\n:return: list of results for each query operation", "function_declaration": "def record_height_and_query_growth(n, operations...
[ 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 record_and_query_growth(n, operations):\n days = {}\n \n def record(day, height):\n days[day] = height\n \n def query(d1, d2):\n i...
trial_gpt4o_2
{ "original_instruction": "A researcher is studying the growth patterns of a rare species of plant. Each day, the researcher records the height of the plant and calculates the average growth rate over certain periods. The growth rate is defined as the difference in height between the start and the end of the period, ...
0.558708
Taco_89111
C
[ "record_height_and_query_growth", "plant_growth_operations" ]
2
[ [ "plant_growth_operations", "record_height_and_query_growth" ] ]
1
[]
false
[]
false
pytest
false
[]
true
6ceba6a82029a0eb7ad08bd7834c052d3aa78574
2d6e9850b549c89e5f0fb7d613a4b75fa6d9c474
v1.0
complete
Taco
Taco_89583_C
def partition_items(N: int, C: int, items_data: List[str], K: int) -> Union[str, List[List[int]]]: """Partition the items into collections as described by input. Parameters: N (int): The number of items. C (int): The number of characteristics each item has. items_data (List[str]): List of item desc...
def can_partition(items, K): from itertools import combinations def check_no_overlap(items): seen = set() for item in items: if any(char in seen for char in item[1:]): return False seen.update(item[1:]) return True N = len(items) if N...
from solution import partition_items def test_partition_impossible(): N = 5 C = 3 items_data = [ "1 1 2 3", "2 2 3 4", "3 1 3 4", "4 5 6 7", "5 4 5 6" ] K = 2 assert partition_items(N, C, items_data, K) == "impossible" def test_partition_possible(): ...
[ { "docstring": null, "function_declaration": "def can_partition(items, K):", "function_name": "can_partition", "parameter_list": "(items, K)" }, { "docstring": null, "function_declaration": "def partition_items(N, C, items_data, K):", "function_name": "partition_items", "paramete...
[ 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 partition_collections(N, C, items, K):\n \"\"\"\n Organize the items into collections of size K such that no items\n in the same collection share any ...
trial_gpt4o_3
{ "original_instruction": "**Problem Statement**\n\nHenry loves collecting and organizing unique antique items. He has a database of items, where each item is described by a unique identification number and a few characteristics. Henry wants to organize the items into different collections based on their characterist...
0.512174
Taco_89583
C
[ "can_partition", "partition_items" ]
2
[ [ "partition_items", "can_partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c164bddf94e59e5c3f0dd31ab25d6f156909c6e5
7172c4824ce1cd5ea5f3c2e86429a0798adc2267
v1.0
complete
Taco
Taco_89270_C
def initialize_grid(size=100): """ Initialize a size x size grid filled with zeros. >>> grid = initialize_grid() >>> len(grid) 100 >>> len(grid[0]) 100 >>> all(cell == 0 for row in grid for cell in row) True """ def draw_horizontal_line(grid, x, y, length): """ Draw a horizo...
def initialize_grid(size=100): return [[0 for _ in range(size)] for _ in range(size)] def draw_horizontal_line(grid, x, y, length): for i in range(length): grid[x][y + i] = 1 def draw_vertical_line(grid, x, y, length): for i in range(length): grid[x + i][y] = 1 def process_commands(comman...
from solution import initialize_grid, draw_horizontal_line, draw_vertical_line, process_commands def test_initialize_grid(): grid = initialize_grid() assert len(grid) == 100 assert len(grid[0]) == 100 assert all(cell == 0 for row in grid for cell in row) def test_draw_horizontal_line(): grid = ini...
[ { "docstring": null, "function_declaration": "def initialize_grid(size=100):", "function_name": "initialize_grid", "parameter_list": "(size=100)" }, { "docstring": null, "function_declaration": "def draw_horizontal_line(grid, x, y, length):", "function_name": "draw_horizontal_line", ...
[ 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 initialize_grid(size=100):\n return [[0 for _ in range(size)] for _ in range(size)]\n\ndef draw_horizontal_line(grid, x, y, length):\n for i in range(len...
trial_gpt4o_0
{ "original_instruction": "Write a program that simulates a simple drawing application on a grid. The program should accept commands to draw horizontal and vertical lines of a specified length. Each grid cell is represented by an integer, starting with all cells initialized to 0. Drawing a line will set the correspon...
0.600139
Taco_89270
C
[ "initialize_grid", "draw_horizontal_line", "draw_vertical_line", "process_commands", "print_grid" ]
5
[ [ "process_commands", "draw_horizontal_line" ], [ "process_commands", "draw_vertical_line" ], [ "process_commands", "initialize_grid" ] ]
3
[]
false
[]
false
pytest
true
[]
true
04112595ad8718371626223454516fbb48e65e6c
eb9709c041eb65ea733b30895c425a70fbf408f3
v1.0
complete
Taco
Taco_89344_C
from typing import List, Tuple, Dict def monitor_security(N: int, queries: List[Tuple[int, int, int]], updates: Dict[str, List[Tuple[int, int]]]) -> List[str]: """ Monitor and ensure the security of various city zones in Gotham. Args: - N (int): the number of zones - queries (List[Tuple[int, int, int]]...
from collections import defaultdict def find(parent, x): if parent[x] != x: parent[x] = find(parent, parent[x]) return parent[x] def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY]...
def test_monitor_security(): # Test case 1 N = 5 updates = { "edges": [(1, 2), (2, 3), (3, 4), (4, 5)] } queries = [ [0, 1, 5], [1, 3, 10], [0, 3, 2], [0, 5, 1] ] expected_output = ["YES", "YES", "YES"] assert monitor_security(N, queries, updates) ...
[ { "docstring": null, "function_declaration": "def find(parent, x):", "function_name": "find", "parameter_list": "(parent, x)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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": "class GothamSecurity:\n def __init__(self, n, security_levels, edges):\n self.n = n\n self.security_levels = security_levels\n self.graph =...
trial_gpt4o_5
{ "original_instruction": "Chef has decided to conduct a special operation to monitor and ensure the security of various city zones in Gotham. Each zone has a specific level of security, represented by a number. Zones are connected through a network of security paths, forming a complex web of routes.\n\nBatman has bu...
0.521768
Taco_89344
C
[ "find", "union", "monitor_security" ]
3
[ [ "monitor_security", "find" ], [ "monitor_security", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
false
[]
true
56f89ec573d14a6aa485683d0a80c43954532014
17074d840c92f295f39ce69292392e35fa600580
v1.0
complete
Taco
Taco_89380_C
def is_palindromic_number(n: int) -> bool: """ Determines if a given number is a palindrome. >>> is_palindromic_number(121) True >>> is_palindromic_number(12321) True >>> is_palindromic_number(123) False """ # Complete the function body def check_palindromic_numbers(t: int, num...
def is_palindromic_number(n): """ Determines if a given number is a palindrome. """ str_n = str(n) return str_n == str_n[::-1] def check_palindromic_numbers(t, numbers): """ Checks if each number in the list `numbers` is palindromic and returns results as a list. """ results = [] ...
from solution import is_palindromic_number, check_palindromic_numbers def test_is_palindromic_number(): assert is_palindromic_number(121) assert is_palindromic_number(12321) assert not is_palindromic_number(123) assert is_palindromic_number(1) assert is_palindromic_number(0) assert not is_palin...
[ { "docstring": "Determines if a given number is a palindrome.", "function_declaration": "def is_palindromic_number(n):", "function_name": "is_palindromic_number", "parameter_list": "(n)" }, { "docstring": "Checks if each number in the list `numbers` is palindromic and returns results as a li...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Determine if a given number n is a palindrome.\n \"\"\"\n str_n = str(n)\n return str_n == str_n[::-1]\n\ndef check...
trial_gpt4o_1
{ "original_instruction": "A palindromic number is a number that remains the same when its digits are reversed. Given a number, determine whether it is a palindrome.\n\nInput Format:\nThe input begins with number of test cases t in a single line. In each of the next t lines, there is a number n.\n\nOutput Format:\nIn...
0.745465
Taco_89380
C
[ "is_palindromic_number", "check_palindromic_numbers" ]
2
[ [ "check_palindromic_numbers", "is_palindromic_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
03606f5e89f97c6edf0b2ad060ce09a21d8d6cfc
be705c517909947673ddbd860786f53cdfc06946
v1.0
complete
Taco
Taco_89941_C
from typing import List def knight_arrangements(strengths: List[int]) -> List[List[int]]: """ Given a list of knight strengths, return all valid arrangements where each knight is stronger than the knight directly next to them. >>> knight_arrangements([3, 1, 2]) [[1, 2, 3], [3, 2, 1]] >>> knight_arr...
from itertools import permutations def is_valid_arrangement(perm): """ Check if a given permutation is a valid arrangement where each knight is stronger than the knight directly next to them. """ for i in range(len(perm) - 1): if abs(perm[i] - perm[i + 1]) != 1: return False ...
from solution import knight_arrangements def test_sample_input_1(): result = knight_arrangements([3, 1, 2]) expected = [[1, 2, 3], [3, 2, 1]] assert result == expected def test_sample_input_2(): result = knight_arrangements([4, 3, 2, 1]) expected = [[1, 2, 3, 4], [4, 3, 2, 1]] assert result ==...
[ { "docstring": "Check if a given permutation is a valid arrangement where each knight\nis stronger than the knight directly next to them.", "function_declaration": "def is_valid_arrangement(perm):", "function_name": "is_valid_arrangement", "parameter_list": "(perm)" }, { "docstring": "Given ...
[ 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": "from itertools import permutations\n\ndef is_valid(arrangement):\n \"\"\"\n Checks if the arrangement satisfies the condition where each knight is stronger\n...
trial_gpt4o_6
{ "original_instruction": "In a magical kingdom, there is a prestigious tournament of knights. Each knight can have a unique strength level represented by an integer. The king organizes them such that the knights stand in a line, and each knight must be stronger than the knight directly to their left or right. For a ...
0.523245
Taco_89941
C
[ "is_valid_arrangement", "knight_arrangements" ]
2
[ [ "knight_arrangements", "is_valid_arrangement" ] ]
1
[]
false
[]
false
pytest
true
[]
true
22bbb8c0e9ad777ceb7fff23c696f6c520b492ad
cf92c2fcc1066278bb767092f0c1511c707cdd5f
v1.0
complete
Taco
Taco_89740_C
from typing import List, Tuple def sum_of_squares_of_digits(n: int) -> int: """ Compute the sum of the squares of the digits of the number n. >>> sum_of_squares_of_digits(19) 82 >>> sum_of_squares_of_digits(82) 68 """ pass def reaches_one_within_k_steps(a0: int, K: int) -> str: """...
def sum_of_squares_of_digits(n): """ Compute the sum of the squares of the digits of the number n. """ return sum(int(digit)**2 for digit in str(n)) def reaches_one_within_k_steps(a0, K): """ Determine if the sequence starting from a0 reaches 1 within K steps. """ for _ in range(K): ...
from solution import sum_of_squares_of_digits, reaches_one_within_k_steps, solution def test_sum_of_squares_of_digits(): assert sum_of_squares_of_digits(19) == 1**2 + 9**2 assert sum_of_squares_of_digits(82) == 8**2 + 2**2 assert sum_of_squares_of_digits(100) == 1**2 + 0**2 + 0**2 def test_reaches_one_wit...
[ { "docstring": "Compute the sum of the squares of the digits of the number n.", "function_declaration": "def sum_of_squares_of_digits(n):", "function_name": "sum_of_squares_of_digits", "parameter_list": "(n)" }, { "docstring": "Determine if the sequence starting from a0 reaches 1 within K st...
[ 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 sum_of_squares_of_digits(n):\n \"\"\"\n Compute the sum of the squares of the digits of the number n.\n \"\"\"\n return sum(int(digit)**2 for digit...
trial_gpt4o_0
{ "original_instruction": "Given an infinite sequence of positive integers defined as follows:\nEach element $a_n$ of the sequence is computed as the sum of the squares of the digits of $a_{n-1}$. The sequence starts with a given positive integer $a_0$.\n\nIf $a_0$ has only one digit, then $a_1$ can be directly compu...
0.590829
Taco_89740
C
[ "sum_of_squares_of_digits", "reaches_one_within_k_steps", "solution", "main" ]
4
[ [ "reaches_one_within_k_steps", "sum_of_squares_of_digits" ], [ "solution", "reaches_one_within_k_steps" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fa3504c74a9b743ff1d78186153a0782f41e343c
c809563a24d504b4c3f35262d758cb8e10607096
v1.0
complete
Taco
Taco_89824_C
def solve(n: int) -> List[int]: """ In this function, you will be given an integer `n`, and your task is to find a pair of prime numbers such that their sum is equal to `n`. If multiple such pairs exist, return the pair with the smallest difference, and if there are still multiple pairs with the same differ...
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 solve(n): primes = [i ...
from solution import solve def test_solve(): assert solve(10) == [5, 5], "Expected [5, 5] for input 10" assert solve(12) == [5, 7], "Expected [5, 7] for input 12" assert solve(4) == [2, 2], "Expected [2, 2] for input 4" assert solve(8) == [3, 5], "Expected [3, 5] for input 8" assert solve(20) == [7...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def solve(n):", "function_name": "solve", "parameter_list": "(n)" } ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 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_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_7
{ "original_instruction": "In this Kata, you will be given an integer `n`, and your task is to find a pair of prime numbers such that their sum is equal to `n`. If multiple such pairs exist, return the pair with the smallest difference, and if there are still multiple pairs with the same difference, return the pair w...
0.733443
Taco_89824
C
[ "is_prime", "solve" ]
2
[ [ "solve", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7bb978d7bae5944fd0acc199c1c0aa622f9802e2
84f81c896066a67470bff69a2d51d012bc91f23e