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_8472_C
from typing import List def smallestConcatenatedNumber(nums: List[int]) -> str: """ Given a list of non-negative integers, find the smallest number that can be formed by concatenating the numbers together. >>> smallestConcatenatedNumber([3, 30, 34, 5, 9]) "3033459" >>> smallestConcatenatedNumber([20, 1, 34...
from functools import cmp_to_key def compare(a, b): if a + b < b + a: return -1 elif a + b > b + a: return 1 else: return 0 def smallestConcatenatedNumber(nums): """ Returns the smallest number that can be formed by concatenating the numbers together. """ # Conver...
from solution import smallestConcatenatedNumber def test_example_1(): assert smallestConcatenatedNumber([3, 30, 34, 5, 9]) == "3033459" def test_example_2(): assert smallestConcatenatedNumber([20, 1, 34, 3, 9]) == "1203349" def test_all_zeros(): assert smallestConcatenatedNumber([0, 0, 0, 0]) == "0" def...
[ { "docstring": null, "function_declaration": "def compare(a, b):", "function_name": "compare", "parameter_list": "(a, b)" }, { "docstring": "Returns the smallest number that can be formed by concatenating the numbers together.", "function_declaration": "def smallestConcatenatedNumber(num...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(a, b):\n \"\"\"\n Comparator function to sort numbers in such a way that \n the concatenation of numbers f...
trial_gpt4o_9
{ "original_instruction": "Given a list of non-negative integers, your task is to find the smallest number that can be formed by concatenating the numbers together. \n\nExample 1:\nInput: nums = [3, 30, 34, 5, 9]\nOutput: \"3033459\"\nExplanation: By arranging the numbers in such a way, the smallest concatenated numb...
0.655092
Taco_8472
C
[ "compare", "smallestConcatenatedNumber" ]
2
[ [ "smallestConcatenatedNumber", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
01f4c76e3df4a4a887d0ac6f4a6721e8eeb24454
45e0cfc1b00c4a5dd0cfa7fe2ad2a3cd77c39cc3
v1.0
complete
Taco
Taco_8067_C
class TreeNode: def __init__(self, key): self.left = None self.right = None self.value = key def insert(root, key): if root is None: return TreeNode(key) else: if root.value < key: root.right = insert(root.right, key) else: root.left =...
class TreeNode: def __init__(self, key): self.left = None self.right = None self.value = key def insert(root, key): if root is None: return TreeNode(key) else: if root.value < key: root.right = insert(root.right, key) else: root.left =...
from solution import construct_bst_and_compute_height def test_construct_bst_and_compute_height_example(): assert construct_bst_and_compute_height("10,5,15,3,7,13,17,2,4,6,8") == 3 def test_construct_bst_and_compute_height_single_element(): assert construct_bst_and_compute_height("10") == 0 def test_construc...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef insert_into_bst(root, value...
trial_gpt4o_2
{ "original_instruction": "Given a sequence of positive integers, construct a binary search tree (BST) by inserting the integers in the given order. Then, compute and output the height of the BST. The height of a BST is the length of the path from the root to the deepest node in the tree.\n\nInput\n\nA single line co...
0.562913
Taco_8067
C
[ "insert", "height", "construct_bst_and_compute_height" ]
3
[ [ "construct_bst_and_compute_height", "height" ], [ "construct_bst_and_compute_height", "insert" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
a23dac4e45659dbe4bc39a9a1c75453c25f1a420
06f498f748ccd5c7dd6c54608e19f88adfb32224
v1.0
complete
Taco
Taco_7084_C
from typing import List def rotateLeft(S: str, x: int) -> str: """ Returns the string S rotated to the left x times. """ pass def character_frequencies(S: str) -> List[int]: """ Returns a list of frequencies of lowercase letters in the string S. """ pass def process_queries(N: int, S: str, M: int, q...
def rotateLeft(S, x): """ Returns the string S rotated to the left x times. """ N = len(S) x = x % N # Only rotating x % N times is needed return S[x:] + S[:x] def character_frequencies(S): """ Returns a list of frequencies of lowercase letters in the string S. """ freq = [0] *...
def test_rotateLeft(): assert rotateLeft("abcde", 1) == "bcdea" assert rotateLeft("abcde", 2) == "cdeab" assert rotateLeft("abcde", 5) == "abcde" assert rotateLeft("abcde", 7) == "cdeab" # 7 % 5 == 2 def test_character_frequencies(): assert character_frequencies("abcde") == [1, 1, 1, 1, 1, 0, 0, 0...
[ { "docstring": "Returns the string S rotated to the left x times.", "function_declaration": "def rotateLeft(S, x):", "function_name": "rotateLeft", "parameter_list": "(S, x)" }, { "docstring": "Returns a list of frequencies of lowercase letters in the string S.", "function_declaration": ...
[ 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 rotateLeft(S, x):\n x = x % len(S) # To avoid extra unnecessary rotations\n return S[x:] + S[:x]\n\ndef character_fre...
trial_gpt4o_1
{ "original_instruction": "Given a string S of length N consisting of lowercase letters, you can perform a left cyclic shift operation where the first character of the string moves to the end of the string. \n\nDefine `rotateLeft(S, x)` as the string resulting from performing the left cyclic shift operation x times o...
0.648754
Taco_7084
C
[ "rotateLeft", "character_frequencies", "process_queries" ]
3
[ [ "process_queries", "character_frequencies" ], [ "process_queries", "rotateLeft" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
bcab4da94a8baa2dd4e3e3c2f0914248dc4874d8
96f1444c5b455111d5eb7eb4976afd49cc266f03
v1.0
complete
Taco
Taco_7836_C
from typing import List, Tuple def min_max_travel_time(n: int, k: int, roads: List[Tuple[int, int, int]]) -> int: """ Determine the minimum possible maximum travel time to the nearest checkpoint. Args: n (int): The number of cities. k (int): The maximum number of checkpoints. roads (List[Tuple...
import heapq from collections import defaultdict import numpy as np def dijkstra(graph, n, start): dist = [float('inf')] * n dist[start] = 0 pq = [(0, start)] while pq: curr_dist, u = heapq.heappop(pq) if curr_dist > dist[u]: continue for v, length in graph[u]: ...
from solution import min_max_travel_time def test_example_1(): n, k = 5, 2 roads = [ (1, 2, 4), (2, 3, 6), (3, 4, 8), (4, 5, 3), ] assert min_max_travel_time(n, k, roads) == 6 def test_single_city(): n, k = 1, 1 roads = [] assert min_max_travel_time(n, k, ro...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, n, start):", "function_name": "dijkstra", "parameter_list": "(graph, n, start)" }, { "docstring": null, "function_declaration": "def min_max_travel_time(n, k, roads):", "function_name": "min_max_travel_time", "para...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nfrom collections import defaultdict\n\ndef min_max_travel_time(n, k, roads):\n if k >= n:\n return 0\n \n def bfs(start, distance):\n...
trial_gpt4o_1
{ "original_instruction": "In a certain kingdom, cities are connected by bidirectional roads, such that there is exactly one path between any two cities. Each road has a certain travel-time associated with it, which varies greatly.\n\nThe king, to improve trade efficiency, wants to open a maximum of k checkpoints in ...
0.670017
Taco_7836
C
[ "dijkstra", "min_max_travel_time" ]
2
[ [ "min_max_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
1cb3fe17b6e84c05aa19d4994f466a9f3415f10c
ad7cd7c7a9ab69b38deab15ad162f3d141946b15
v1.0
complete
Taco
Taco_8286_C
def find_longest_subsequence(arr): """ Function to find the length of the longest subsequence such that the difference between consecutive elements is a constant value. Args: arr (list): List of integers. Returns: int: Length of the longest subsequence. >>> find_longest_subsequence([3...
def find_longest_subsequence(arr): """ Function to find the length of the longest subsequence such that the difference between consecutive elements is a constant value. """ if not arr: return 0 n = len(arr) if n == 1: return 1 dp = [{} for _ in range(n)] max...
import pytest from solution import find_longest_subsequence def test_longest_subsequence_case_1(): assert find_longest_subsequence([3, 6, 9, 12, 15, 18, 21]) == 7 def test_longest_subsequence_case_2(): assert find_longest_subsequence([5, 1, 5, 9, 13, 17]) == 5 def test_no_sequence(): assert find_longest...
[ { "docstring": "Function to find the length of the longest subsequence such that the\ndifference between consecutive elements is a constant value.", "function_declaration": "def find_longest_subsequence(arr):", "function_name": "find_longest_subsequence", "parameter_list": "(arr)" }, { "docs...
[ 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 longest_arith_seq_len(nums):\n if len(nums) == 0:\n return 0\n \n dp = [{} for _ in range(len(nums))]\n max_len = 1\n \n for i in rang...
trial_gpt4o_2
{ "original_instruction": "You are given an array of N integers. Your task is to find the length of the longest subsequence such that the difference between consecutive elements is a constant value.\n\nWrite a function to find this length.\n\n### Input:\n- The first line contains an integer T denoting the number of t...
0.81983
Taco_8286
C
[ "find_longest_subsequence", "longest_subsequence_length", "parse_input_output", "main" ]
4
[ [ "longest_subsequence_length", "find_longest_subsequence" ] ]
1
[ "parse_input_output" ]
false
[]
false
pytest
true
[]
true
2d9a0a1160374f07219fa7b709ac1c93c60d73a2
8040cba74c0cda2d78ea5bad6e5be898d48c802d
v1.0
complete
Taco
Taco_8256_C
def max_artifact_value(n: int, W: int, items: List[Tuple[int, int]]) -> int: """ Given the number of artifacts n, the max weight capacity W, and a list of artifacts (each represented as a tuple (weight, value)), this function calculates the maximum value that can be collected without exceeding the weig...
def max_artifact_value(n, W, items): """ Given the number of artifacts n, the max weight capacity W, and a list of artifacts (each represented as a tuple (weight, value)), this function calculates the maximum value that can be collected without exceeding the weight capacity using dynamic programming. ...
from solution import max_artifact_value, read_input_and_solve def test_example1(): input_data = "4 7\n1 1\n3 4\n4 5\n5 7" assert read_input_and_solve(input_data) == 9 def test_example2(): input_data = "3 50\n10 60\n20 100\n30 120" assert read_input_and_solve(input_data) == 220 def test_single_item():...
[ { "docstring": "Given the number of artifacts n, the max weight capacity W, and a list of artifacts \n(each represented as a tuple (weight, value)), this function calculates the maximum\nvalue that can be collected without exceeding the weight capacity using dynamic programming.", "function_declaration": "d...
[ 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_artifact_value(n, W, artifacts):\n # Initialize the DP array with 0\n dp = [0] * (W + 1)\n\n # Process each artifact\n for weight, value in art...
trial_gpt4o_3
{ "original_instruction": "A professional treasure hunter has discovered a room full of artifacts. Each artifact has a weight and a value associated with it. However, the room has a maximum weight capacity that cannot be exceeded. The treasure hunter wants to collect artifacts in a way that maximizes the total value,...
0.609895
Taco_8256
C
[ "max_artifact_value", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "max_artifact_value" ] ]
1
[]
false
[]
false
pytest
true
[]
true
92d3cea2a1c14266780df76b5bf6afaf5f31a90a
cb7e292c999e8d25256b2f7dbb091e212f9c0085
v1.0
complete
Taco
Taco_8228_C
def simulate_routing(N, M, connections, forwarding_data, S, D): """ Simulate the routing of packets through a series of routers based on forwarding tables. Args: N (int): Number of routers M (int): Number of connections connections (List[Tuple[int, int]]): List of direct connections between routers ...
def find_path(N, M, connections, forwarding_tables, S, D): from collections import deque # Build the network graph graph = {i: [] for i in range(N)} for u, v in connections: graph[u].append(v) graph[v].append(u) # Assume bidirectional links # Perform BFS to find the path queue...
def test_example_case(): N = 5 M = 6 connections = [(0, 1), (0, 2), (1, 3), (2, 3), (3, 4), (2, 4)] forwarding_data = [ (3, 0, 1, 1, 2, 2, 1), (3, 0, 1, 4, 4, 1, 2), (2, 2, 3, 4, 4), (2, 4, 4, 3, 3), (2, 4, 4, 3, 3), ] S, D = 0, 4 assert simulate_routi...
[ { "docstring": null, "function_declaration": "def find_path(N, M, connections, forwarding_tables, S, D):", "function_name": "find_path", "parameter_list": "(N, M, connections, forwarding_tables, S, D)" }, { "docstring": null, "function_declaration": "def simulate_routing(N, M, connection...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def router_path(N, M, connections, forwarding_tables, S, D):\n \"\"\"\n Determines the path a packet takes in the network from source router S to destination...
trial_gpt4o_9
{ "original_instruction": "Imagine you are designing a basic router that routes data packets in a network. You need to simulate the routing of packets through a series of routers. Each router forwards the packet to the next router in the path based on a set of forwarding rules.\n\nThe network is represented as a grap...
0.462535
Taco_8228
C
[ "find_path", "simulate_routing" ]
2
[ [ "simulate_routing", "find_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
29e518fd463bcc29ebabefedce2b3bfed1fb51ea
574e780fcf298e431e826699439e0e6882ea05e5
v1.0
complete
Taco
Taco_8363_C
def sieve_of_eratosthenes(N): """ Returns a list of all prime numbers less than or equal to N. >>> sieve_of_eratosthenes(1) == [] >>> sieve_of_eratosthenes(2) == [2] >>> sieve_of_eratosthenes(10) == [2, 3, 5, 7] >>> sieve_of_eratosthenes(30) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] """ def pr...
def sieve_of_eratosthenes(N): """ Returns a list of all prime numbers less than or equal to N. """ if N < 2: return [] prime = [True for i in range(N + 1)] p = 2 while p * p <= N: if prime[p]: for i in range(p * p, N + 1, p): prime[i] = False ...
from solution import sieve_of_eratosthenes, print_primes_up_to import io import sys def test_sieve_basic(): assert sieve_of_eratosthenes(1) == [] assert sieve_of_eratosthenes(2) == [2] assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] def test_sieve_larger(): assert sieve_of_eratosthenes(30) == [2, 3, ...
[ { "docstring": "Returns a list of all prime numbers less than or equal to N.", "function_declaration": "def sieve_of_eratosthenes(N):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(N)" }, { "docstring": null, "function_declaration": "def print_primes_up_to(N):", "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 find_primes(N):\n \"\"\"\n Returns a list of all prime numbers less than or equal to N.\n \"\"\"\n if N < 2:\n return []\n sieve = [True]...
trial_gpt4o_1
{ "original_instruction": "Given an integer N, print all prime numbers less than or equal to N. A prime number is a positive integer greater than 1 that has no positive integer divisors other than 1 and itself.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^6\n - All values in input are integers.\n\n-----Input-----\...
0.669613
Taco_8363
C
[ "sieve_of_eratosthenes", "print_primes_up_to" ]
2
[ [ "print_primes_up_to", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8eb47b13f7067b11a35d8bf12e69c9762b85d36a
19b535c36dbfd5b2d22ba35433537655f257e52e
v1.0
complete
Taco
Taco_8360_C
def super_primes(n: int) -> List[int]: """ Find and return a list of the first n super prime numbers. A super prime number is a prime number that occupies a prime-numbered position in the sequence of all prime numbers. >>> super_primes(1) == [3] >>> super_primes(2) == [3, 5] >>> super_primes(5) == [...
def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def generate_primes_up_to(n): primes = [] candidate = 2 while len(primes) < n: if is_prime(candidate): primes.append(candid...
from solution import super_primes def test_super_primes_single(): assert super_primes(1) == [3] def test_super_primes_two(): assert super_primes(2) == [3, 5] def test_super_primes_five(): assert super_primes(5) == [3, 5, 11, 17, 31] def test_super_primes_ten(): assert super_primes(10) == [3, 5, 11, ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def generate_primes_up_to(n):", "function_name": "generate_primes_up_to", "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 if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n retur...
trial_gpt4o_3
{ "original_instruction": "A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A super prime number is a prime number that occupies a prime-numbered position in the sequence of all prime numbers, as defined by their natural occurrence.\n\nFor example, th...
0.730711
Taco_8360
C
[ "is_prime", "generate_primes_up_to", "super_primes" ]
3
[ [ "generate_primes_up_to", "is_prime" ], [ "super_primes", "generate_primes_up_to" ], [ "super_primes", "is_prime" ] ]
3
[]
false
[]
false
pytest
true
[]
true
68c5da6cf1fd14d318d5f8e04c652c0a23e38b47
546b2d5af3c37cb9047f2e49b8ee2e44c5d498b7
v1.0
complete
Taco
Taco_8629_C
def check_arithmetic_sequence(N: int, arr: List[int]) -> str: """ Given an array of integers, determine if the array can be rearranged to form an arithmetic sequence. An arithmetic sequence is a sequence of numbers in which the difference between consecutive terms is constant. >>> check_arithmetic_seq...
def can_form_arithmetic_sequence(arr): """ Check if the given array can be rearranged to form an arithmetic sequence. """ if len(arr) <= 1: return True arr.sort() difference = arr[1] - arr[0] for i in range(2, len(arr)): if arr[i] - arr[i - 1] != difference: ...
def test_single_element(): assert check_arithmetic_sequence(1, [1]) == "YES" def test_two_elements(): assert check_arithmetic_sequence(2, [5, 10]) == "YES" assert check_arithmetic_sequence(2, [10, 5]) == "YES" def test_already_sorted_arithmetic_sequence(): assert check_arithmetic_sequence(5, [1, 3, 5,...
[ { "docstring": "Check if the given array can be rearranged to form an arithmetic sequence.", "function_declaration": "def can_form_arithmetic_sequence(arr):", "function_name": "can_form_arithmetic_sequence", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def c...
[ 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_form_arithmetic_sequence(arr):\n \"\"\"\n Determine if the array can be rearranged to form an arithmetic sequence.\n \"\"\"\n if len(arr) <= 1:...
trial_gpt4o_2
{ "original_instruction": "Given an array of integers, determine if the array can be rearranged to form an arithmetic sequence. \n\nAn arithmetic sequence is a sequence of numbers in which the difference between consecutive terms is constant.\n\nConstraints:\n- The number of elements in the array, \\( N \\), is an in...
0.672331
Taco_8629
C
[ "can_form_arithmetic_sequence", "check_arithmetic_sequence" ]
2
[ [ "check_arithmetic_sequence", "can_form_arithmetic_sequence" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3a86082c2828a438872a3d9349de57359b349fd1
66a752c95f967f1f3a5b707cb5a71ae3dbfaa9dd
v1.0
complete
Taco
Taco_8419_C
import math from typing import List, Tuple def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(4) False """ pass def average_of_primes(arr: List[int]) -> int: """ Find the average of all the prime numbers present in the array. If ...
import math def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True def average_of_primes(arr): primes = [x for x in arr if is_pr...
from solution import is_prime, average_of_primes, 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(1) == False assert is_prime(0) == False assert is_prime(1000003) == True d...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def average_of_primes(arr):", "function_name": "average_of_primes", "parameter_list": "(arr)" }, { "docst...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return False\n for i in range(3...
trial_gpt4o_1
{ "original_instruction": "Given an integer array, find the average of all the prime numbers present in the array. If there are no prime numbers in the array, return -1.\n\n-----Input-----\n- The first line of the input contains an integer T denoting the number of test cases. Then T test cases follow.\n- Each test ca...
0.665389
Taco_8419
C
[ "is_prime", "average_of_primes", "process_test_cases" ]
3
[ [ "average_of_primes", "is_prime" ], [ "process_test_cases", "average_of_primes" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
e0844014f9dad2f8d4e4f2792a40e44579759678
491f1d9c81099509653bc2423db24e85e28f718b
v1.0
complete
Taco
Taco_7763_C
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[...
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] = rootX elif rank[...
from solution import process_multiple_datasets def test_single_dataset(): datasets = [ (4, 2, [(1, 2, 8), (2, 3, 5)]), ] assert process_multiple_datasets(datasets) == [1] def test_single_dataset_no_additional_roads_needed(): datasets = [ (3, 3, [(1, 2, 7), (1, 3, 10), (2, 3, 2)]), ...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 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_minimum_roads(x, y, roads):\n parent = list(range(x + 1))\n \n def find(v):\n if parent[v] != v:\n parent[v] = find(parent[v])\...
trial_gpt4o_2
{ "original_instruction": "Consider an island with x villages (numbered 1 through x) and y roads connecting these villages. Each road connects exactly two different villages and may have different travel times. The rulers of the island want to pave additional roads to ensure that it is possible to travel between any ...
0.591176
Taco_7763
C
[ "find", "union", "min_additional_roads", "process_multiple_datasets" ]
4
[ [ "min_additional_roads", "find" ], [ "min_additional_roads", "union" ], [ "process_multiple_datasets", "min_additional_roads" ], [ "union", "find" ] ]
4
[ "process_multiple_datasets" ]
false
[]
false
pytest
true
[]
true
5da558651e422d5e0af99e4af4a98dcf501d199e
9b415d2e87a70061edc0753c55de350aa988f5e4
v1.0
complete
Taco
Taco_8691_C
from typing import List def is_prime(num: int) -> bool: """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(4) False >>> is_prime(17) True """ def is_palindrome(num: int) -> bool: """ Check if a number is a palindrome. >>> is_palindrome(121) True >>> is_palindrom...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import is_prime, is_palindrome, palindrome_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_is_palindrome(): assert is_palindrome(121) == True assert ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Checks if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindr...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\" Returns True if n is a prime number, else False. \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "Bob has just learned about prime numbers and palindrome numbers in his computer science class. He is now tasked with solving a problem that combines both concepts.\n\nA prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A palind...
0.705972
Taco_8691
C
[ "is_prime", "is_palindrome", "palindrome_prime" ]
3
[ [ "palindrome_prime", "is_palindrome" ], [ "palindrome_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c68fd20981330b591735ca81383f663ad6dcf529
99722d96f5f42e39e321971748b1cc8f96172472
v1.0
complete
Taco
Taco_8661_C
from typing import List def calculate_tsp(N: int, D: List[List[int]]) -> int: """ Calculate the shortest possible route for the Traveling Salesman Problem with a limited number of cities using permutations. Args: N: The number of cities. D: A 2D list representing the distance matrix. ...
from itertools import permutations def calculate_tsp(N, D): """ Calculate the shortest possible route for the Traveling Salesman Problem with a limited number of cities using permutations. """ cities = range(N) min_route_length = float('inf') # Generate all permutations of city visits...
def test_tsp_example_1(): input_str = '''4 0 10 15 20 10 0 35 25 15 35 0 30 20 25 30 0''' assert read_input_and_solve(input_str) == 80 def test_tsp_example_2(): input_str = '''3 0 29 20 29 0 15 20 15 0''' assert read_input_and_solve(input_str) == 64 def test_tsp_min_2_cities(): input_str = '''2 0 ...
[ { "docstring": "Calculate the shortest possible route for the Traveling Salesman Problem \nwith a limited number of cities using permutations.", "function_declaration": "def calculate_tsp(N, D):", "function_name": "calculate_tsp", "parameter_list": "(N, D)" }, { "docstring": null, "funct...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef calculate_tsp(N, D):\n \"\"\"\n Calculate the shortest possible route for the Traveling Salesman Problem \n with...
trial_gpt4o_0
{ "original_instruction": "The Traveling Salesman Problem (TSP) is a classic algorithmic problem in the fields of operations research and computer science. Given a list of cities and the distances between each pair of cities, the task is to find the shortest possible route that visits each city exactly once and retur...
0.596088
Taco_8661
C
[ "calculate_tsp", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "calculate_tsp" ] ]
1
[]
false
[]
false
pytest
false
[]
true
d01fe658e5291e87bdb5f9482f33102c9887d7ab
275154950797f441597b7d207187620a924bfd6b
v1.0
complete
Taco
Taco_8597_C
def is_valid_palindrome(s: str) -> bool: """ Determines if the given string s is a valid palindrome by ignoring non-alphanumeric characters and case differences. >>> is_valid_palindrome("A man, a plan, a canal: Panama") True >>> is_valid_palindrome("race a car") False """ def solve(s: ...
def is_valid_palindrome(s): """ Determines if the given string s is a valid palindrome by ignoring non-alphanumeric characters and case differences. """ # Remove non-alphanumeric characters and convert to lowercase filtered_s = ''.join([char.lower() for char in s if char.isalnum()]) # Check ...
from solution import is_valid_palindrome, solve import subprocess def test_is_valid_palindrome(): assert is_valid_palindrome("A man, a plan, a canal: Panama") == True assert is_valid_palindrome("race a car") == False assert is_valid_palindrome("") == True assert is_valid_palindrome(" ") == True ass...
[ { "docstring": "Determines if the given string s is a valid palindrome by ignoring non-alphanumeric characters\nand case differences.", "function_declaration": "def is_valid_palindrome(s):", "function_name": "is_valid_palindrome", "parameter_list": "(s)" }, { "docstring": "Solves the problem...
[ 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_palindrome(s):\n \"\"\"\n Returns \"YES\" if the given string is a valid palindrome, otherwise returns \"NO\".\n A string is considered a val...
trial_gpt4o_2
{ "original_instruction": "A string is said to be a valid palindrome if it reads the same backward as forward, after converting all uppercase letters into lowercase letters and ignoring all non-alphanumeric characters. Write a function to determine if a given string is a valid palindrome.\n\n------ Input ------\n\nTh...
0.803244
Taco_8597
C
[ "is_valid_palindrome", "solve" ]
2
[ [ "solve", "is_valid_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
57fb56b1995cc6494dffe29615520c2b29bbb169
3fb2c28bfdd19ebf14b47d5261ee4f2e30b62634
v1.0
complete
Taco
Taco_8928_C
def minimize_largest_sum(arr, n, k): """ Given an array arr of size n and an integer k, divide the array into exactly k subarrays such that the largest sum of any subarray is minimized. Returns the minimized largest sum. >>> minimize_largest_sum([7, 2, 5, 10, 8, 1, 3], 7, 3) 14 >>> minimize_lar...
def can_split(arr, n, k, max_sum): """ Determines if it is possible to split the array into k or fewer subarrays such that the maximum subarray sum does not exceed max_sum. """ current_sum = 0 required_splits = 1 for num in arr: if current_sum + num > max_sum: required_s...
def test_example_case(): assert minimize_largest_sum([7, 2, 5, 10, 8, 1, 3], 7, 3) == 14 def test_single_element(): assert minimize_largest_sum([10], 1, 1) == 10 def test_equal_k_n(): assert minimize_largest_sum([1, 2, 3, 4, 5], 5, 5) == 5 def test_k_equal_to_1(): assert minimize_largest_sum([1, 2, 3...
[ { "docstring": "Determines if it is possible to split the array into k or fewer subarrays\nsuch that the maximum subarray sum does not exceed max_sum.", "function_declaration": "def can_split(arr, n, k, max_sum):", "function_name": "can_split", "parameter_list": "(arr, n, k, max_sum)" }, { "...
[ 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 minimize_largest_sum(arr, n, k):\n def can_partition(arr, n, k, limit):\n count, current_sum = 1, 0\n for i in range(n):\n if curre...
trial_gpt4o_2
{ "original_instruction": "You are given an integer array `arr` of size `n`. Your task is to divide the array into exactly `k` subarrays such that the largest sum of any subarray is minimized. Write a program to determine the minimized largest sum among these k subarrays.\n\n### Input\nThe input consists of:\n- The f...
0.724309
Taco_8928
C
[ "can_split", "minimize_largest_sum" ]
2
[ [ "minimize_largest_sum", "can_split" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8ccbae4fb0de748f66cd5fc8d35af565d86df1b6
01169bc991e6214eb5fded552257cedf2996fafa
v1.0
complete
Taco
Taco_9099_C
def find_min_transfer_time(n, m, edges): """ Determine the minimum amount of time required for an item produced on machine 1 to be transferred to machine N. >>> find_min_transfer_time(5, 6, [(1, 2, 4), (2, 3, 1), (3, 5, 1), (1, 4, 5), (4, 5, 2), (3, 4, 3)]) 6 >>> find_min_transfer_time(4, 2, [(1, 2, 5),...
import heapq import sys input = sys.stdin.read def find_min_transfer_time(n, m, edges): adj = [[] for _ in range(n + 1)] for u, v, t in edges: adj[u].append((v, t)) adj[v].append((u, t)) return dijkstra(adj, 1, n, n) def dijkstra(adj, start, end, n): pq = [(0, start)] dist = {...
from solution import find_min_transfer_time def test_sample_1(): N = 5 M = 6 edges = [ (1, 2, 4), (2, 3, 1), (3, 5, 1), (1, 4, 5), (4, 5, 2), (3, 4, 3) ] assert find_min_transfer_time(N, M, edges) == 6 def test_no_path(): N = 4 M = 2 edge...
[ { "docstring": null, "function_declaration": "def find_min_transfer_time(n, m, edges):", "function_name": "find_min_transfer_time", "parameter_list": "(n, m, edges)" }, { "docstring": null, "function_declaration": "def dijkstra(adj, start, end, n):", "function_name": "dijkstra", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\ninput = sys.stdin.read\n\ndef find_min_transfer_time(n, m, edges):\n adj = [[] for _ in range(n + 1)]\n for u, v, t in edges:\n ...
trial_gpt4o_0
{ "original_instruction": "A factory has a network of N machines (numbered 1 to N) connected by M conveyor belts. Each conveyor belt connects two machines and transfers items between them in a specified amount of time. The factory produces items on machine 1 and they need to be delivered to machine N.\n\nWrite a prog...
0.570792
Taco_9099
C
[ "find_min_transfer_time", "dijkstra", "main" ]
3
[ [ "find_min_transfer_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
052965dd6dda2e9bea2fc0c04ec6f23169cf9d04
da2794c8f2e41c257a21f8eb424babbd48da9357
v1.0
complete
Taco
Taco_9226_C
def palindrome_status(s: str) -> int: """ Determine the palindrome status of a string. Return 1 if the string is a palindrome. Return 0 if the string can be made a palindrome by removing one character. Return -1 otherwise. >>> palindrome_status("A man a plan a canal Panama") 1 >>> palindrom...
def is_alphanumeric(c): return c.isalnum() def is_palindrome(s): filtered_chars = list(filter(is_alphanumeric, s.lower())) return filtered_chars == filtered_chars[::-1] def can_be_palindrome_by_removing_one_char(s): filtered_chars = list(filter(is_alphanumeric, s.lower())) for i in range(len(filte...
from solution import palindrome_status def test_palindrome(): assert palindrome_status("A man a plan a canal Panama") == 1 def test_one_removal_palindrome(): assert palindrome_status("abca") == 0 def test_not_palindrome(): assert palindrome_status("abc") == -1 def test_single_character(): assert...
[ { "docstring": null, "function_declaration": "def is_alphanumeric(c):", "function_name": "is_alphanumeric", "parameter_list": "(c)" }, { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "doc...
[ 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_alphanumeric(c):\n return c.isalnum()\n\ndef is_palindrome(s):\n filtered_chars = list(filter(is_alphanumeric, s.lower()))\n return filtered_chars ...
trial_gpt4o_0
{ "original_instruction": "Ariella is learning about string manipulation in her programming course and has come across the concept of palindromes. She finds it fascinating but slightly challenging. A palindrome is a string that reads the same forward and backward, ignoring cases, spaces, and non-alphanumeric characte...
0.847262
Taco_9226
C
[ "is_alphanumeric", "is_palindrome", "can_be_palindrome_by_removing_one_char", "palindrome_status" ]
4
[ [ "can_be_palindrome_by_removing_one_char", "is_alphanumeric" ], [ "is_palindrome", "is_alphanumeric" ], [ "palindrome_status", "can_be_palindrome_by_removing_one_char" ], [ "palindrome_status", "is_palindrome" ] ]
4
[]
false
[]
false
pytest
true
[]
true
3f11609b270a72251b8fbf4f52bf5b376cbbb847
f8f20fe0937367dfbd95f4b0966ec0e523f4c945
v1.0
complete
Taco
Taco_9356_C
def process_parking_events(events): """ Process a list of parking events and calculate the fee for each car upon exit. >>> events = ["enter ABC123 2 R 09:00", "enter XYZ789 1 C 09:30", "exit ABC123 11:00"] >>> process_events(events) ["ABC123 10"] >>> events = ["enter ABC123 2 R 09:00", "enter XYZ789...
def calculate_fee(entry_time, exit_time, rate_per_hour): entry_hours, entry_minutes = map(int, entry_time.split(":")) exit_hours, exit_minutes = map(int, exit_time.split(":")) total_entry_minutes = entry_hours * 60 + entry_minutes total_exit_minutes = exit_hours * 60 + exit_minutes total_minutes = ...
import pytest from solution import process_parking_events def test_example(): events = [ "enter ABC123 2 R 09:00", "enter XYZ789 1 C 09:30", "exit ABC123 11:00", "enter EFG456 3 H 12:00", "enter HIJ101 1 E 13:00", "exit XYZ789 14:00" ] expected_output = [ ...
[ { "docstring": null, "function_declaration": "def calculate_fee(entry_time, exit_time, rate_per_hour):", "function_name": "calculate_fee", "parameter_list": "(entry_time, exit_time, rate_per_hour)" }, { "docstring": null, "function_declaration": "def process_parking_events(events):", ...
[ 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 calculate_fee(entry_time, exit_time, rate_per_hour):\n entry_hours, entry_minutes = map(int, entry_time.split(\":\"))\n exit_hours, exit_minutes = map(in...
trial_gpt4o_0
{ "original_instruction": "You are tasked with developing a software system to manage a parking lot with automated billing. The parking lot consists of different sections: Regular, Compact, Handicapped, and Electric. Each section has a limited number of parking spaces and can accommodate cars up to a specified maximu...
0.486556
Taco_9356
C
[ "calculate_fee", "process_parking_events" ]
2
[ [ "process_parking_events", "calculate_fee" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1cd353833253bc85fde31e9d300406988bd7970c
41a3522ddb88db024e2b285735fe092ddabf3b37
v1.0
complete
Taco
Taco_8796_C
import math from collections import Counter MOD = 10**9 + 7 def factorial_mod(n, mod=MOD): """ Computes the factorial of a number n modulo mod. >>> factorial_mod(5) 120 >>> factorial_mod(10) 3628800 """ result = 1 for i in range(2, n + 1): result = result * i % mod return r...
import math from collections import Counter MOD = 10**9 + 7 def factorial_mod(n, mod=MOD): result = 1 for i in range(2, n + 1): result = result * i % mod return result def distinct_permutations(s): count = Counter(s) denominator = 1 for freq in count.values(): denominator = (d...
def test_distinct_permutations_aab(): assert distinct_permutations("aab") == 3 def test_distinct_permutations_abc(): assert distinct_permutations("abc") == 6 def test_distinct_permutations_single_char(): assert distinct_permutations("a") == 1 def test_distinct_permutations_repeated_chars(): assert di...
[ { "docstring": null, "function_declaration": "def factorial_mod(n, mod=MOD):", "function_name": "factorial_mod", "parameter_list": "(n, mod=MOD)" }, { "docstring": null, "function_declaration": "def distinct_permutations(s):", "function_name": "distinct_permutations", "parameter_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom collections import Counter\n\nMOD = 10**9 + 7\n\ndef factorial(n):\n if n == 0 or n == 1:\n return 1\n return n * factorial(n - 1) %...
trial_gpt4o_2
{ "original_instruction": "The Kingdom of Magicland is controlled by a powerful wizard who maintains order by using magical seals. One day, he decided to conduct an experiment to test the abilities of his apprentices. He wants to know how many distinct ways they can arrange a series of magical seals represented by a ...
0.711838
Taco_8796
C
[ "factorial_mod", "distinct_permutations", "number_of_distinct_permutations" ]
3
[ [ "distinct_permutations", "factorial_mod" ], [ "number_of_distinct_permutations", "distinct_permutations" ] ]
2
[]
false
[]
false
pytest
false
[]
true
eb031a738e5dac9c1375cdc1c59503dd6d015b9b
920eac1bff0fc0cb701fdf7ae1f5a1a5d5477288
v1.0
complete
Taco
Taco_8983_C
def minimum_energy_costs(T, test_cases): """ Determine the minimum energy costs required to return to the center from each intersection where an event occurs. Args: T (int): Number of test cases. test_cases (List[Tuple[Tuple[int, int, int], Tuple[int], List[Tuple[int, int, int]], List[int]]]): Informat...
import heapq import sys def dijkstra(graph, start): """ Function to implement Dijkstra's algorithm to find the shortest path from the start node to all other nodes in the graph. """ n = len(graph) distances = [sys.maxsize] * n distances[start] = 0 pq = [(0, start)] # Priority queue to ...
def test_minimum_energy_costs(): T = 1 test_cases = [( (6, 8, 3), (2,), [ (1, 2, 3), (1, 3, 1), (2, 3, 1), (2, 4, 2), (3, 4, 1), (3, 5, 4), (4, 6, 2), (5, 6, 3) ], [5, 6, 3] ...
[ { "docstring": "Function to implement Dijkstra's algorithm to find the shortest path\nfrom the start node to all other nodes in the graph.", "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": null, "fun...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\nimport sys\n\ndef dijkstra(graph, start):\n \"\"\"\n Function to implement Dijkstra's algorithm to find the shortest path\n from the start n...
trial_gpt4o_0
{ "original_instruction": "A popular city has an intricate network of roads, represented as an undirected graph with N intersections and M roads. Each road has a particular energy cost associated with traversing it. There's a particularly important intersection known as the \"center\", denoted as C. Every day, severa...
0.597747
Taco_8983
C
[ "dijkstra", "minimum_energy_costs" ]
2
[ [ "minimum_energy_costs", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
82a71033a30754d1776d2d57168640414aac8fd8
5903b8b16d6411f93d5bfa2480478974bbca1917
v1.0
complete
Taco
Taco_8973_C
from typing import List def solve_crossword(n: int, m: int, grid: List[str], words: List[str]) -> int: """ Alicia is an avid puzzle enthusiast and loves filling out crosswords. However, she faces a very peculiar problem. She must fill a crossword grid consisting of n rows and m columns with the words she has alrea...
def can_place_word_horizontally(grid, word, row, col): if col + len(word) > len(grid[0]): return False for i in range(len(word)): if grid[row][col + i] == '#' or (grid[row][col + i] != '.' and grid[row][col + i] != word[i]): return False return True def can_place_word_vertically...
import pytest from solution import solve_crossword def test_example_1(): n = 4 m = 4 grid = ["....", ".#..", "....", "...."] words = ["this", "math", "cat"] assert solve_crossword(n, m, grid, words) == 3 def test_example_2(): n = 4 m = 4 grid = ["....", ".#..", ".##.", "...."] word...
[ { "docstring": null, "function_declaration": "def can_place_word_horizontally(grid, word, row, col):", "function_name": "can_place_word_horizontally", "parameter_list": "(grid, word, row, col)" }, { "docstring": null, "function_declaration": "def can_place_word_vertically(grid, word, row...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_place_word_horizontally(grid, word, row, col):\n if col + len(word) > len(grid[0]):\n return False\n for i in range(len(word)):\n if gr...
trial_gpt4o_1
{ "original_instruction": "Alicia is an avid puzzle enthusiast and loves filling out crosswords. However, she faces a very peculiar problem. She must fill a crossword grid consisting of n rows and m columns with the words she has already chosen. The grid cells are represented as a list of n strings containing '.' for...
0.605048
Taco_8973
C
[ "can_place_word_horizontally", "can_place_word_vertically", "place_word_horizontally", "place_word_vertically", "solve_crossword" ]
5
[ [ "solve_crossword", "can_place_word_horizontally" ], [ "solve_crossword", "can_place_word_vertically" ], [ "solve_crossword", "place_word_horizontally" ], [ "solve_crossword", "place_word_vertically" ] ]
4
[]
false
[]
false
pytest
true
[]
true
2fe2d0af2c77aa49fc92fb76b51b7118cc0afcf8
ee00cca86962ab2c127e5160ccd2be9bdae6d4f3
v1.0
complete
Taco
Taco_9523_C
def nth_palindromic_number(N: int) -> int: """ Function to get the N-th palindromic number. >>> nth_palindromic_number(5) 5 >>> nth_palindromic_number(11) 22 """
def is_palindrome(num): """ Helper function to check if a number is a palindrome. """ return str(num) == str(num)[::-1] def nth_palindromic_number(N): """ Function to get the N-th palindromic number. """ count = 0 num = 0 # Iterate until we find the N-th palindromic number w...
from solution import nth_palindromic_number def test_first_ten_palindromic_numbers(): assert nth_palindromic_number(1) == 1 assert nth_palindromic_number(2) == 2 assert nth_palindromic_number(3) == 3 assert nth_palindromic_number(4) == 4 assert nth_palindromic_number(5) == 5 assert nth_palindro...
[ { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Function to get the N-th palindromic number.", "function_declaration": "def nth_palind...
[ 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 nth_palindromic_number(N):\n \"\"\"\n Returns the N-th palindromic number.\n \"\"\"\n def is_palindromic(num):\n return str(num) == str(num)...
trial_gpt4o_4
{ "original_instruction": "A company wants to generate unique employee IDs for each of its employees. Every employee ID must be a palindromic number, meaning it reads the same backward as forward. Given an integer N, the company wants to know the N-th palindromic number. The first few palindromic numbers are: 1, 2, 3...
0.706911
Taco_9523
C
[ "is_palindrome", "nth_palindromic_number" ]
2
[ [ "nth_palindromic_number", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b585591070a5c5e3c8b6318e84abfe727ec2ebf9
36e44dc692e0fd3e38260e69684adc7917438b58
v1.0
complete
Taco
Taco_9269_C
import math from typing import List, Set def prime_factors(n: int) -> Set[int]: """Returns a set of distinct prime factors of n.""" # Implementation goes here pass def fortress_strength(n: int) -> int: """Returns the sum of factorials of the distinct prime factors of n. >>> fortress_strength(6) ...
import math def prime_factors(n): """Returns a set of distinct prime factors of n.""" factors = set() while n % 2 == 0: factors.add(2) n = n // 2 for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: factors.add(i) n = n // i if n > 2: ...
from solution import prime_factors, fortress_strength, total_strength_of_fortresses def test_prime_factors(): assert prime_factors(6) == {2, 3} assert prime_factors(10) == {2, 5} assert prime_factors(15) == {3, 5} assert prime_factors(17) == {17} def test_fortress_strength(): assert fortress_stren...
[ { "docstring": "Returns a set of distinct prime factors of n.", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Returns the sum of factorials of the distinct prime factors of n.", "function_declaration": "def f...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import factorial\n\ndef prime_factors(n):\n \"\"\" Return the list of distinct prime factors of a given number. \"\"\"\n factors = set()\n d = 2...
trial_gpt4o_4
{ "original_instruction": "King of Westeros wants to expand his territory by building a series of fortresses. Each fortress has a specific strength that is determined by a peculiar function. The strength of a fortress is the sum of the factorials of the number of distinct prime numbers in each of its prime factor dec...
0.60143
Taco_9269
C
[ "prime_factors", "fortress_strength", "total_strength_of_fortresses" ]
3
[ [ "fortress_strength", "prime_factors" ], [ "total_strength_of_fortresses", "fortress_strength" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fbb5c593bfa55970bdc92b9579160f3b410ff4a0
0e363d838f9fae183cc34a612e2b50c1380badc7
v1.0
complete
Taco
Taco_9482_C
from typing import List def is_prime(n: int) -> bool: """ Check if a number is prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(5) True >>> is_prime(25) False >>> is_prime(29) True """ pass def count_primes(arr: List[int]) -> int: """ Count th...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def count_primes(arr): return sum(1 for x ...
from solution import is_prime, count_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(25) == False assert is_prime(29) == True def test_count_primes_example1(): assert count_primes([2, 3...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def count_primes(arr):", "function_name": "count_primes", "parameter_list": "(arr)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Return True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return...
trial_gpt4o_1
{ "original_instruction": "### Prime Number Array\n\nAlice has an array of integers and wants to know how many prime numbers are in the array. Write a program that takes an integer array as input and outputs the count of prime numbers in the array.\n\nA prime number is an integer greater than 1 that has no positive d...
0.794524
Taco_9482
C
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2496d0188321788b38c3acd7adbfff9fce83fa6b
9951e02549030ae1b6f34e71b3aedf3e3dec1337
v1.0
complete
Taco
Taco_9431_C
def digit_sum(n: int) -> int: """ Return the digit sum of the number n. >>> digit_sum(123) 6 >>> digit_sum(456) 15 >>> digit_sum(7890) 24 """ def compute_digit_sums(numbers: List[int]) -> List[int]: """ For each number in the list `numbers`, compute the digit sum and return a list of th...
def digit_sum(n): """ Returns the digit sum of the number n. """ return sum(int(digit) for digit in str(n)) def compute_digit_sums(numbers): """ For each number in the list `numbers`, computes the digit sum and returns a list of these sums. """ return [digit_sum(number) for number i...
from solution import digit_sum, compute_digit_sums def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(456) == 15 assert digit_sum(7890) == 24 assert digit_sum(1) == 1 assert digit_sum(10**9) == 1 # 1000000000 -> digit sum is 1 assert digit_sum(999999999) == 81 # All 9s, 9*9 = 8...
[ { "docstring": "Returns the digit sum of the number n.", "function_declaration": "def digit_sum(n):", "function_name": "digit_sum", "parameter_list": "(n)" }, { "docstring": "For each number in the list `numbers`, computes the digit sum and\nreturns a list of these sums.", "function_decl...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_sum(n):\n \"\"\"\n Returns the sum of the digits of the number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef digit_sums(num...
trial_gpt4o_2
{ "original_instruction": "Linda loves playing with numbers, and she has recently come across the concept of digit sum. A digit sum of a number is the sum of all its digits. For example, the digit sum of 1234 is 1 + 2 + 3 + 4 = 10.\n\nLinda has a list of positive integers and wants to know the digit sums for each of ...
0.759145
Taco_9431
C
[ "digit_sum", "compute_digit_sums" ]
2
[ [ "compute_digit_sums", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1aa34ab1ae5b07a63b581cf59845acfb323f163c
17f9061ddbd7d0b5350cecdeeacef52049d346f4
v1.0
complete
Taco
Taco_8998_C
def find_right_angled_triangle(points: List[Tuple[int, int]]) -> str: """ Determine if there exists at least one right-angled triangle that can be formed using any three of these points. >>> find_right_angled_triangle([(0, 0), (3, 0), (3, 4), (0, 4)]) 'YES' >>> find_right_angled_triangle([(1, 2), (3, 4)...
def is_right_angle(px, py, qx, qy, rx, ry): """Helper function to check if the triangle (p, q, r) is right-angled.""" a2 = (qx - px) ** 2 + (qy - py) ** 2 b2 = (rx - qx) ** 2 + (ry - qy) ** 2 c2 = (px - rx) ** 2 + (py - ry) ** 2 sides = sorted([a2, b2, c2]) return sides[0] + sides[1] == sides[2]...
def test_case_1(): points = [(0, 0), (3, 0), (3, 4), (0, 4)] assert find_right_angled_triangle(points) == "YES" def test_case_2(): points = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)] assert find_right_angled_triangle(points) == "NO" def test_case_3(): points = [(0, 0), (0, 5), (5, 0), (2, 2), (...
[ { "docstring": "Helper function to check if the triangle (p, q, r) is right-angled.", "function_declaration": "def is_right_angle(px, py, qx, qy, rx, ry):", "function_name": "is_right_angle", "parameter_list": "(px, py, qx, qy, rx, ry)" }, { "docstring": null, "function_declaration": "de...
[ 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 itertools import combinations\n\ndef is_right_angle_triangle(p1, p2, p3):\n \"\"\"\n This function checks if the given three points form a right-angled ...
trial_gpt4o_1
{ "original_instruction": "In a 2D coordinate plane, you are given an integer n and n pairs of integers (x, y) representing the coordinates of n points. Your task is to determine if there exists at least one right-angled triangle that can be formed using any three of these points. \n\nA right-angled triangle is one t...
0.711585
Taco_8998
C
[ "is_right_angle", "find_right_angled_triangle", "main" ]
3
[ [ "find_right_angled_triangle", "is_right_angle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8b42d879b440e67bd95b915f3fcab75aa795b7e5
1892797c271ca1ba441ce667b400180090ab02f7
v1.0
complete
Taco
Taco_9095_C
def is_prime(num: int) -> bool: """Return True if the number is prime, otherwise False.""" pass def generate_prime_gaps(n: int) -> List[int]: """Generate the first n prime gaps. >>> generate_prime_gaps(1) [1] >>> generate_prime_gaps(2) [1, 2] >>> generate_prime_gaps(3) [1, 2, 2] ...
def is_prime(num): """ Return True if the number is prime, otherwise False. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: re...
from solution import is_prime, generate_prime_gaps, sum_of_prime_gaps, solve def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(15) == False def test_generate_prime_gaps(): assert generate_prime_gap...
[ { "docstring": "Return True if the number is prime, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generate the first n prime gaps.", "function_declaration": "def generate_prime_gaps(n):", "fu...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Return True if the number is prime, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n ...
trial_gpt4o_0
{ "original_instruction": "John is passionate about numbers, especially prime sequences. He recently learned about a fascinating concept called \"prime gap sequences.\" A prime gap sequence is defined as the difference between successive prime numbers. For instance, the first few prime numbers are 2, 3, 5, 7, 11, so ...
0.65361
Taco_9095
C
[ "is_prime", "generate_prime_gaps", "sum_of_prime_gaps", "solve" ]
4
[ [ "generate_prime_gaps", "is_prime" ], [ "solve", "sum_of_prime_gaps" ], [ "sum_of_prime_gaps", "generate_prime_gaps" ] ]
3
[]
false
[]
false
pytest
true
[]
true
81c9864ad2e07bb3cf614c51cbfb234b29d19cce
651be12c7fd3b6921cc078af42140f4913bc36d4
v1.0
complete
Taco
Taco_8470_C
def min_officials_needed(N: int, M: int, D: int, K: int, highways: List[Tuple[int, int]], initial_officials: List[int]) -> int: """ Determine the minimum number of officials needed to manage all fortresses in the kingdom. Input: - N: number of fortresses - M: number of highways - D: maximum number o...
from collections import deque def bfs_shortest_paths(graph, start, max_distance): distances = {} queue = deque([(start, 0)]) while queue: current_node, current_distance = queue.popleft() if current_node not in distances: distances[current_node] = current_distance if ...
def test_min_officials_needed_case1(): input_data = '''5 6 3 2 1 2 1 3 2 4 2 5 3 4 3 5 2 1 2 0 0 0 0 ''' expected_output = [2] assert parse_input(input_data) == expected_output def test_min_officials_needed_case2(): input_data = '''7 10 4 3 1 2 1 3 2 4 2 5 3 6 3 7 4 5 5 6 6 7 7 1 3 1 4 7 0 0 0 0 ''' ...
[ { "docstring": null, "function_declaration": "def bfs_shortest_paths(graph, start, max_distance):", "function_name": "bfs_shortest_paths", "parameter_list": "(graph, start, max_distance)" }, { "docstring": null, "function_declaration": "def min_officials_needed(N, M, D, K, highways, init...
[ 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 bfs_shortest_paths(graph, start, max_distance):\n distances = {}\n queue = deque([(start, 0)])\n while queue:\n ...
trial_gpt4o_0
{ "original_instruction": "Problem\n\nIn a distant kingdom, there are N fortresses connected by M bidirectional highways. The kingdom's king recently decreed that all fortresses must be directly managed by the kingdom's officials. Each official is assigned to a fortress and has two limits on their duties: they can on...
0.61146
Taco_8470
C
[ "bfs_shortest_paths", "min_officials_needed", "parse_input", "main" ]
4
[ [ "min_officials_needed", "bfs_shortest_paths" ], [ "parse_input", "min_officials_needed" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
bd7a6286354b1f299c7b4e20555c4b9fffdd77d3
687a28a1afe8c7673300b732e8f162b6678a9b0d
v1.0
complete
Taco
Taco_9274_C
def min_energy_cost(T: int, test_cases: List[Tuple[int, int, List[str], int, int, int, int]]) -> List[str]: """ Determine the minimum energy cost for robots to move in a grid, avoiding obstacles. Args: - T (int): The number of test cases. - test_cases (List[Tuple[int, int, List[str], int, int, int,...
from collections import deque def min_energy_cost(T, test_cases): def bfs(grid, start, target): N = len(grid) M = len(grid[0]) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(start[0], start[1], 0)]) visited = set() visited.add((start[0], start[1])) ...
def test_min_energy_cost(): T = 2 test_cases = [ (4, 4, ["....", ".#..", "..#.", "...."], 0, 0, 3, 3), (4, 4, ["..#.", ".#..", "..#.", "...."], 0, 1, 2, 2), ] expected = [ "Case #1: 6", "Case #2: -1" ] assert min_energy_cost(T, test_cases) == expected def test_mi...
[ { "docstring": null, "function_declaration": "def min_energy_cost(T, test_cases):", "function_name": "min_energy_cost", "parameter_list": "(T, test_cases)" }, { "docstring": null, "function_declaration": "def driver():", "function_name": "driver", "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": "from collections import deque\n\ndef min_energy_cost(T, test_cases):\n results = []\n \n directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n \n def bf...
trial_gpt4o_2
{ "original_instruction": "As a space station engineer, you are tasked with optimizing the energy consumption of robot movements in a grid. Each robot can move up, down, left, or right by one unit per move. The grid consists of `N` x `M` cells, where each cell either contains a clear path (represented by '.') or an o...
0.662877
Taco_9274
C
[ "min_energy_cost", "driver" ]
2
[ [ "driver", "min_energy_cost" ] ]
1
[]
false
[]
false
pytest
false
[]
true
7c67f850676f1d92b71f0d44cc8e541ffedca9d9
8ab0b77d17f188dbbc30af5a07e67c80e9e11f5c
v1.0
complete
Taco
Taco_9577_C
def is_progressive_number(n: int) -> bool: """ Checks if the number n is a progressive number. >>> is_progressive_number(89) True >>> is_progressive_number(135) True >>> is_progressive_number(10) False >>> is_progressive_number(123) False """ # Implement the function here de...
def is_progressive_number(n): """ Checks if the number n is a progressive number. """ digits = [int(d) for d in str(n)] total = sum(d ** (i + 1) for i, d in enumerate(digits)) return total == n def find_progressive_numbers(p, q): """ Find all progressive numbers in the range [p, q]. ...
from solution import is_progressive_number, find_progressive_numbers # Unit tests for is_progressive_number function def test_is_progressive_number_true(): assert is_progressive_number(89) == True assert is_progressive_number(135) == True def test_is_progressive_number_false(): assert is_progressive_numbe...
[ { "docstring": "Checks if the number n is a progressive number.", "function_declaration": "def is_progressive_number(n):", "function_name": "is_progressive_number", "parameter_list": "(n)" }, { "docstring": "Find all progressive numbers in the range [p, q].", "function_declaration": "def...
[ 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_progressive_number(n):\n \"\"\"\n Checks if a number n is a progressive number.\n \"\"\"\n digits = list(map(int, str(n)))\n progressive_sum ...
trial_gpt4o_4
{ "original_instruction": "A progressive number is a positive integer that, when its digits are raised to consecutive powers starting from 1, the sum of those powers equals to the number itself. For instance, 89 is a progressive number because 8^1 + 9^2 = 89.\n\nWrite a program that takes two positive integers p and ...
0.591766
Taco_9577
C
[ "is_progressive_number", "find_progressive_numbers" ]
2
[ [ "find_progressive_numbers", "is_progressive_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cb7075fdb8c650932d17b5e4fde506424adfe4d1
7c42967437a52e9132e06b9cc9eb9b4def44afe4
v1.0
complete
Taco
Taco_8935_C
def levenshtein_distance(s1: str, s2: str) -> int: """ Compute the Levenshtein distance between two strings s1 and s2. """ pass def autocorrect(dictionary: List[str], words_to_correct: List[str]) -> List[str]: """ Correct the misspelled words based on a dictionary of correct words. """ ...
def levenshtein_distance(s1, s2): """ 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) for i, c1 in enumerate(s1): ...
from solution import process_testcases def test_case_1(): testcases = [ (3, ["apple", "banana", "orange"], 2, ["appl", "bannana"]), ] expected_output = ["apple banana"] assert process_testcases(testcases) == expected_output def test_case_2(): testcases = [ (2, ["codeforces", "stac...
[ { "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 autocorrect(dictionary...
[ 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 levenshtein_distance(s1, s2):\n \"\"\"Calculate the Levenshtein distance between two strings.\"\"\"\n if len(s1) < len(s2):\n return levenshtein_d...
trial_gpt4o_2
{ "original_instruction": "A coding magazine editor wants to design a simple text editor that provides a special feature of `autocorrect`. The autocorrect function is supposed to correct misspelled words based on a given dictionary of correct words. The text editor needs to replace any misspelled words with the neare...
0.594568
Taco_8935
C
[ "levenshtein_distance", "autocorrect", "process_testcases" ]
3
[ [ "autocorrect", "levenshtein_distance" ], [ "process_testcases", "autocorrect" ] ]
2
[ "process_testcases" ]
false
[]
false
pytest
true
[]
true
ad6fbed2ca4e75a0eefd406ad39c2c4632966002
cbffa0c4017b9c23bb67c6c49ba3a2e21f524297
v1.0
complete
Taco
Taco_9351_C
def detect_cycles_in_graphs(test_cases: List[Tuple[int, int, List[Tuple[int, int]]]]) -> List[str]: """ Given a list of test cases, each representing an undirected graph, determine if each graph contains a cycle. Args: test_cases (List[Tuple[int, int, List[Tuple[int, int]]]]): A list of test cases. Eac...
def find(parent, i): if parent[i] == -1: return i return find(parent, parent[i]) def union(parent, x, y): xset = find(parent, x) yset = find(parent, y) if xset != yset: parent[xset] = yset def has_cycle(n, edges): parent = [-1] * (n + 1) for u, v in edges: x = find(...
from solution import detect_cycles_in_graphs def test_cycle_case_1(): test_cases = [ (3, 3, [(1, 2), (1, 3), (2, 3)]) ] assert detect_cycles_in_graphs(test_cases) == ["YES"] def test_cycle_case_2(): test_cases = [ (4, 2, [(1, 2), (3, 4)]) ] assert detect_cycles_in_graphs(test_c...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, x, y):", "function_name": "union", "parameter_list": "(parent, x, y)" }, { "doc...
[ 1, 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_parent(parents, node):\n if parents[node] == node:\n return node\n parents[node] = find_parent(parents, parents[node])\n return parents[no...
trial_gpt4o_2
{ "original_instruction": "Given an undirected graph with `n` vertices and `m` edges, write a program to determine if the graph contains a cycle. Each of the `m` edges connects a pair of vertices.\n\nA cycle is formed when a path exists between a node and itself with one or more edges.\n\nIf the graph contains a cycl...
0.643009
Taco_9351
C
[ "find", "union", "has_cycle", "detect_cycles_in_graphs" ]
4
[ [ "detect_cycles_in_graphs", "has_cycle" ], [ "has_cycle", "find" ], [ "has_cycle", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
985ef18276a5332d86132139ea2d626b11e89cdd
33e2ed05daa5dbb0cf10d070b5ba32ac1a30429e
v1.0
complete
Taco
Taco_8846_C
def solve(T: int, test_cases: list) -> list: """ Determine if it is possible to measure exactly the required amount of the special ingredient. Args: T (int): Number of test cases. test_cases (list): List of test cases, each containing a tuple with: - A tuple with the number of bottles and t...
def calculate_effective_capacity(C, P): """ Returns the effective capacity of the bottle after reduction. C: Original capacity of the bottle P: Percentage reduction """ return C * (100 - P) / 100 def is_possible_to_measure(M, capacities): """ Determines if it's possible to measure exact...
from solution import solve def test_example_cases(): # Sample input T = 2 test_cases = [ ((3, 50), [(100, 50), (100, 0), (100, 25)]), ((2, 75), [(100, 50), (100, 50)]) ] # Expected output expected_output = ["Yes", "No"] # Test assert solve(T, test_cases) == exp...
[ { "docstring": "Returns the effective capacity of the bottle after reduction.\nC: Original capacity of the bottle\nP: Percentage reduction", "function_declaration": "def calculate_effective_capacity(C, P):", "function_name": "calculate_effective_capacity", "parameter_list": "(C, P)" }, { "do...
[ 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": "# Function to calculate the effective volume after percentage reduction\ndef effective_volume(C, P):\n return C * (1 - P / 100)\n\n# Function to check if we can...
trial_gpt4o_2
{ "original_instruction": "Professor Snape is brewing a magical potion and needs exactly $M$ milliliters of a special ingredient. He has several bottles, each containing a different amount of the special ingredient. However, he noticed that some bottles might be enchanted, reducing the content by a fixed percentage a...
0.618958
Taco_8846
C
[ "calculate_effective_capacity", "is_possible_to_measure", "can_measure_special_ingredient", "solve" ]
4
[ [ "can_measure_special_ingredient", "calculate_effective_capacity" ], [ "can_measure_special_ingredient", "is_possible_to_measure" ], [ "solve", "can_measure_special_ingredient" ] ]
3
[]
false
[]
false
pytest
true
[]
true
7752855d95248cacf2f84678c9cf62b602718e72
d82b084509b97f0c6639b6687e15f23c242156d6
v1.0
complete
Taco
Taco_9562_C
def get_shortest_path_length(n: int, m: int, grid: List[List[str]]) -> int: """ Calculate the length of the shortest path from the top-left to the bottom-right corner in a 2D grid. >>> get_shortest_path_length(3, 3, [['0', '1', '0'], ['0', '0', '0'], ['1', '1', '0']]) 4 >>> get_shortest_path_length(4, 4...
from collections import deque def get_shortest_path_length(n, m, grid): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Up, Down, Left, Right queue = deque([(0, 0, 0)]) # (x, y, distance) visited = set((0, 0)) while queue: x, y, dist = queue.popleft() if x == n-1 and y...
def test_get_shortest_path_length_1(): grid = [ ['0', '1', '0'], ['0', '0', '0'], ['1', '1', '0'] ] assert get_shortest_path_length(3, 3, grid) == 4 def test_get_shortest_path_length_2(): grid = [ ['0', '0', '1', '0'], ['1', '0', '1', '0'], ['0', '0', '0'...
[ { "docstring": null, "function_declaration": "def get_shortest_path_length(n, m, grid):", "function_name": "get_shortest_path_length", "parameter_list": "(n, m, grid)" }, { "docstring": null, "function_declaration": "def input_and_calculate_shortest_path():", "function_name": "input_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(N, M, grid):\n \"\"\"\n Returns the length of the shortest path in a grid from the top-left corner to the ...
trial_gpt4o_1
{ "original_instruction": "In a 2D grid of size N x M, you are to find the shortest path from the top-left corner (0,0) to the bottom-right corner (N-1,M-1). However, certain cells are blocked and cannot be traversed.\n\nYou are allowed to move up, down, left, or right, but cannot move diagonally. Your task is to cal...
0.708225
Taco_9562
C
[ "get_shortest_path_length", "input_and_calculate_shortest_path" ]
2
[ [ "input_and_calculate_shortest_path", "get_shortest_path_length" ] ]
1
[]
false
[]
false
pytest
false
[]
true
0453be0245e0dd581a88986bf09a0c0042320820
9d7c4b93ee5b7118e5d8951f553fa45e16012997
v1.0
complete
Taco
Taco_9833_C
def max_compatible_tasks(test_cases): """ Find the maximum number of compatible tasks from the given list of test cases. >>> max_compatible_tasks([[(1, 3), (2, 5), (4, 6)]]) [2] >>> max_compatible_tasks([[(1, 2), (3, 4), (0, 5), (8, 9)]]) [3] """ def parse_input(input_str): """ Parse the input ...
def max_compatible_tasks(test_cases): results = [] for tasks in test_cases: # Sort tasks by their end times for the greedy algorithm tasks.sort(key=lambda x: x[1]) max_tasks = 0 last_end_time = -1 for start, end in tasks: if start >= last_en...
import pytest from solution import parse_input, max_compatible_tasks, solve def test_parse_input(): input_str = "3\n1 3\n2 5\n4 6\n4\n1 2\n3 4\n0 5\n8 9\n0\n" expected = [ [(1, 3), (2, 5), (4, 6)], [(1, 2), (3, 4), (0, 5), (8, 9)], ] assert parse_input(input_str) == expected def test_...
[ { "docstring": null, "function_declaration": "def max_compatible_tasks(test_cases):", "function_name": "max_compatible_tasks", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "paramete...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_compatible_tasks(test_cases):\n results = []\n for tasks in test_cases:\n tasks.sort(key=lambda x: x[1]) # Sort tasks based on end time\n ...
trial_gpt4o_1
{ "original_instruction": "You are given a list of tasks. Each task is represented by a start time and an end time. Two tasks are compatible if they do not overlap. Your goal is to find the maximum number of compatible tasks from the given list.\n\nA task `(s1, e1)` is considered compatible with another task `(s2, e2...
0.559938
Taco_9833
C
[ "max_compatible_tasks", "parse_input", "solve" ]
3
[ [ "solve", "max_compatible_tasks" ], [ "solve", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
e8eb075fabf249a075e85ce1c4c515ba663e7f17
1e0a0c2a7c6d2649e0b23821273b72c5efc4245c
v1.0
complete
Taco
Taco_9467_C
def is_prime(n): """ Check if a number is a prime number. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(17) True """ def is_fibonacci(n): """ Check if a number is a Fibonacci number. >>> is_fibonacci(0) True >>> is_fibonacci(1) True >>> is_fibo...
def is_prime(n): if n <= 1: return False if n == 2 or n == 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def is_fibonacci(n): if n < 0: ...
from solution import is_prime, is_fibonacci, is_special_fibonacci_number, special_fibonacci_numbers def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(1) == False assert is_prime(0) == False asse...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_fibonacci(n):", "function_name": "is_fibonacci", "parameter_list": "(n)" }, { "docstring": null, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n ...
trial_gpt4o_1
{ "original_instruction": "Arjun and Beena are participating in a coding competition where they need to find out if a specific number is a \"Special Fibonacci Number\". Arjun loves Fibonacci numbers, and Beena admires prime numbers. So, they combined their interests and came up with the following definition:\n\nA num...
0.783518
Taco_9467
C
[ "is_prime", "is_fibonacci", "is_special_fibonacci_number", "special_fibonacci_numbers" ]
4
[ [ "is_special_fibonacci_number", "is_fibonacci" ], [ "is_special_fibonacci_number", "is_prime" ], [ "special_fibonacci_numbers", "is_special_fibonacci_number" ] ]
3
[]
false
[]
false
pytest
true
[]
true
49d2cc532e1393436132708be819747898649b5d
b2ff9f741156739a1852bd80df0dcb5313941310
v1.0
complete
Taco
Taco_9381_C
def product_except_self(arr): """ Given an array arr, returns a new array such that each element at index i is equal to the product of all the elements of arr except arr[i], without using division. """ def solve(test_cases): """ Solves the problem for all the given test cases. """ def ...
def product_except_self(arr): """ Given an array arr, returns a new array such that each element at index i is equal to the product of all the elements of arr except arr[i], without using division. """ n = len(arr) if n == 0: return [] # Initialize the left and right product arrays ...
def test_product_except_self(): assert product_except_self([1, 2, 3]) == [6, 3, 2] assert product_except_self([2, 3, 4, 5]) == [60, 40, 30, 24] assert product_except_self([1, 1, 1, 1]) == [1, 1, 1, 1] assert product_except_self([1, 2, 0]) == [0, 0, 2] assert product_except_self([0, 0, 0]) == [0, 0, ...
[ { "docstring": "Given an array arr, returns a new array such that each element at index i is\nequal to the product of all the elements of arr except arr[i], without using division.", "function_declaration": "def product_except_self(arr):", "function_name": "product_except_self", "parameter_list": "(...
[ 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 product_except_self(arr):\n \"\"\"\n Given an array arr, returns a new array such that each element at index i is\n equal to the product of all the el...
trial_gpt4o_0
{ "original_instruction": "Albert has a challenge for you: Given an array of integers, for each element in the array compute the product of all the elements in the array except the element at the current position. You are required to solve this without using division.\n\nInput Format:\nThe first line contains T, the ...
0.567647
Taco_9381
C
[ "product_except_self", "solve", "parse_input", "format_output" ]
4
[ [ "solve", "product_except_self" ] ]
1
[ "parse_input", "format_output" ]
false
[]
false
pytest
false
[]
true
429034f99b845047e127ed2ae1985aa5ce74e2e5
64063225655ca746d9cbe9e6935e6143e0b73dff
v1.0
complete
Taco
Taco_10005_C
def performance_metrics(times): """ This function takes a list of times taken to solve problems and returns a tuple containing: - the shortest time - the longest time - the average time - the median time >>> performance_metrics([120, 150, 300, 50, 90]) == (50.00, 300.00, 142.00, ...
def performance_metrics(times): """ This function takes a list of times taken to solve problems and returns a tuple containing: - the shortest time - the longest time - the average time - the median time """ n = len(times) if n == 0: return 0.00, 0.00, 0.00, 0.00 tim...
from solution import performance_metrics, metrics_from_input def test_performance_metrics_single_entry(): assert performance_metrics([100]) == (100.00, 100.00, 100.00, 100.00) def test_performance_metrics_odd_entries(): assert performance_metrics([120, 150, 300, 50, 90]) == (50.00, 300.00, 142.00, 120.00) de...
[ { "docstring": "This function takes a list of times taken to solve problems and returns a tuple containing:\n- the shortest time\n- the longest time\n- the average time\n- the median time", "function_declaration": "def performance_metrics(times):", "function_name": "performance_metrics", "parameter_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def performance_summary(n, times):\n \"\"\"\n Computes and returns the shortest, longest, average, and median time from the given list of times.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "Emma loves programming contests. When she practices, she likes to simulate competitions by solving several problems in a row. She wants to track her performance by recording the time taken to solve each problem. After a session, she realizes that she wants a summary of her performance: the ...
0.615613
Taco_10005
C
[ "performance_metrics", "metrics_from_input" ]
2
[ [ "metrics_from_input", "performance_metrics" ] ]
1
[]
false
[]
false
pytest
true
[]
true
01d243f58689aef7952e8f74ac44d6d2ecb14880
80268d5c74aa72c79a5d9f70d8dbbb2d6dae6d47
v1.0
complete
Taco
Taco_9645_C
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sum_of_left_leaves_from_input(data: str) -> int: """ Given a binary tree in level order traversal, find the sum of all left leaves in the tree. A leaf is a no...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def sumOfLeftLeaves(root): if not root: return 0 def is_leaf(node): return node and not node.left and not node.right left_sum = 0 if ro...
from solution import sum_of_left_leaves_from_input def test_sum_of_left_leaves_case_1(): tree_input = "3 9 20 null null 15 7" assert sum_of_left_leaves_from_input(tree_input) == 24 def test_sum_of_left_leaves_with_no_left_leaves(): tree_input = "1 null 2 null 3 null 4 null 5" assert sum_of_left_leaves...
[]
[ 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 TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef sumOfLe...
trial_gpt4o_5
{ "original_instruction": "Given a binary tree, write a program to find the sum of all left leaves in the tree. A leaf is a node with no children, and a left leaf is a leaf that is the left child of its parent.\n\n------ Input details ------ \n\nThe input consists of the binary tree in level order traversal, with 'n...
0.583155
Taco_9645
C
[ "sumOfLeftLeaves", "build_tree_from_level_order", "sum_of_left_leaves_from_input" ]
3
[ [ "sum_of_left_leaves_from_input", "build_tree_from_level_order" ], [ "sum_of_left_leaves_from_input", "sumOfLeftLeaves" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
583f09a25a6102ab23c76c3af68c793f19530678
9bd7b7458b81b13eadafc6fa96267f34f6bb472a
v1.0
complete
Taco
Taco_9081_C
def shortest_path(grid, startX, startY, endX, endY): """ Determine the shortest path from the starting to the ending position on a grid, avoiding obstacles. If the delivery location is unreachable, return -1. Args: grid (List[List[int]]): NxN grid where '0' indicates an open space and '1' indicates a bu...
from collections import deque def shortest_path(grid, startX, startY, endX, endY): N = len(grid) directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] queue = deque([(startX, startY, 0)]) # (x, y, distance) visited = set((startX, startY)) while queue: x, y, dist = queue.popleft() ...
def test_single_case_reachable(): input_str = "1\n5\n0 0 1 0 0\n0 0 1 0 0\n0 0 0 1 1\n1 1 0 0 0\n0 0 0 0 0\n0 0 4 4" expected_output = "8" assert main(input_str) == expected_output def test_single_case_unreachable(): input_str = "1\n4\n0 0 1 1\n1 1 0 0\n0 0 0 0\n1 0 0 0\n3 0 0 1" expected_output = ...
[ { "docstring": null, "function_declaration": "def shortest_path(grid, startX, startY, endX, endY):", "function_name": "shortest_path", "parameter_list": "(grid, startX, startY, endX, endY)" }, { "docstring": null, "function_declaration": "def solve_drone_delivery(test_cases):", "func...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(grid, startX, startY, endX, endY):\n \"\"\"\n Uses BFS to find the shortest path in a grid from (startX, s...
trial_gpt4o_2
{ "original_instruction": "You are managing a fleet of delivery drones that operate within a grid city. Each grid cell can be either an open space or a building that a drone cannot fly through. Your task is to write a program to guide a drone from a starting position to a delivery location while ensuring it does not ...
0.607584
Taco_9081
C
[ "shortest_path", "solve_drone_delivery", "parse_input", "main" ]
4
[ [ "solve_drone_delivery", "shortest_path" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
false
[]
true
2f004dad639b823edb5dd16d8afbd305070c5bbb
81a23013ecd520cce96b58a815555070b601721b
v1.0
complete
Taco
Taco_10255_C
def generate_subsets(s: str): """Generate all unique subsets of the string `s` in lexicographic order. Args: s: A string consisting of lowercase alphabetic characters. Returns: A list of unique subsets of `s` in lexicographic order. Examples: >>> generate_subsets("...
def generate_subsets(s): """ This function generates all unique subsets of the string `s` in lexicographic order. """ subsets = set() def backtrack(start, path): # Add current subset to the set subsets.add("".join(path)) for i in range(start, len(s)): # Include t...
from solution import generate_subsets def test_generate_subsets_example1(): assert generate_subsets("abc") == ['', 'a', 'ab', 'abc', 'ac', 'b', 'bc', 'c'] def test_generate_subsets_example2(): assert generate_subsets("aab") == ['', 'a', 'aa', 'aab', 'ab', 'b'] def test_generate_subsets_single_char(): ass...
[ { "docstring": "This function generates all unique subsets of the string `s` in lexicographic order.", "function_declaration": "def generate_subsets(s):", "function_name": "generate_subsets", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def print_subsets(s):",...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef unique_subsets(s):\n \"\"\"\n Generate all unique subsets of the string in lexicographic order.\n \"\"\"\n # ...
trial_gpt4o_3
{ "original_instruction": "For a given string \\( s \\), print all unique subsets of the string in lexicographic order. Each subset should appear on a new line. Subsets can be empty or contain all characters of the string in any order, but no subset should appear more than once.\n\nConstraints\n\n* \\( 1 \\leq |s| \\...
0.611156
Taco_10255
C
[ "generate_subsets", "print_subsets" ]
2
[ [ "print_subsets", "generate_subsets" ] ]
1
[]
false
[]
false
pytest
true
[]
true
67ac93c5e743082405b719be96af7c2c165cafbe
b5bdcbf3c5a4a3fe1f53703ebfe8df6c7942672d
v1.0
complete
Taco
Taco_9433_C
import math from typing import List def calculate_polyhedron_volume(vertices: List[List[float]], faces: List[List[int]]) -> float: """ Given vertex coordinates and triangular face indices, calculate the volume of the polyhedron. >>> vertices = [ [0.00000, 0.00000, 0.00000], [1.00000, 0....
import sys import math def vector_cross(a, b): return [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]] def dot_product(a, b): return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] def volume_of_tetrahedron(v1, v2, v3, v4): vec1 = [v2[i] - v1[i] for i in range(3)] vec2 = [v3[i] - v1[i] for i i...
from solution import calculate_polyhedron_volume def test_tetrahedron_volume(): vertices = [ [0.00000, 0.00000, 0.00000], [1.00000, 0.00000, 0.00000], [0.00000, 1.00000, 0.00000], [0.00000, 0.00000, 1.00000], ] faces = [ [1, 2, 3], [1, 2, 4], [1, 3, 4...
[ { "docstring": null, "function_declaration": "def vector_cross(a, b):", "function_name": "vector_cross", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def dot_product(a, b):", "function_name": "dot_product", "parameter_list": "(a, b)" }, { "d...
[ 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 volume_of_polyhedron(vertices, faces):\n def vector_cross_product(a, b):\n return (\n a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] ...
trial_gpt4o_8
{ "original_instruction": "A massive space mining project is underway in the Andromeda galaxy. One of the main milestones of this project is to deploy mining robots on asteroids. Each asteroid is modeled as a polyhedron in a three-dimensional space. Before deploying the robots, scientists need to calculate the volume...
0.650793
Taco_9433
C
[ "vector_cross", "dot_product", "volume_of_tetrahedron", "calculate_polyhedron_volume", "parse_input", "main" ]
6
[ [ "calculate_polyhedron_volume", "volume_of_tetrahedron" ], [ "volume_of_tetrahedron", "dot_product" ], [ "volume_of_tetrahedron", "vector_cross" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
ca349f51ccbab452dc8bf630eb236864584a2c3a
7179d3b4b62b20ccb382ae466b3e53648a0cb0f4
v1.0
complete
Taco
Taco_9882_C
from typing import List def find_idle_employees(employee_data: List[str], threshold: int) -> List[str]: """ Calculate the total idle time for each employee given their login and logout timestamps and output the IDs of employees who exceed a specified idle time threshold. Args: employee_data : List...
from datetime import datetime def calculate_idle_time(log_pairs): idle_time = 0 for i in range(1, len(log_pairs), 2): logout_time = datetime.strptime(log_pairs[i], "%H:%M") if i+1 < len(log_pairs): next_login_time = datetime.strptime(log_pairs[i+1], "%H:%M") idle_ti...
from solution import find_idle_employees def test_no_idle_time_violations(): employee_data = ["1", "60", "E001 09:00,12:00"] result = find_idle_employees(employee_data, 60) assert result == ["NO IDLE TIME VIOLATIONS"] def test_single_idle_violation(): employee_data = ["1", "30", "E001 09:00,09:30,10:0...
[ { "docstring": null, "function_declaration": "def calculate_idle_time(log_pairs):", "function_name": "calculate_idle_time", "parameter_list": "(log_pairs)" }, { "docstring": null, "function_declaration": "def find_idle_employees(employee_data, threshold):", "function_name": "find_idl...
[ 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 datetime import datetime\n\ndef parse_time(time_str):\n return datetime.strptime(time_str, \"%H:%M\")\n\ndef calculate_total_idle_time(logins_logouts):\n ...
trial_gpt4o_4
{ "original_instruction": "A company wants to monitor its employees' activity to ensure they are not idle during their working hours. Each employee has a unique ID and a list of timestamps representing their login and logout times (in pairs) throughout the day. The company defines \"idle time\" as the total amount of...
0.587986
Taco_9882
C
[ "calculate_idle_time", "find_idle_employees" ]
2
[ [ "find_idle_employees", "calculate_idle_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9917e437da51f617d27555f9ae6082e627d7b5ee
5080e3478537922e9c0275882a779bec28a18ea6
v1.0
complete
Taco
Taco_7758_C
def is_equal_weighted(s: str) -> bool: """ Determine if the given string is equal-weighted, meaning the sum of the first half of the string equals the sum of the second half. >>> is_equal_weighted("123321") True >>> is_equal_weighted("456654") True >>> is_equal_weighted("112233") F...
def is_equal_weighted(s): n = len(s) first_half = s[:n//2] second_half = s[n//2:] return sum(map(int, first_half)) == sum(map(int, second_half)) def check_strings(t, strings): results = [] for s in strings: if is_equal_weighted(s): results.append("YES") else: ...
from solution import is_equal_weighted, check_strings def test_is_equal_weighted(): assert is_equal_weighted("123321") == True assert is_equal_weighted("456654") == True assert is_equal_weighted("112233") == False assert is_equal_weighted("111111") == True assert is_equal_weighted("123456") == Fals...
[ { "docstring": null, "function_declaration": "def is_equal_weighted(s):", "function_name": "is_equal_weighted", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def check_strings(t, strings):", "function_name": "check_strings", "parameter_list": "(t, strin...
[ 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_equal_weighted(s):\n \"\"\"\n Returns 'YES' if the sum of the first half of the string equals the sum of the second half,\n otherwise returns 'NO'....
trial_gpt4o_2
{ "original_instruction": "In a distant galaxy, there are special droids that communicate using a unique string language. Each string consists of digits from 0 to 9. The droids have discovered that some strings are \"equal-weighted\" if the sum of the first half of the string equals the sum of the second half.\n\nYou...
0.642128
Taco_7758
C
[ "is_equal_weighted", "check_strings" ]
2
[ [ "check_strings", "is_equal_weighted" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e60f65e4530b422b94725eec41a0ecc9f1c4a7a
b57f491e81f52c68c076a2c94942e2930063a431
v1.0
complete
Taco
Taco_10179_C
def check_maxitree(n: int, nodes_info: List[Tuple[int, int, int, int]]) -> str: """ Determine whether the given binary tree is a MaxiTree. >>> check_maxitree(5, [(0, 10, 1, 2), (1, 5, -1, -1), (2, 10, 3, 4), (3, 5, -1, -1), (4, 2, -1, -1)]) "Yes" >>> check_maxitree(3, [(0, 5, 1, 2), (1, 10, -1, -1), (2, 3, ...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes_info): nodes = {} for index, value, left, right in nodes_info: if index not in nodes: nodes[index] = TreeNode(value) else: no...
from solution import check_maxitree def test_example(): n = 5 nodes_info = [ (0, 10, 1, 2), (1, 5, -1, -1), (2, 10, 3, 4), (3, 5, -1, -1), (4, 2, -1, -1) ] assert check_maxitree(n, nodes_info) == "Yes" def test_single_node(): n = 1 nodes_info = [ ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, index, value):\n self.index = index\n self.value = value\n self.left = None\n self.right = None\n\n...
trial_gpt4o_1
{ "original_instruction": "In a certain kingdom, there's a peculiar type of tree called a MaxiTree. The uniqueness of this tree lies in its nodes' arrangement. You are given a binary tree, where each node has a value. Your task is to determine whether this binary tree is a MaxiTree. \n\nA tree is considered a MaxiTre...
0.567103
Taco_10179
C
[ "build_tree", "is_maxitree", "check_maxitree" ]
3
[ [ "check_maxitree", "build_tree" ], [ "check_maxitree", "is_maxitree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
91a1b3bbe1dbd1a731f4d106deecaffe62e1bec3
9ec436d572122de99b8962a8436219a6468ef87f
v1.0
complete
Taco
Taco_10549_C
def isPrimeList(arr): """ Returns a list of booleans indicating whether each integer in the input list is a prime number. >>> isPrimeList([2, 3, 4, 5, 6]) [True, True, False, True, False] >>> isPrimeList([10, 13, 17, 19, 20]) [False, True, True, True, False] """
import math def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return Fals...
from solution import isPrimeList def test_is_prime_list_example_1(): assert isPrimeList([2, 3, 4, 5, 6]) == [True, True, False, True, False] def test_is_prime_list_example_2(): assert isPrimeList([10, 13, 17, 19, 20]) == [False, True, True, True, False] def test_is_prime_list_single_prime(): assert isPri...
[ { "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 a list of booleans indicating whether each integer in the input list is a prime number.", "function...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number is a prime number.\n :param n: Integer\n :return: Boolean - True if n is a prime n...
trial_gpt4o_2
{ "original_instruction": "Write a function that takes a list of integers and returns a list of booleans indicating whether each integer is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\n\nExample 1:\nInput:\narr = [2, 3, 4, 5, 6]\nOutput:\n[T...
0.780963
Taco_10549
C
[ "is_prime", "isPrimeList" ]
2
[ [ "isPrimeList", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c6b57c0b21d38ca962d3d5763d14a1d5b43e2ec0
fe91d1fd30ff7654be87be5d89799f0d8cc3d55b
v1.0
complete
Taco
Taco_10214_C
from typing import List, Tuple, Union def arrange_stations(n: int, m: int, constraints: List[Tuple[int, int]]) -> Union[Tuple[int, ...], str]: """ Determine if it is possible to arrange all n stations satisfying the given constraints. Args: n: int - representing the number of stations. m: int - re...
import itertools def is_valid(arrangement, constraints): """ Check if a given arrangement satisfies all the adjacency constraints. """ for (x, y) in constraints: for a, b in zip(arrangement, arrangement[1:]): if (a == x and b == y) or (a == y and b == x): return Fals...
from solution import arrange_stations def test_simple_case_possible(): n = 4 m = 2 constraints = [(1, 2), (3, 4)] result = arrange_stations(n, m, constraints) assert result != "No arrangement possible" assert isinstance(result, tuple) and len(result) == 4 def test_simple_case_not_possible(...
[ { "docstring": "Check if a given arrangement satisfies all the adjacency constraints.", "function_declaration": "def is_valid(arrangement, constraints):", "function_name": "is_valid", "parameter_list": "(arrangement, constraints)" }, { "docstring": "Determines if it is possible to arrange al...
[ 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 itertools\n\ndef is_valid(arrangement, constraints):\n \"\"\"\n Check if a given arrangement satisfies all the adjacency constraints.\n \"\"\"\n ...
trial_gpt4o_0
{ "original_instruction": "Кate is organizing a charity event and needs to set up different activity stations. She needs to arrange n different stations linearly in such a way that certain pairs of stations must not be directly next to each other due to space constraints and safety guidelines. The pairs that must avo...
0.668392
Taco_10214
C
[ "is_valid", "arrange_stations" ]
2
[ [ "arrange_stations", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b055dcc3de23f66017e261505d0a346b215f0a7e
4fc90c7787558d7c0572d1a5b768a6b3d2651953
v1.0
complete
Taco
Taco_9168_C
def minimum_latency(n: int, m: int, edges: List[Tuple[int, int, int]], s: int, d: int) -> int: """ Determines the shortest path in terms of latency from the source computer to the destination computer in a networking system. Parameters: n (int): The number of computers in the network. m (int): The ...
import heapq def dijkstra(n, edges, source, destination): """ Function to calculate the minimum latency to send a message from the source to the destination computer. Parameters: n (int): Number of computers edges (list of tuples): List of edges where each edge is represented as (u, v,...
def test_simple_case(): n = 5 m = 5 edges = [(0, 1, 10), (0, 2, 5), (1, 3, 1), (2, 1, 3), (3, 4, 4)] source = 0 destination = 4 assert minimum_latency(n, m, edges, source, destination) == 13 def test_direct_connection(): n = 3 m = 3 edges = [(0, 1, 1), (1, 2, 1), (0, 2, 10)] sou...
[ { "docstring": "Function to calculate the minimum latency to send a message from the source to the destination computer.\n\nParameters:\n n (int): Number of computers\n edges (list of tuples): List of edges where each edge is represented as (u, v, w)\n source (int): Source computer\n destination (in...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, edges, source, destination):\n \"\"\"\n Function to calculate the minimum latency to send a message from the source to the de...
trial_gpt4o_0
{ "original_instruction": "In a networking system, computers are interconnected such that messages can be sent from one computer to another through various paths. Each computer has a unique identifier, and communication paths have different latencies associated with them. In this system, a message can be sent from on...
0.545743
Taco_9168
C
[ "dijkstra", "minimum_latency" ]
2
[ [ "minimum_latency", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e63b9f7fd5b39812de76c8e8bdce04d87c48388d
53806e44887dd44054b8d2b81457d53e93c0cca5
v1.0
complete
Taco
Taco_8575_C
def solve(t: int, test_cases: List[Tuple[Tuple[int, int], List[str]]]) -> List[str]: """ Determine if there is a path from the start ('S') to the end ('E') in each maze. >>> solve(3, [((4, 4), ["S...", ".##.", ".#..", "...E"]), ... ((4, 4), ["S.#.", ".##.", ".#..", "#..E"]), ... ((3,...
def can_reach_end(matrix, start, end, n, m): from collections import deque # Directions for moving up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # BFS setup queue = deque([start]) visited = set() visited.add(start) while queue: current = que...
import pytest from solution import solve def test_example_cases(): assert solve(3, [((4, 4), ["S...", ".##.", ".#..", "...E"]), ((4, 4), ["S.#.", ".##.", ".#..", "#..E"]), ((3, 3), ["S#E", "###", "###"])]) == ['YES', 'NO', 'NO'] def test_no_path(): assert solve(1, [((...
[ { "docstring": null, "function_declaration": "def can_reach_end(matrix, start, end, n, m):", "function_name": "can_reach_end", "parameter_list": "(matrix, start, end, n, m)" }, { "docstring": null, "function_declaration": "def solve(t, test_cases):", "function_name": "solve", "pa...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_path_possible(mazes):\n def valid_position(x, y, n, m):\n return 0 <= x < n and 0 <= y < m\n \n def bfs(start, end, maze):\n from col...
trial_gpt4o_2
{ "original_instruction": "You are given a matrix representing a maze consisting of $n$ rows and $m$ columns. The maze contains obstacles ('#'), open paths ('.'), a start point ('S'), and an end point ('E'). Your goal is to determine whether there is a path from the start point to the end point. You can only move up,...
0.597791
Taco_8575
C
[ "can_reach_end", "solve" ]
2
[ [ "solve", "can_reach_end" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5c2e433e3e6061c23f4eaf9b52c87c0469a90e11
e550d8629586d0a2d932f77cb496687740a1e8be
v1.0
complete
Taco
Taco_9924_C
def is_prime(num): """ Checks if a number is prime. """ pass def calculate_sum_of_primes_in_list(num_list): """ Calculates the sum of prime numbers in the provided list. """ pass def solve_prime_sum_problem(T, test_cases): """ Solves the problem of finding the sum of prime numb...
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += ...
from solution import is_prime, calculate_sum_of_primes_in_list, solve_prime_sum_problem def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(17) == True assert is_prime(20) == False assert is_prime(...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Calculates the sum of prime numbers in the provided list.", "function_declaration": "def calculate_sum_of_primes_in_list(...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if an integer is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_1
{ "original_instruction": "Nyx, a computer science student, loves solving number theory problems. One day, she comes across a fascinating problem related to prime numbers. She decided to solve it using her coding skills but quickly realized that it requires a highly optimized approach due to the large constraints. Gi...
0.71671
Taco_9924
C
[ "is_prime", "calculate_sum_of_primes_in_list", "solve_prime_sum_problem" ]
3
[ [ "calculate_sum_of_primes_in_list", "is_prime" ], [ "solve_prime_sum_problem", "calculate_sum_of_primes_in_list" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6704bb4a858e08034acdc6c7bd3391dd57f962af
a6e378b1731c336ceba49b81ff0d1a2505961d5c
v1.0
complete
Taco
Taco_10457_C
def sieve_of_eratosthenes(n: int) -> List[int]: """ Generates all prime numbers up to n using the sieve of Eratosthenes. """ pass def kth_prime(k: int) -> int: """ Returns the k-th prime number. >>> kth_prime(1) # 2 >>> kth_prime(5) # 11 >>> kth_prime(10) # 29 """ pass def ...
def sieve_of_eratosthenes(n): """ Generates all prime numbers up to n using the sieve of Eratosthenes. """ is_prime = [True] * (n + 1) p = 2 while p * p <= n: if is_prime[p]: for i in range(p * p, n + 1, p): is_prime[i] = False p += 1 primes = [p f...
from solution import kth_prime, process_primes def test_sieve_of_eratosthenes(): from solution import sieve_of_eratosthenes assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_kth_prime(): assert kth_prime(1) == 2 assert kth_pr...
[ { "docstring": "Generates all prime numbers up to n using the sieve of Eratosthenes.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns the k-th prime number.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(n):\n \"\"\"\n Returns all prime numbers up to n (inclusive) using the Sieve of Eratosthenes.\n \"\"\"\n is_prime = [True] * ...
trial_gpt4o_1
{ "original_instruction": "Aradhana loves prime numbers, and she has challenged the boys in her class to a game. She will select a number `k`, and the nth boy who wants to impress her must find the `k`th prime number. Since some of the boys are not well-versed in programming, they have asked for your help to determin...
0.68609
Taco_10457
C
[ "sieve_of_eratosthenes", "kth_prime", "process_primes" ]
3
[ [ "kth_prime", "sieve_of_eratosthenes" ], [ "process_primes", "kth_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c85b86d217eca8f1e81ba42023b0c3f81d36b6e9
5c1ed76e5635f02e780ff5891e23d5b41171c54b
v1.0
complete
Taco
Taco_10449_C
def task_management(input_lines: List[str]) -> str: """Determine a valid sequence to complete the tasks based on dependencies. The input consists of multiple lines where the first line contains a single integer N representing the number of tasks. Each of the next N lines contains a task followed by its...
from collections import defaultdict, deque def find_task_order(N, dependencies): # Create an adjacency list and compute in-degrees of each task adj_list = defaultdict(list) in_degree = {i: 0 for i in range(1, N+1)} for task, deps in dependencies.items(): for dep in deps: adj_list[d...
from solution import task_management def test_sample_input_1(): input_lines = [ "4", "1 2 -1", "2 3 -1", "3 4 -1", "4 -1" ] assert task_management(input_lines) == "4 3 2 1" def test_sample_input_2(): input_lines = [ "3", "1 2 -1", "2 3 -1...
[ { "docstring": null, "function_declaration": "def find_task_order(N, dependencies):", "function_name": "find_task_order", "parameter_list": "(N, dependencies)" }, { "docstring": null, "function_declaration": "def parse_input(input_lines):", "function_name": "parse_input", "parame...
[ 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef find_task_order(N, task_dependencies):\n graph = defaultdict(list)\n indegree = defaultdict(int)\n \n ...
trial_gpt4o_8
{ "original_instruction": "Anant is working on a system where he needs to manage tasks with dependencies. Each task is represented with a unique identifier from 1 to N. Some tasks have dependencies, meaning that a task can only be started after specific tasks have been completed. \n\nThe input consists of multiple li...
0.542381
Taco_10449
C
[ "find_task_order", "parse_input", "task_management" ]
3
[ [ "task_management", "find_task_order" ], [ "task_management", "parse_input" ] ]
2
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
d1fad1b19d9471d0e54a5db9a6e136a78cdbddc1
3da27bec201fb0fa6c29828fbe384fa5cb94a25b
v1.0
complete
Taco
Taco_10825_C
def canSplitIntoThreePalindromicSubstrings(s: str) -> bool: """ Determines if the string s can be split into exactly three non-empty palindromic substrings. >>> canSplitIntoThreePalindromicSubstrings("abacaba") True >>> canSplitIntoThreePalindromicSubstrings("abcd") False """
def is_palindrome(sub): """ Checks if a given string is a palindrome. """ return sub == sub[::-1] def canSplitIntoThreePalindromicSubstrings(s): """ Determines if the string s can be split into exactly three non-empty palindromic substrings. """ n = len(s) # Loop through p...
from solution import canSplitIntoThreePalindromicSubstrings def test_example_case_1(): assert canSplitIntoThreePalindromicSubstrings("abacaba") == True def test_example_case_2(): assert canSplitIntoThreePalindromicSubstrings("abcd") == False def test_single_character(): assert canSplitIntoThreePalindromi...
[ { "docstring": "Checks if a given string is a palindrome.", "function_declaration": "def is_palindrome(sub):", "function_name": "is_palindrome", "parameter_list": "(sub)" }, { "docstring": "Determines if the string s can be split into exactly three non-empty \npalindromic substrings.", "...
[ 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_palindrome(sub):\n return sub == sub[::-1]\n\ndef canSplitIntoThreePalindromicSubstrings(s):\n n = len(s)\n for i in range(1, n):\n for j in...
trial_gpt4o_4
{ "original_instruction": "In this problem, you need to determine if a string can be split into exactly **three** non-empty palindromic substrings.\n\nA **palindrome** is a word that reads the same backward as forward, for example, `madam`, `racecar`, `a`, etc.\n\nGiven a string `s`, check if it is possible to partit...
0.704621
Taco_10825
C
[ "is_palindrome", "canSplitIntoThreePalindromicSubstrings" ]
2
[ [ "canSplitIntoThreePalindromicSubstrings", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63b8b0cd6a55f0ac4abdae52dfaa22b1d0fc24c7
fda4ee1b46bede497e1db4669af8196e4505d89e
v1.0
complete
Taco
Taco_9672_C
def fibonacci(n: int) -> list: """ Returns a list of the first n Fibonacci numbers with zero-based indexing. >>> fibonacci(0) [] >>> fibonacci(1) [0] >>> fibonacci(2) [0, 1] >>> fibonacci(3) [0, 1, 1] >>> fibonacci(5) [0, 1, 1, 2, 3] """ pass def transform_a...
def fibonacci(n): """ Returns a list of the first n Fibonacci numbers with zero-based indexing. """ if n == 0: return [] if n == 1: return [0] fib = [0, 1] for i in range(2, n): fib.append(fib[i-1] + fib[i-2]) return fib def transform_array(arr): """...
from solution import fibonacci, transform_array def test_fibonacci(): assert fibonacci(0) == [] 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_transform_array(): assert transform_array([4, 3, 2, 1, 0]) =...
[ { "docstring": "Returns a list of the first n Fibonacci numbers with zero-based indexing.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Transforms the array by adding the corresponding Fibonacci number to each element....
[ 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 fibonacci(n):\n \"\"\"\n Generate a list of first n Fibonacci numbers.\n \"\"\"\n if n == 0:\n return []\n elif n == 1:\n return [...
trial_gpt4o_2
{ "original_instruction": "Fibonacci Array Transformation\n\nYou are given an array of integers. Your goal is to transform this array into another array where each element is equal to the sum of itself and the corresponding Fibonacci number. The first Fibonacci number in this context is considered to be `F0 = 0`, the...
0.764208
Taco_9672
C
[ "fibonacci", "transform_array" ]
2
[ [ "transform_array", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
492c4ac7622db089c3dd963e96075070c0fc6284
f7bb03737042861b87b4b0758a6a562378c4414c
v1.0
complete
Taco
Taco_10186_C
from typing import List, Tuple def min_energy_loss(n: int, edges: List[Tuple[int, int]]) -> List[int]: """ In the futuristic city of Technovia, compute the minimum energy loss for each district when redirected to the hub. Parameters: n (int): The number of nodes (districts) in the tree. edges (Lis...
from collections import deque def min_energy_loss(n, edges): # Initialize the adjacency list adjacency_list = [[] for _ in range(n + 1)] for u, v in edges: adjacency_list[u].append(v) adjacency_list[v].append(u) # Distance array to store distance from node 1 distance = [-1] * (...
from solution import min_energy_loss def test_sample_input(): n = 5 edges = [(1, 2), (1, 3), (2, 4), (2, 5)] expected_output = [0, 1, 1, 2, 2] assert min_energy_loss(n, edges) == expected_output def test_single_node(): n = 1 edges = [] expected_output = [0] assert min_energy_loss(n, ed...
[ { "docstring": null, "function_declaration": "def min_energy_loss(n, edges):", "function_name": "min_energy_loss", "parameter_list": "(n, edges)" }, { "docstring": null, "function_declaration": "def energy_loss(n, edges):", "function_name": "energy_loss", "parameter_list": "(n, e...
[ 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, defaultdict\n\ndef bfs_minimum_energy_loss(n, edges):\n # Initialize adjacency list\n adj_list = defaultdict(list)\n for u,...
trial_gpt4o_1
{ "original_instruction": "In the futuristic city of Technovia, the residents have developed an advanced system to manage their energy consumption. The city grid is represented as a tree with `n` nodes, where each node represents a different district, and each edge represents an energy conduit between two districts. ...
0.605074
Taco_10186
C
[ "min_energy_loss", "energy_loss" ]
2
[ [ "energy_loss", "min_energy_loss" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abfc290650282630389e7c4ac875d8760018fc6b
e82d0c9ec4a33d26ec0000c6e9b85806391756ce
v1.0
complete
Taco
Taco_9439_C
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reorder_list(input_list): """ Reorder a linked list in the order: first node -> last node -> second node -> second last node, and so on. >>> reorder_list([1, 2, 3, 4]) [1, 4, 2, 3] >>> reo...
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reorderList(head): if not head or not head.next: return head # Find the middle of the linked list slow, fast = head, head while fast and fast.next: slow = slow.next ...
import pytest from solution import reorder_list def test_reorder_list_case1(): assert reorder_list([1, 2, 3, 4]) == [1, 4, 2, 3] def test_reorder_list_case2(): assert reorder_list([1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3] def test_reorder_list_single_element(): assert reorder_list([1]) == [1] def test_reorder...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class ListNode:\n def __init__(self, val=0, next=None):\n self.val = val\n self.next = next\n\ndef list_to_string(head: ListNode) -> str:\n res...
trial_gpt4o_2
{ "original_instruction": "Mina is practicing her data structure skills with linked lists. She decides to create a problem where she has to reorder a linked list according to specific rules. Given a singly linked list, you need to reorder the list so that it is arranged in the order: first node -> last node -> second...
0.566796
Taco_9439
C
[ "reorderList", "toList", "toLinkedList", "reorder_list" ]
4
[ [ "reorder_list", "reorderList" ], [ "reorder_list", "toLinkedList" ], [ "reorder_list", "toList" ] ]
3
[]
false
[ "ListNode" ]
true
pytest
true
[]
true
21b24573665d7db4364101498deb5a3a4faa8afa
2f55017fe4219918a033e4c898e4ca98a6e5a46f
v1.0
complete
Taco
Taco_10190_C
def solve_mazes(test_cases: List[Tuple[int, int, List[str]]]) -> List[str]: """ In a video game, players find themselves in a grid-based maze consisting of walls and empty spaces. The player can only move up, down, left, or right and aims to reach the exit located at the bottom-right corner of the grid starting fro...
from collections import deque # Directions for movement: Up, Down, Left, Right DIRECTIONS = [(-1, 0), (1, 0), (0, -1), (0, 1)] def is_valid_move(r, c, R, C, maze, visited): return 0 <= r < R and 0 <= c < C and maze[r][c] != '#' and maze[r][c] != 'T' and (r, c) not in visited def can_escape_maze(maze, R, C): ...
import pytest from solution import solve_mazes def test_example_cases(): test_cases = [ (3, 3, ['...', '.#.', '..D']), (4, 4, ['.D.T', '.T..', '....', '...#']) ] expected = ['YES', 'NO'] assert solve_mazes(test_cases) == expected def test_single_cell_no_trap(): test_cases = [ ...
[ { "docstring": null, "function_declaration": "def is_valid_move(r, c, R, C, maze, visited):", "function_name": "is_valid_move", "parameter_list": "(r, c, R, C, maze, visited)" }, { "docstring": null, "function_declaration": "def can_escape_maze(maze, R, C):", "function_name": "can_es...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\n# Directions for movement: Up, Down, Left, Right\nDIRECTIONS = [(-1, 0), (1, 0), (0, -1), (0, 1)]\n\ndef is_valid_move(r, c, R, C,...
trial_gpt4o_0
{ "original_instruction": "In a video game, players find themselves in a grid-based maze consisting of walls and empty spaces. The player can only move up, down, left, or right and aims to reach the exit located at the bottom-right corner of the grid starting from the top-left corner. However, the maze contains traps...
0.634555
Taco_10190
C
[ "is_valid_move", "can_escape_maze", "solve_mazes" ]
3
[ [ "can_escape_maze", "is_valid_move" ], [ "solve_mazes", "can_escape_maze" ] ]
2
[]
false
[]
false
pytest
true
[]
true
790f2788947a857cfb9e934fe8eb0b5a07613219
a7bd59a26251a436e255fe80ebcacb448f95ae63
v1.0
complete
Taco
Taco_10624_C
from typing import List def match_pattern(word: str, pattern: str) -> bool: """ Check if a single word matches the given pattern. >>> match_pattern("mee", "abb") True >>> match_pattern("ccc", "abb") False """ pass def find_and_replace_pattern(words: List[str], pattern: str) -> List[str]: ...
def match_pattern(word, pattern): if len(word) != len(pattern): return False map_word_to_pattern = {} map_pattern_to_word = {} for w, p in zip(word, pattern): if w not in map_word_to_pattern: map_word_to_pattern[w] = p if p not in map_pattern_to_word: ma...
from solution import find_and_replace_pattern, match_pattern def test_simple_patterns(): words = ["abc", "deq", "mee", "aqq", "dkd", "ccc"] pattern = "abb" assert find_and_replace_pattern(words, pattern) == ["mee", "aqq"] def test_single_letter_pattern(): words = ["a", "b", "c"] pattern = "a" ...
[ { "docstring": null, "function_declaration": "def match_pattern(word, pattern):", "function_name": "match_pattern", "parameter_list": "(word, pattern)" }, { "docstring": null, "function_declaration": "def find_and_replace_pattern(words, pattern):", "function_name": "find_and_replace_...
[ 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 match_pattern(word, pattern):\n if len(word) != len(pattern):\n return False\n\n map_word_to_pattern = {}\n map_pattern_to_word = {}\n\n for...
trial_gpt4o_0
{ "original_instruction": "Given an array of strings `words` and a string `pattern`, return a list of words from the array that match the given pattern. A word matches the pattern if there exists a bijection from the letters in the pattern to the letters in the word such that transforming all occurrences of the same ...
0.619448
Taco_10624
C
[ "match_pattern", "find_and_replace_pattern" ]
2
[ [ "find_and_replace_pattern", "match_pattern" ] ]
1
[]
false
[]
false
pytest
true
[]
true
265f4f1d6f15e0e5716870abb6af53f9b0528408
ed6636359041ece7942d48a69007582b29c50ebc
v1.0
complete
Taco
Taco_10547_C
import math from typing import List def is_prime(n: int) -> bool: """ Checks if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return ...
import math def is_prime(n): """ Checks if a number is a prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(math.sqrt(n)) + 1, 2): if n % i == 0: return False return True def replace_pr...
from solution import replace_primes_with_squares def test_replace_primes_with_squares(): # Test case 1: Example given in the prompt assert replace_primes_with_squares([2, 3, 4, 5, 6, 7, 8, 9, 10]) == [4, 9, 4, 25, 6, 49, 8, 9, 10] # Test case 2: Array with no prime numbers assert replace_primes_wi...
[ { "docstring": "Checks if a number is a prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Replaces all prime numbers in the array with their squares.", "function_declaration": "def replace_primes_with_squares(arr)...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return ...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes an integer array as input and returns an array with all the prime numbers replaced by their squares.\n\nFor example:\n\nInput: [2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nOutput: [4, 9, 4, 25, 6, 49, 8, 9, 10]\n\nNote: The function should identify prime numbers and replace t...
0.679828
Taco_10547
C
[ "is_prime", "replace_primes_with_squares" ]
2
[ [ "replace_primes_with_squares", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb47b619cc29db196b5803d9cfc8f0cd2ace442b
84dc34f589057795fe23f8776b502881b59d7b8c
v1.0
complete
Taco
Taco_10491_C
def can_place_boxes(m, n, boxes): """ Returns "YES" if all boxes can be placed on the grid without overlapping and within grid boundaries, else "NO". Parameters: m (int): Number of rows in the grid. n (int): Number of columns in the grid. boxes (list of tuples): List of boxes where each box...
def can_place_boxes(m, n, boxes): """ Returns "YES" if all boxes can be placed on the grid without overlapping and within grid boundaries, else "NO". Parameters: m (int): Number of rows in the grid. n (int): Number of columns in the grid. boxes (list of tuples): List of boxes where each box...
from solution import can_place_boxes, solve def test_case_1(): input_data = "5 5\n3\n1 1 2 2\n3 3 1 1\n4 4 2 2\n" assert solve(input_data) == "YES" def test_case_2(): input_data = "4 4\n2\n1 1 3 3\n2 2 2 2\n" assert solve(input_data) == "NO" def test_case_3(): input_data = "10 10\n5\n1 1 1 1\n2 2...
[ { "docstring": "Returns \"YES\" if all boxes can be placed on the grid without overlapping and within grid boundaries, else \"NO\".\n\nParameters:\nm (int): Number of rows in the grid.\nn (int): Number of columns in the grid.\nboxes (list of tuples): List of boxes where each box is described by tuple (r, c, h, ...
[ 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 can_place_boxes(m, n, b, boxes):\n grid = [[0]*n for _ in range(m)] # Create a grid initialized with 0\n \n for box in boxes:\n r, c, h, w = bo...
trial_gpt4o_4
{ "original_instruction": "A warehouse has a grid layout of shelves with rows numbered from 1 to m and columns numbered from 1 to n. Each cell in the grid can either be empty or contain a box with certain dimensions. You need to implement a system to store the boxes in such a way that no box overlaps with any other, ...
0.71605
Taco_10491
C
[ "can_place_boxes", "solve" ]
2
[ [ "solve", "can_place_boxes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9ef74d380210b81a1df9346c2ca1a0be5ae66534
1d5d8addc1cf6a704cf6aabf618753bcda852e3c
v1.0
complete
Taco
Taco_10404_C
from typing import List def largest_black_rectangle(matrix: List[List[int]]) -> int: """ Find the largest rectangle consisting entirely of black pixels (1s) in a binary matrix. >>> largest_black_rectangle([ ... [1, 0, 1, 0, 0], ... [1, 0, 1, 1, 1], ... [1, 1, 1, 1, 1], ... [1, 0, 0...
from typing import List def largest_black_rectangle(matrix: List[List[int]]) -> int: if not matrix or not matrix[0]: return 0 n = len(matrix) m = len(matrix[0]) max_area = 0 histogram = [0] * m for row in matrix: # Update the histogram for i in range(m): ...
from solution import largest_black_rectangle def test_largest_black_rectangle_example_case(): matrix = [ [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 0] ] assert largest_black_rectangle(matrix) == 6 def test_largest_black_rectangle_all_zeros(): matrix...
[ { "docstring": null, "function_declaration": "def largest_black_rectangle(matrix):", "function_name": "largest_black_rectangle", "parameter_list": "(matrix)" }, { "docstring": null, "function_declaration": "def largest_rectangle_in_histogram(heights):", "function_name": "largest_rect...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef largest_black_rectangle(matrix: List[List[int]]) -> int:\n if not matrix:\n return 0\n\n n = len(matrix)\n m = len(m...
trial_gpt4o_2
{ "original_instruction": "Consider an image represented as an n x m grid of pixels. Each pixel can be either `0` (white) or `1` (black). Suppose you want to find the largest rectangle (contiguous sub-grid) consisting entirely of black pixels.\n\nWrite a function `largest_black_rectangle` that takes a binary matrix (...
0.64089
Taco_10404
C
[ "largest_black_rectangle", "largest_rectangle_in_histogram" ]
2
[ [ "largest_black_rectangle", "largest_rectangle_in_histogram" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7fead8e1f3acc74e961d5ac59efd05e8a17bb5a5
389c86f310bf5ecb634b4c2b1abe4bb446e7f7ab
v1.0
complete
Taco
Taco_9751_C
from typing import List, Tuple def process_input_blocks(input_lines: List[str]) -> List[int]: """ Determines the shortest travel time between pairs of cities based on provided input blocks. Args: input_lines: List of strings where each string represents a line of input as described in the problem stat...
import heapq def dijkstra(graph, start, n): """ Performs Dijkstra's algorithm to find the shortest path from start to all other nodes. """ distances = {node: float('infinity') for node in range(1, n+1)} distances[start] = 0 pq = [(0, start)] while pq: current_distance, current_...
def test_example_1(): input_lines = [ "4 4", "1 2 1", "2 3 3", "3 4 1", "4 1 6", "2", "1 3", "1 4", "5 3", "1 2 10", "2 3 10", "4 5 5", "1", "1 5", "0 0" ] expected_output = [4, 5, -1] ...
[ { "docstring": "Performs Dijkstra's algorithm to find the shortest path from start to all other nodes.", "function_declaration": "def dijkstra(graph, start, n):", "function_name": "dijkstra", "parameter_list": "(graph, start, n)" }, { "docstring": "For each query, find the shortest travel ti...
[ 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 sys\nimport heapq\n\ndef dijkstra(n, graph, start, end):\n distance = [float('inf')] * (n + 1)\n distance[start] = 0\n priority_queue = [(0, start)...
trial_gpt4o_2
{ "original_instruction": "A kingdom is divided into several cities connected by bidirectional roads. Each road has a travel time. You are asked to write a program to determine the shortest time required to travel between pairs of cities. If a direct connection between the cities is not possible, the program should r...
0.695136
Taco_9751
C
[ "dijkstra", "find_shortest_paths", "process_input_blocks" ]
3
[ [ "find_shortest_paths", "dijkstra" ], [ "process_input_blocks", "find_shortest_paths" ] ]
2
[]
false
[]
false
pytest
false
[]
true
d24cdb40266ecac0821981da77e1653a65665122
503335919f42d5414062b971fae0adda831c7357
v1.0
complete
Taco
Taco_10337_C
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): """ Convert a list of node values to a binary tree. Args: nodes: List of integers representing node values in level order traversal, where -1 represents a null node....
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): if not nodes: return None n = len(nodes) if n == 0 or nodes[0] == -1: return None root = TreeNode(nodes[0]) queue = [root] index = ...
def test_check_spiral_order_trees(): from solution import check_spiral_order_trees T = 2 test_cases = [ (7, [1, 2, 3, 7, 6, 5, 4]), (7, [1, 2, 3, -1, -1, 5, 4]) ] results = check_spiral_order_trees(T, test_cases) assert results[0] == "YES" assert results[1] == "NO" def...
[]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef build_t...
trial_gpt4o_9
{ "original_instruction": "Given a binary tree, determine whether the tree satisfies the property of a \"spiral order\". A binary tree has a spiral order if the levels of the tree are traversed alternately from left to right and right to left, starting from the root level which is traversed from left to right.\n\nInp...
0.539673
Taco_10337
C
[ "build_tree", "is_spiral_order", "check_spiral_order_trees" ]
3
[ [ "check_spiral_order_trees", "build_tree" ], [ "check_spiral_order_trees", "is_spiral_order" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
bc24686a0b30668bff4b356a5e2ba4824bfc200e
9a6426d216590215f4a626f57c98f5ec81756549
v1.0
complete
Taco
Taco_10733_C
def validate_id_code(id_code: str) -> str: """ Checks if the given ID code is valid based on the specified criteria. - The ID code must be exactly 8 characters long. - It must contain at least one uppercase letter. - It must contain at least one lowercase letter. - It must contain at least one ...
import re def validate_id_code(id_code): """ Checks if the given ID code is valid based on the specified criteria. """ if len(id_code) != 8: return "Invalid" has_upper = re.search(r'[A-Z]', id_code) is not None has_lower = re.search(r'[a-z]', id_code) is not None has_digit = re...
from solution import validate_id_code, validate_id_codes def test_validate_id_code_all_criteria_met(): assert validate_id_code("A1!bCdef") == "Valid" def test_validate_id_code_missing_uppercase(): assert validate_id_code("a1!bcdef") == "Invalid" def test_validate_id_code_missing_lowercase(): assert v...
[ { "docstring": "Checks if the given ID code is valid based on the specified criteria.", "function_declaration": "def validate_id_code(id_code):", "function_name": "validate_id_code", "parameter_list": "(id_code)" }, { "docstring": "Given a list of ID codes, returns a list indicating which co...
[ 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 validate_id_codes(n, id_codes):\n \"\"\"\n This function validates employee ID codes based on specified criteria:\n - Must be exactly 8 characters lon...
trial_gpt4o_1
{ "original_instruction": "A company requires a system that validates employee identification codes. Each ID code has specific rules that need to be checked. Your task is to write a function that validates these codes and determines if they meet the company's standards. \n\n-----Input:-----\n- First line will contain...
0.544505
Taco_10733
C
[ "validate_id_code", "validate_id_codes" ]
2
[ [ "validate_id_codes", "validate_id_code" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0d89becb02db96621de2aef3d63ca3178b1760a7
8fa5323a22602bb5dac7c4cefa7b5b345a5b84c2
v1.0
complete
Taco
Taco_10385_C
from collections import deque from typing import List def is_path_possible(grid: List[List[int]], M: int, N: int, max_diff: int) -> bool: """Check if a path is possible with the given maximum difference constraint. >>> grid = [ >>> [1, 2, 2], >>> [3, 8, 2], >>> [5, 3, 5] >>> ] >>> is_pat...
from collections import deque def is_path_possible(grid, M, N, max_diff): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] visited = [[False] * N for _ in range(M)] queue = deque([(0, 0)]) visited[0][0] = True while queue: x, y = queue.popleft() if x == M - 1 and y == N - 1: ...
from solution import is_path_possible, min_max_difference def test_sample_input(): grid = [ [1, 2, 2], [3, 8, 2], [5, 3, 5] ] assert min_max_difference(grid) == 2 def test_smaller_grid(): grid = [ [0, 1], [1, 0] ] assert min_max_difference(grid) == 1 de...
[ { "docstring": null, "function_declaration": "def is_path_possible(grid, M, N, max_diff):", "function_name": "is_path_possible", "parameter_list": "(grid, M, N, max_diff)" }, { "docstring": null, "function_declaration": "def min_max_difference(grid):", "function_name": "min_max_diffe...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from heapq import heappop, heappush\n\ndef min_max_diff(M, N, heights):\n def is_valid(x, y):\n return 0 <= x < M and 0 <= y < N\n \n directions = ...
trial_gpt4o_5
{ "original_instruction": "You are given a 2D grid of size M x N filled with non-negative integers, representing heights. Suppose you are going on a hike, and you start at the top-left corner of the grid (1, 1), and move to the bottom-right corner (M, N). You can only move up, down, left, or right each step, and you ...
0.723088
Taco_10385
C
[ "is_path_possible", "min_max_difference", "main" ]
3
[ [ "min_max_difference", "is_path_possible" ] ]
1
[]
false
[]
false
pytest
true
[]
true
142f386958e7370191be9b4d30075267307207aa
0a430492c96c3ed105dc3c4057c17fc980bc0327
v1.0
complete
Taco
Taco_10716_C
def is_prime(num): """ Determine if a number is a prime. >>> is_prime(2) True >>> is_prime(3) True >>> is_prime(4) False >>> is_prime(29) True >>> is_prime(100) False """ pass def largest_prime_in_grid(grid): """ Find the largest prime number in a grid of numbers...
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 largest_prime_...
from solution import is_prime, largest_prime_in_grid, solve 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(100) == False def test_largest_prime_in_grid(): assert largest_prime_in_grid([[8, 23, 1...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def largest_prime_in_grid(grid):", "function_name": "largest_prime_in_grid", "parameter_list": "(grid)" }, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_2
{ "original_instruction": "Nina loves solving puzzles, especially those that involve prime numbers. She recently stumbled upon an interesting puzzle and wants you to help her solve it.\n\nThe puzzle works with a grid that contains various numbers. Nina's task is to find the largest prime number within the grid. A pri...
0.65703
Taco_10716
C
[ "is_prime", "largest_prime_in_grid", "solve" ]
3
[ [ "largest_prime_in_grid", "is_prime" ], [ "solve", "largest_prime_in_grid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3c9c300de00507a375ebf9deac3f439e43e78745
6f938696496ce0fe451e0080df0c8d3b21d35d4f
v1.0
complete
Taco
Taco_10757_C
from typing import List def evaluate_expressions(expressions: List[str]) -> List[int]: """ Evaluate a list of mathematical expression strings and return their results as a list of integers. Drop decimal part in division results and return 0 for division by zero. Example: >>> evaluate_expressi...
def evaluate_expression(expression): """ Evaluate a single mathematical expression string containing integers and the operators +, -, *, /. Drop decimal part in division results and return 0 for division by zero. """ try: # Remove spaces expression = expression.replace(' ', '') ...
import pytest from solution import evaluate_expressions def test_evaluate_expressions_basic(): expressions = ["3 + 5", "10 - 2 * 2", "18 / 3 + 4", "15 / 0"] assert evaluate_expressions(expressions) == [8, 6, 10, 0] def test_evaluate_expressions_with_spaces(): expressions = [" 3 + 5 ", " 10 - 2 * 2 ", " 1...
[ { "docstring": "Evaluate a single mathematical expression string containing integers and the operators +, -, *, /.\nDrop decimal part in division results and return 0 for division by zero.", "function_declaration": "def evaluate_expression(expression):", "function_name": "evaluate_expression", "para...
[ 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_expression(expression):\n \"\"\"\n Evaluates a mathematical expression containing integers and +, -, *, /\n operators. Assumes all operations...
trial_gpt4o_2
{ "original_instruction": "You are given a list of strings. Each string in the list represents a mathematical arithmetic expression containing integers and the operators `+`, `-`, `*`, and `/` (without brackets). You need to evaluate the expression for each string and return their results as a list of integers. Assum...
0.605139
Taco_10757
C
[ "evaluate_expression", "evaluate_expressions" ]
2
[ [ "evaluate_expressions", "evaluate_expression" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ec76c06e4720e647f49a475c51e87745eca4092
e2ed017b1763b74c4081f447fb7653f3495e8299
v1.0
complete
Taco
Taco_10527_C
class TreeNode: def __init__(self, node_id): self.node_id = node_id self.children = [] def build_tree(n, edges): nodes = [TreeNode(i) for i in range(n + 1)] for u, v in edges: nodes[u].children.append(nodes[v]) nodes[v].children.append(nodes[u]) return nodes def calcula...
class TreeNode: def __init__(self, node_id): self.node_id = node_id self.children = [] def build_tree(n, edges): nodes = [TreeNode(i) for i in range(n + 1)] for u, v in edges: nodes[u].children.append(nodes[v]) nodes[v].children.append(nodes[u]) return nodes def calcula...
from solution import subtree_sizes def test_case_1(): n = 5 edges = [(1, 2), (1, 3), (3, 4), (3, 5)] m = 3 queries = [1, 3, 4] assert subtree_sizes(n, edges, m, queries) == [5, 3, 1] def test_single_node(): n = 1 edges = [] m = 1 queries = [1] assert subtree_sizes(n, edges, m, ...
[]
[ 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 defaultdict\n\ndef subtree_sizes(n, edges, queries):\n tree = defaultdict(list)\n for u, v in edges:\n tree[u].append(v)\n ...
trial_gpt4o_2
{ "original_instruction": "Tommy the Turtle likes to play with binary trees. He has a tree with n nodes, where each node is labeled with a unique integer from 1 to n. Tommy wants to find out the number of nodes in the subtree of a specific node. Can you help Tommy?\n\nGiven a binary tree with n nodes, you have to pro...
0.602872
Taco_10527
C
[ "build_tree", "calculate_subtree_sizes", "subtree_sizes" ]
3
[ [ "subtree_sizes", "build_tree" ], [ "subtree_sizes", "calculate_subtree_sizes" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
1ebd49fff135f3e6d488722013faf28694731df9
2b38267db285a92b06b3de03313adb679c86b71b
v1.0
complete
Taco
Taco_10258_C
def min_energy_to_reach_end(grid): """ Calculate the minimum energy required to reach the bottom-right corner of the grid from the top-left corner. """ pass # Your implementation here def solve_arya_navigation(test_cases): """ Solve multiple test cases of arya's navigation problem. """...
def min_energy_to_reach_end(grid): """ Calculate the minimum energy required to reach the bottom-right corner of the grid from the top-left corner. """ N = len(grid) M = len(grid[0]) # Initialization of a dp array to store the minimum energy required to reach each cell dp = [[0]*M f...
from solution import min_energy_to_reach_end, solve_arya_navigation, parse_input def test_min_energy_to_reach_end_single_case(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_energy_to_reach_end(grid) == 7 def test_solve_arya_navigation_single_case(): test_cases = [ ...
[ { "docstring": "Calculate the minimum energy required to reach the bottom-right corner\nof the grid from the top-left corner.", "function_declaration": "def min_energy_to_reach_end(grid):", "function_name": "min_energy_to_reach_end", "parameter_list": "(grid)" }, { "docstring": null, "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_energy(T, test_cases):\n results = []\n \n for test_case in test_cases:\n N, M, grid = test_case\n dp = [[0] * M for _ in range(N)]\...
trial_gpt4o_2
{ "original_instruction": "You are tasked with helping Arya navigate the haunted forests of Weirwood. This forest is represented as a grid of N x M cells. Arya starts at the top-left corner of the grid and needs to reach the bottom-right corner. Each cell in the grid contains a number that represents the amount of en...
0.579016
Taco_10258
C
[ "min_energy_to_reach_end", "solve_arya_navigation", "parse_input" ]
3
[ [ "solve_arya_navigation", "min_energy_to_reach_end" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
e0992a2be633f52850e0ca7f36642577ad0b53a6
1ca3f381ea280637e3a5037be17b24cb7c6dc07f
v1.0
complete
Taco
Taco_10881_C
def nextPalindrome(n: int) -> int: """ Returns the smallest numeric palindrome greater than the given number `n`. >>> nextPalindrome(123) 131 >>> nextPalindrome(9) 11 >>> nextPalindrome(0) 1 >>> nextPalindrome(10) 11 >>> nextPalindrome(999) 1001 >>> nextPalindrome(1221) ...
def is_palindrome(n): """ Helper function to check if a number is a palindrome. """ return str(n) == str(n)[::-1] def nextPalindrome(n): """ Returns the smallest numeric palindrome greater than the given number `n`. """ m = n + 1 while not is_palindrome(m): m += 1 return...
from solution import nextPalindrome def test_nextPalindrome_basic(): assert nextPalindrome(123) == 131 assert nextPalindrome(9) == 11 def test_nextPalindrome_edge(): assert nextPalindrome(0) == 1 assert nextPalindrome(10) == 11 def test_nextPalindrome_large_number(): assert nextPalindrome(999...
[ { "docstring": "Helper function to check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Returns the smallest numeric palindrome greater than the given number `n`.", "function_dec...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n str_n = str(n)\n return str_n == str_n[::-1]\n\ndef nextPalindrome(n):\n while True:\n n += 1\n if is_palindrome(n):...
trial_gpt4o_1
{ "original_instruction": "A palindrome is a sequence that reads the same backwards as forwards. A numeric palindrome is simply a number that is a palindrome. For example, 121 is a palindrome, but 123 is not.\n\n## Task\n\nWrite a function `nextPalindrome` that finds the smallest numeric palindrome that is greater th...
0.75867
Taco_10881
C
[ "is_palindrome", "nextPalindrome" ]
2
[ [ "nextPalindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3144ff2e61fbb0da86cfe3e4cb9a1d451ccfafde
b0684cc73f60813a85a3f9659b4ef1de6a7c1c69
v1.0
complete
Taco
Taco_10987_C
def longest_palindromic_substring(S: str) -> int: """ Compute the length of the longest palindromic substring among all cyclic shifts of the string S. >>> longest_palindromic_substring("ababa") 5 >>> longest_palindromic_substring("a") 1 >>> longest_palindromic_substring("abcdefg") 1 >>> ...
def is_palindrome(s): return s == s[::-1] def longest_palindromic_substring(S): N = len(S) max_len = 0 # Generate all cyclic shifts for i in range(N): shifted = S[i:] + S[:i] # Check all possible substrings for start in range(N): for end in range(start + 1, ...
from solution import longest_palindromic_substring def test_example_case(): assert longest_palindromic_substring("ababa") == 5 def test_single_character(): assert longest_palindromic_substring("a") == 1 def test_no_palindrome_longer_than_one(): assert longest_palindromic_substring("abcdefg") == 1 def te...
[ { "docstring": null, "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def longest_palindromic_substring(S):", "function_name": "longest_palindromic_substring", "parameter_li...
[ 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": "def is_palindrome(s):\n return s == s[::-1]\n\ndef longest_palindromic_substring_length(s):\n n = len(s)\n max_len = 0\n for i in range(n):\n cy...
trial_gpt4o_4
{ "original_instruction": "Read problems statements in Mandarin Chinese and Russian.\n\nChef is working with strings and needs your help with a problem involving cyclic shifts.\n\nA cyclic shift of a string is obtained by moving some (possibly zero) characters from the beginning of the string to the end, in the same ...
0.76928
Taco_10987
C
[ "is_palindrome", "longest_palindromic_substring" ]
2
[ [ "longest_palindromic_substring", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20bfdda1c086f09410f8f7c24ba4de27d7e59412
943dcc0b2f6cac367746d366257d8f6d06cb5659
v1.0
complete
Taco
Taco_10972_C
def will_new_road_reduce_travel_time(N: int, M: int, existing_roads: List[Tuple[int, int, int]], K: int, new_roads: List[Tuple[int, int, int]]) -> List[str]: """ For each new road, determine if it will reduce the travel time between the two cities it connects >>> will_new_road_reduce_travel_time(5, 6, [(1, 2, 2...
import heapq def dijkstra(start, graph, N): """ Implements Dijkstra's algorithm to find the shortest paths from the start node to all other nodes :param start: Starting node :param graph: Adjacency list of the graph :param N: Number of nodes :return: List of shortest distances from start to all...
def test_will_new_road_reduce_travel_time(): N = 5 M = 6 existing_roads = [ (1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 2), ] K = 3 new_roads = [ (1, 5, 4), (2, 5, 6), (1, 4, 5), ] expected = ["YES"...
[ { "docstring": "Implements Dijkstra's algorithm to find the shortest paths from the start node to all other nodes\n:param start: Starting node\n:param graph: Adjacency list of the graph\n:param N: Number of nodes\n:return: List of shortest distances from start to all other nodes", "function_declaration": "d...
[ 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, start, N):\n \"\"\"\n Performs the Dijkstra's algorithm to find the shortest paths from the start node to all other nodes...
trial_gpt4o_4
{ "original_instruction": "In the kingdom of Algorithmia, there are N cities connected by M bidirectional roads. Each road connects two distinct cities and has a certain travel time associated with it. The king wants to ensure that all his cities are well connected, and he has selected certain pairs of cities to be d...
0.724416
Taco_10972
C
[ "dijkstra", "will_new_road_reduce_travel_time" ]
2
[ [ "will_new_road_reduce_travel_time", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
fdbb684fb1130f05b150676f983ab30cba6de187
3b7bbec854b6c17fb3331d6ee64d97cbe4f341e8
v1.0
complete
Taco
Taco_10838_C
def convert_24_to_12(hour_minute: str) -> str: """ Converts a given time from 24-hour format to 12-hour format with AM/PM. >>> convert_24_to_12("00:15") == "12:15 AM" >>> convert_24_to_12("11:30") == "11:30 AM" >>> convert_24_to_12("12:00") == "12:00 PM" >>> convert_24_to_12("13:45") == "1:...
def convert_24_to_12(hour_minute): """ Converts a given time from 24-hour format to 12-hour format with AM/PM. Args: hour_minute (str): A string representing time in 24-hour format "HH:MM" Returns: str: A string representing time in 12-hour format with AM/PM """ hh, mm = map(in...
from solution import convert_24_to_12, convert_multiple_times def test_convert_24_to_12(): assert convert_24_to_12("00:15") == "12:15 AM" assert convert_24_to_12("11:30") == "11:30 AM" assert convert_24_to_12("12:00") == "12:00 PM" assert convert_24_to_12("13:45") == "1:45 PM" assert convert_24_to_...
[ { "docstring": "Converts a given time from 24-hour format to 12-hour format with AM/PM.\n\nArgs:\nhour_minute (str): A string representing time in 24-hour format \"HH:MM\"\n\nReturns:\nstr: A string representing time in 12-hour format with AM/PM", "function_declaration": "def convert_24_to_12(hour_minute):"...
[ 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 convert_time_to_12_hour_format(times):\n converted_times = []\n for time in times:\n hh, mm = map(int, time.split(\":\"))\n period = \"AM\"...
trial_gpt4o_2
{ "original_instruction": "You are tasked to write a program that converts times from a 24-hour format (also known as military time) to a 12-hour format with \"AM\" and \"PM\" annotations.\n\nThe 24-hour formatted time is in the format HH:MM, where HH is an integer between 00 and 23 inclusive, and MM is an integer be...
0.618349
Taco_10838
C
[ "convert_24_to_12", "convert_multiple_times" ]
2
[ [ "convert_multiple_times", "convert_24_to_12" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1f2c0c5b6d7bcf0463dfe485ddffbd424acb972d
da23fd4ef61b1609e96dfcf2a05b1b223e7edb82
v1.0
complete
Taco
Taco_10963_C
def is_valid_sudoku(board: str) -> bool: """ Determine if a given 81-character string representing a Sudoku board is valid. >>> is_valid_sudoku("295743861431865927876192543387459216612387495549216738763524189928671354154938672") True >>> is_valid_sudoku("1957438624318659278761925433874592166123874955492...
def is_valid_sudoku(board): def is_valid_block(block): return sorted(block) == list('123456789') for row in range(9): if not is_valid_block([board[row * 9 + col] for col in range(9)]): return False for col in range(9): if not is_valid_block([board[row * 9 + col] for ...
def test_is_valid_sudoku(): valid_sudoku = "295743861431865927876192543387459216612387495549216738763524189928671354154938672" invalid_sudoku = "195743862431865927876192543387459216612387495549216738763524189928671354254938671" assert is_valid_sudoku(valid_sudoku) == True assert is_valid_sudoku(inv...
[ { "docstring": null, "function_declaration": "def is_valid_sudoku(board):", "function_name": "is_valid_sudoku", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def validate_sudoku_boards():", "function_name": "validate_sudoku_boards", "parameter_list"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_sudoku(board):\n \"\"\"\n Verifies if the given Sudoku board is valid.\n \"\"\"\n def is_valid_group(group):\n return set(group) ==...
trial_gpt4o_1
{ "original_instruction": "Determine Sudoku Validity\n\nA Sudoku board is a 9x9 grid where each row, column, and 3x3 sub-grid must contain the digits 1 through 9 exactly once.\n\nYou need to write a program that verifies if a given completed Sudoku board is valid.\n\nInput\n\nThe input consists of multiple lines, eac...
0.606258
Taco_10963
C
[ "is_valid_sudoku", "validate_sudoku_boards" ]
2
[ [ "validate_sudoku_boards", "is_valid_sudoku" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8ccbf7edf343c83c450e6e48d910af14f447cef9
1f2adb4d14fa9d3b5b491fa8d6f71b8719a158c0
v1.0
complete
Taco
Taco_10995_C
def find(parent, i): if parent[i] == i: return i else: return find(parent, parent[i]) def union(parent, rank, x, y): xroot = find(parent, x) yroot = find(parent, y) if rank[xroot] < rank[yroot]: parent[xroot] = yroot elif rank[xroot] > rank[yroot]: parent[yroot] ...
def 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 connect_cities_from_input def test_example_1(): input_str = "4 5\n1 2 1\n1 3 4\n2 3 2\n2 4 7\n3 4 3\n" assert connect_cities_from_input(input_str) == 6 def test_example_2(): input_str = "4 1\n1 2 10\n" assert connect_cities_from_input(input_str) == -1 def test_no_edges(): inp...
[ { "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": "In a certain land called Byteland, there are many cities, each connected by roads. The king of Byteland wants to improve the transportation system between cities by connecting each city with high-speed railways. However, due to budget constraints, the king wants to minimize the total cost o...
0.633491
Taco_10995
C
[ "find", "union", "minimum_cost_to_connect_cities", "connect_cities_from_input" ]
4
[ [ "connect_cities_from_input", "minimum_cost_to_connect_cities" ], [ "minimum_cost_to_connect_cities", "find" ], [ "minimum_cost_to_connect_cities", "union" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
00ba410a8a25cd42225a44c04a3a948040c4ca62
6bf705cfe629a084997664e15e71970f731c82ae
v1.0
complete
Taco
Taco_11039_C
def sum_of_cubes_of_digits(n): """Compute the sum of the cubes of the digits of a number.""" pass def G(n): """Compute the value of G(n) = n + sum of the cubes of the digits of n.""" pass def find_kth_term(X, k): """Given an initial number X and an integer k, find the k-th term in the sequence def...
def sum_of_cubes_of_digits(n): return sum(int(digit)**3 for digit in str(n)) def G(n): return n + sum_of_cubes_of_digits(n) def find_kth_term(X, k): term = X for _ in range(1, k): term = G(term) return term def solve_multiple_cases(cases): results = [] for X, k in cases: r...
def test_sum_of_cubes_of_digits(): assert sum_of_cubes_of_digits(123) == 36 assert sum_of_cubes_of_digits(456) == 405 assert sum_of_cubes_of_digits(0) == 0 assert sum_of_cubes_of_digits(9) == 729 def test_G(): assert G(5) == 130 # 5 + 5^3 assert G(89) == 1330 # 89 + (8^3 + 9^3) assert G(133...
[ { "docstring": null, "function_declaration": "def sum_of_cubes_of_digits(n):", "function_name": "sum_of_cubes_of_digits", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def G(n):", "function_name": "G", "parameter_list": "(n)" }, { "docstring": n...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_cubes_of_digits(n):\n return sum(int(digit)**3 for digit in str(n))\n\ndef G(n):\n return n + sum_of_cubes_of_digits(n)\n\ndef find_kth_term(X, k)...
trial_gpt4o_0
{ "original_instruction": "In a village named Codeville, the villagers love playing with numbers. They are particularly fond of sequences where each number is the sum of the cubes of its digits. To entertain themselves, they decided to create a special function $G(n)$, denoted as $G(n) = n + f(n)$, where $f(n)$ is th...
0.667533
Taco_11039
C
[ "sum_of_cubes_of_digits", "G", "find_kth_term", "solve_multiple_cases", "main" ]
5
[ [ "G", "sum_of_cubes_of_digits" ], [ "find_kth_term", "G" ], [ "solve_multiple_cases", "find_kth_term" ] ]
3
[ "solve_multiple_cases" ]
false
[]
false
pytest
false
[]
true
56e2d990e4df8ac9119e3af251641f814876a739
bd63ebea5fca3099a6ac72cbac54277d25106eb9
v1.0
complete
Taco
Taco_10925_C
from typing import List, Tuple class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes: List[Tuple[int, int, int]]) -> TreeNode: """ Build binary tree from the list of nodes. Args: nodes ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes): if not nodes: return None node_dict = {} for node in nodes: value, left, right = node if value not in node_dict: ...
import pytest from solution import is_avl_tree def test_is_avl_tree_1(): n = 5 nodes = [ (10, 5, 15), (5, -1, 7), (15, 12, 20), (7, -1, -1), (20, -1, -1), (12, -1, -1) ] assert is_avl_tree(n, nodes) == "YES" def test_is_avl_tree_2(): n = 3 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 is_avl_tree(tree):\n n = tree[0][0] # Number of nodes in the tree\n if n == 0:\n return \"YES\"\n \n from collections import defaultdict, d...
trial_gpt4o_2
{ "original_instruction": "A programmer working on a project requires a balanced binary tree (AVL tree) for efficient insertion, deletion, and lookup operations. However, after handling a number of updates, the tree can become imbalanced. Your task is to write a function that checks if a given binary tree is an AVL t...
0.71131
Taco_10925
C
[ "build_tree", "is_balanced", "is_avl_tree" ]
3
[ [ "is_avl_tree", "build_tree" ], [ "is_avl_tree", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ddb4c4a7e93e1123f194ec1e225d8fe6d50f35bb
2e5460fdba946d1adec4bf3a7da1572449c1c0f3
v1.0
complete
Taco
Taco_10235_C
from typing import List, Tuple def preprocess_apples(matrix: List[List[int]], n: int, m: int) -> List[List[int]]: """ Preprocess the matrix to create a prefix sum matrix. >>> preprocess_apples([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3, 3) [[0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45]] """...
def preprocess_apples(matrix, n, m): """Preprocess the matrix to create a prefix sum matrix.""" prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): prefix_sum[i][j] = (matrix[i-1][j-1] + prefix_sum[i-1][j...
def test_preprocess_apples(): matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] expected_prefix_sum = [ [0, 0, 0, 0], [0, 1, 3, 6], [0, 5, 12, 21], [0, 12, 27, 45] ] assert preprocess_apples(matrix, 3, 3) == expected_prefix_sum def test_total_apple...
[ { "docstring": "Preprocess the matrix to create a prefix sum matrix.", "function_declaration": "def preprocess_apples(matrix, n, m):", "function_name": "preprocess_apples", "parameter_list": "(matrix, n, m)" }, { "docstring": "Calculate total apples in the subgrid using the prefix sum matrix...
[ 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 preprocess_matrix(matrix):\n \"\"\"\n Preprocesses the matrix to create a prefix sum matrix.\n \"\"\"\n n = len(matrix)\n m = len(matrix[0])\n ...
trial_gpt4o_2
{ "original_instruction": "Filbert has founded a new city with a grid of houses arranged in an `n x m` matrix. Each cell in the grid has a certain number of apples. Filbert wants to host an event and collect apples from a rectangular sub-grid. Given the matrix and multiple queries where each query specifies the top-l...
0.630303
Taco_10235
C
[ "preprocess_apples", "total_apples_in_subgrid", "collect_apples_from_queries" ]
3
[ [ "collect_apples_from_queries", "preprocess_apples" ], [ "collect_apples_from_queries", "total_apples_in_subgrid" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3bc1e6e23fc0657935506039ca008ffcce0fb33e
f15895122c573677f0cc0f22ac9621e4ad4dc8b4
v1.0
complete
Taco
Taco_10935_C
def shortest_times(n: int, m: int, roads: List[Tuple[int, int, int]], queries: List[int]) -> List[int]: """ Determine the shortest time required to reach each village from the central command post. Parameters: - n (int): Number of villages. - m (int): Number of roads. - roads (List[Tuple[int, i...
import heapq def dijkstra(n, adj_list): """ Dijkstra's algorithm to find the shortest path from the source node to all other nodes in the given graph represented by adjacency list. """ dist = [float('inf')] * (n + 1) dist[1] = 0 pq = [(0, 1)] while pq: current_dist, u = heapq.he...
from solution import shortest_times def test_example_case(): n = 6 m = 7 roads = [ (1, 2, 4), (1, 3, 2), (2, 3, 5), (2, 4, 10), (3, 5, 3), (4, 5, 4), (5, 6, 11) ] queries = [4, 5, 6] assert shortest_times(n, m, roads, queries) == [14, 5, 1...
[ { "docstring": "Dijkstra's algorithm to find the shortest path from the source node to all other nodes\nin the given graph represented by adjacency list.", "function_declaration": "def dijkstra(n, adj_list):", "function_name": "dijkstra", "parameter_list": "(n, adj_list)" }, { "docstring": 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": "import heapq\n\ndef dijkstra(n, graph, start):\n distances = [float('inf')] * (n+1)\n distances[start] = 0\n pq = [(0, start)]\n \n while pq:\n ...
trial_gpt4o_2
{ "original_instruction": "After a hurricane hit the coastal town, rescue teams are trying to reach several villages that are connected by a series of roads. Villages are represented as nodes in a graph, and roads are directed edges connecting these nodes. Each road has a time associated with it, indicating how long ...
0.727057
Taco_10935
C
[ "dijkstra", "shortest_times" ]
2
[ [ "shortest_times", "dijkstra" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7e3507dcf54537c3667c09fb0f8d53da10647182
509c66617e9c41908fdd6d1e9337ba4d97e0fc65
v1.0
complete
Taco
Taco_10930_C
def build_lca(N, adjList): """ Preprocesses the tree to find parent and depth information for each node. """ def lca(u, v, depths, dp): """ Finds the Lowest Common Ancestor using binary lifting. """ def process_input(): """ Reads input, processes the data to build the LCA structure, ...
import sys from collections import defaultdict, deque def dfs(node, parent, depth, adjList, depths, parents): """ Depth First Search to populate depth and parent information for each node. """ depths[node] = depth parents[node] = parent for neighbor in adjList[node]: if neighbor != pare...
from solution import build_lca, lca def test_example1(): adjList = { 1: [2, 3], 2: [1, 4, 5], 3: [1, 6, 7], 4: [2], 5: [2], 6: [3], 7: [3] } N = 7 depths, dp = build_lca(N, adjList) assert lca(4, 5, depths, dp) == 2 assert lca(6, 7, depths...
[ { "docstring": "Depth First Search to populate depth and parent information for each node.", "function_declaration": "def dfs(node, parent, depth, adjList, depths, parents):", "function_name": "dfs", "parameter_list": "(node, parent, depth, adjList, depths, parents)" }, { "docstring": "Prepr...
[ 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 collections import defaultdict\nimport sys\nsys.setrecursionlimit(100000)\n\ndef preprocess_lca(employees, N):\n log = 16 # because 2^16 > 10^5\n paren...
trial_gpt4o_6
{ "original_instruction": "In a company, employees are organized hierarchically, meaning there is a single root employee (the CEO) and every other employee has exactly one direct manager. Each employee is represented by an integer ID from 1 to N, where 1 is always the CEO. You are given a list of pairs representing t...
0.520904
Taco_10930
C
[ "dfs", "build_lca", "lca", "process_input" ]
4
[ [ "build_lca", "dfs" ], [ "process_input", "build_lca" ], [ "process_input", "lca" ] ]
3
[ "process_input" ]
false
[]
false
pytest
true
[]
true
ff4ef5db28fe2f0da339404188f3f209fbd89762
8c3c3b859ded7faafb86753eb41fd8e0c672eebf
v1.0
complete
Taco
Taco_10489_C
def min_stations_to_cover_events(n: int, m: int, stations: List[Tuple[int, int, int]], events: List[Tuple[int, int]]) -> int: """ Determine the minimum number of monitoring stations required to cover all given events. Args: n (int): Number of monitoring stations m (int): Number of events statio...
import math from itertools import combinations def distance(x1, y1, x2, y2): """ Calculate the Euclidean distance between two points (x1, y1) and (x2, y2) """ return math.sqrt((x1 - x2)**2 + (y1 - y2)**2) def min_stations_to_cover_events(n, m, stations, events): def can_cover_all_events(selected_s...
from solution import min_stations_to_cover_events def test_example_case(): n = 5 m = 3 stations = [(1, 1, 5), (4, 4, 2), (7, 7, 3), (10, 10, 1), (13, 13, 2)] events = [(2, 2), (6, 6), (9, 9)] assert min_stations_to_cover_events(n, m, stations, events) == 2 def test_no_stations(): n = 0 m =...
[ { "docstring": "Calculate the Euclidean distance between two points (x1, y1) and (x2, y2)", "function_declaration": "def distance(x1, y1, x2, y2):", "function_name": "distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def min_stations_to_cove...
[ 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\nfrom itertools import combinations\n\ndef distance(x1, y1, x2, y2):\n \"\"\"\n Calculate the Euclidean distance between two points (x1, y1) and ...
trial_gpt4o_0
{ "original_instruction": "You are organizing a fleet of drones to monitor a series of events happening in a city. There are $n$ monitoring stations positioned in different parts of the city, each managing certain sections of the area. Each monitoring station has a set radius within which it can effectively monitor e...
0.605312
Taco_10489
C
[ "distance", "min_stations_to_cover_events" ]
2
[ [ "min_stations_to_cover_events", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
548ca91920191b9e14174b1eda8a1ecb6b3f78ba
c9c66bdd8b6ca4d6eabfe84e7e7f7836cfe3d26c
v1.0
complete
Taco
Taco_10800_C
from collections import deque def shortest_path(maze, M, N): """ Find the shortest path in the maze from the top-left corner to the bottom-right corner. Return the length of the shortest path, or -1 if no such path exists. """ def solve_mazes(mazes): """ Solve multiple mazes, finding the shortest pat...
from collections import deque def shortest_path(maze, M, N): directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] queue = deque([(0, 0, 0)]) # (row, col, distance) visited = set((0, 0)) while queue: x, y, dist = queue.popleft() if (x, y) == (M - 1, N - 1): return d...
def test_read_input(): input_data = '6 5\n.....\n.#.#.\n.#...\n.####\n.....\n.#...\n3 3\n.#.\n.#.\n.#.\n0 0\n' expected_mazes = [ {'M': 6, 'N': 5, 'grid': [['.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '#', '.', '.', '.'], ['.', '#', '#', ...
[ { "docstring": null, "function_declaration": "def shortest_path(maze, M, N):", "function_name": "shortest_path", "parameter_list": "(maze, M, N)" }, { "docstring": null, "function_declaration": "def solve_mazes(mazes):", "function_name": "solve_mazes", "parameter_list": "(mazes)"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_maze(M, N, maze):\n def is_valid(x, y):\n return 0 <= x < M and 0 <= y < N and maze[x][y] == '.'\n ...
trial_gpt4o_1
{ "original_instruction": "Heidi has discovered a maze in her quest to track down the Zombie King. The maze is represented as a grid of cells, where each cell is either open (represented by '.') or blocked (represented by '#'). Heidi starts at the top-left corner of the maze and wants to reach the bottom-right corner...
0.626367
Taco_10800
C
[ "shortest_path", "solve_mazes", "read_input", "main" ]
4
[ [ "solve_mazes", "shortest_path" ] ]
1
[ "read_input" ]
false
[]
false
pytest
false
[]
true
874ba435e33a6166a4f18b6449af8dcea85fa91c
cab760f188744f3f2b4db53828f98429e6912263
v1.0
complete
Taco
Taco_11290_C
def process_operations(operations): """ Process a list of operations on a stack and return the results of "POP" operations. Each operation is one of the following: - "PUSH x" (where x is an integer) : Push x onto the stack. - "POP" : Pop the top element from the stack. Print "EMPTY" if the stack is...
def process_operations(operations): stack = [] results = [] for operation in operations: if operation.startswith("PUSH"): _, value = operation.split() stack.append(int(value)) elif operation == "POP": if stack: results.append(stack.pop()) ...
from solution import simulate_stack_operations, process_operations def test_single_push_pop(): assert simulate_stack_operations(["2", "PUSH 1", "POP"]) == [1] def test_multiple_push_pops(): assert simulate_stack_operations(["6", "PUSH 3", "PUSH 4", "POP", "POP", "POP", "PUSH 5"]) == [4, 3, "EMPTY"] def test_...
[ { "docstring": null, "function_declaration": "def process_operations(operations):", "function_name": "process_operations", "parameter_list": "(operations)" }, { "docstring": null, "function_declaration": "def simulate_stack_operations(input_lines):", "function_name": "simulate_stack_...
[ 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 stack_operations(operations):\n stack = []\n result = []\n\n for operation in operations:\n if operation.startswith(\"PUSH\"):\n _, ...
trial_gpt4o_2
{ "original_instruction": "You are given a list of operations to perform on an initially empty stack. The operations are of two types: \"PUSH x\" (where x is an integer that needs to be pushed onto the stack) and \"POP\" (which pops the top element from the stack if the stack is not empty). The task is to process the...
0.467933
Taco_11290
C
[ "process_operations", "simulate_stack_operations" ]
2
[ [ "simulate_stack_operations", "process_operations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bec9838a11dab07a1e640dd172e9ac368797640e
c508f50b1c8311369094a678a2532f0341f39723
v1.0
complete
Taco
Taco_11447_C
def generate_pattern(N: int) -> list: """ Generates a pattern of numbers of size NxN where each element is the product of its row and column indices. Starting index is 1. >>> generate_pattern(1) [[1]] >>> generate_pattern(2) [[1, 2], [2, 4]] """ def format_pattern(pattern: list) -> ...
def generate_pattern(N): """ Generates a pattern of numbers of size NxN where each element is the product of its row and column indices. Starting index is 1. """ pattern = [] for i in range(1, N + 1): row = [] for j in range(1, N + 1): row.append(i * j) p...
from solution import generate_pattern, format_pattern, solution def test_generate_pattern(): assert generate_pattern(1) == [[1]] assert generate_pattern(2) == [[1, 2], [2, 4]] assert generate_pattern(3) == [[1, 2, 3], [2, 4, 6], [3, 6, 9]] def test_format_pattern(): assert format_pattern([[1]]) == '1\...
[ { "docstring": "Generates a pattern of numbers of size NxN where each \nelement is the product of its row and column indices.\nStarting index is 1.", "function_declaration": "def generate_pattern(N):", "function_name": "generate_pattern", "parameter_list": "(N)" }, { "docstring": "Formats th...
[ 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 generate_pattern(N):\n \"\"\"\n Generates a pattern matrix of size N x N where each element in the pattern is \n the product of its row index and colu...
trial_gpt4o_1
{ "original_instruction": "You are given a task to generate a specific pattern of numbers based on the given input. Each test case consists of one integer `N`. For each `N`, you need to print a pattern of size `N x N` (N rows and N columns) where each element in the pattern is the product of its row index and column ...
0.550353
Taco_11447
C
[ "generate_pattern", "format_pattern", "solution" ]
3
[ [ "solution", "format_pattern" ], [ "solution", "generate_pattern" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2bb05daa533a0bf357d9abe64a45c44a4e873d76
74fa0e20c5f38fce104196820f12fea1a66bbf5a
v1.0
complete
Taco
Taco_11324_C
def count_clusters(n: int, grid_values: List[str]) -> int: """ Identify and count the number of clusters of buildings within the grid. >>> count_clusters(5, [ ... "1 1 0 0 0", ... "1 0 0 1 1", ... "0 0 0 1 1", ... "0 1 1 0 0", ... "0 0 0 0 1" ... ]) == 4 >>> count_clusters(3...
def find_clusters(grid, n): def dfs(x, y): if x < 0 or y < 0 or x >= n or y >= n or grid[x][y] == 0: return grid[x][y] = 0 # mark as visited # Visit all adjacent cells (up, down, left, right) dfs(x + 1, y) dfs(x - 1, y) dfs(x, y + 1) dfs(x, y - 1)...
def test_count_clusters_1(): grid = [ "1 1 0 0 0", "1 0 0 1 1", "0 0 0 1 1", "0 1 1 0 0", "0 0 0 0 1" ] assert count_clusters(5, grid) == 4 def test_count_clusters_2(): grid = [ "1 1 0", "0 1 0", "0 0 1" ] assert count_clusters(3, ...
[ { "docstring": null, "function_declaration": "def find_clusters(grid, n):", "function_name": "find_clusters", "parameter_list": "(grid, n)" }, { "docstring": null, "function_declaration": "def count_clusters(n, grid_values):", "function_name": "count_clusters", "parameter_list": ...
[ 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 count_clusters(grid):\n \"\"\"\n Given a grid of size n x n with 1s representing buildings and 0s representing empty lots,\n count the number of conti...
trial_gpt4o_1
{ "original_instruction": "A city is organized in a grid of size n x n. Each cell within the grid may either be a building (represented by the number 1) or an empty lot (represented by the number 0). The mayor of the city wishes to identify contiguous clusters of buildings for future urban planning. A cluster of buil...
0.569322
Taco_11324
C
[ "find_clusters", "count_clusters" ]
2
[ [ "count_clusters", "find_clusters" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3515a0392bf9dd8ba3c22dd4ec9d6d018468e68d
d8469b629e28f9afbf921227bd6950cd0f2065a3
v1.0
complete
Taco
Taco_11199_C
def meetings_scheduler(input_str: str) -> str: """ You are given a list of intervals where each interval represents a meeting and consists of a start time and an end time. Your task is to determine if a person can attend all the meetings without any overlapping. If it is possible for the person to attend all the me...
def can_attend_all_meetings(test_cases): results = [] for case in test_cases: intervals = case["intervals"] # Sort intervals by start time intervals.sort(key=lambda x: x[0]) # Check for any overlap for i in range(1, len(intervals)): if intervals[i][0]...
from solution import meetings_scheduler def test_meetings_scheduler_single_test_case_no_overlap(): input_str = "1\n3\n1 3\n3 5\n5 6" expected_output = "YES" assert meetings_scheduler(input_str) == expected_output def test_meetings_scheduler_single_test_case_with_overlap(): input_str = "1\n2\n1 4\n3 5"...
[ { "docstring": null, "function_declaration": "def can_attend_all_meetings(test_cases):", "function_name": "can_attend_all_meetings", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "pa...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_attend_all_meetings(test_cases):\n results = []\n \n for meetings in test_cases:\n meetings.sort(key=lambda x: x[0])\n \n for...
trial_gpt4o_1
{ "original_instruction": "**You are given a list of intervals where each interval represents a meeting and consists of a start time and an end time. Your task is to determine if a person can attend all the meetings without any overlapping. If it is possible for the person to attend all the meetings, return \"YES\", ...
0.694877
Taco_11199
C
[ "can_attend_all_meetings", "parse_input", "format_output", "meetings_scheduler" ]
4
[ [ "meetings_scheduler", "can_attend_all_meetings" ], [ "meetings_scheduler", "format_output" ], [ "meetings_scheduler", "parse_input" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
338743e43a008c24e635bcc4c6cdd928bbf80fb4
36cc71209794b5fde9e2490a53031d659ef8a02e
v1.0
complete
Taco
Taco_11129_C
from typing import List, Tuple def longest_path_in_tree(N: int, edges: List[Tuple[int, int, int]]) -> int: """ Returns the length of the longest path in a tree with N nodes and given edges. >>> longest_path_in_tree(3, [(1, 2, 3), (2, 3, 4)]) 7 >>> longest_path_in_tree(5, [(1, 2, 1), (2, 3, 2),...
from collections import defaultdict, deque def find_longest_path(N, edges): def bfs(start): dist = [-1] * (N + 1) dist[start] = 0 queue = deque([start]) farthest_node = start max_dist = 0 while queue: node = queue.popleft() for neighb...
from solution import longest_path_in_tree def test_longest_path_example1(): N = 3 edges = [ (1, 2, 3), (2, 3, 4) ] assert longest_path_in_tree(N, edges) == 7 def test_longest_path_example2(): N = 5 edges = [ (1, 2, 1), (2, 3, 2), (2, 4, 3), (4, 5...
[ { "docstring": null, "function_declaration": "def find_longest_path(N, edges):", "function_name": "find_longest_path", "parameter_list": "(N, edges)" }, { "docstring": "Returns the length of the longest path in a tree with N nodes and given edges.", "function_declaration": "def longest_p...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque, defaultdict\n\ndef find_furthest_node(start, graph):\n \"\"\"\n Perform BFS to find the furthest node from the given start nod...
trial_gpt4o_3
{ "original_instruction": "You are given a tree with \\(N\\) nodes, where each node is identified by a number from 1 to \\(N\\). Each edge in the tree has a positive integer weight associated with it.\n\nYour task is to find the longest path in the tree, where the length of a path is defined as the sum of the weights...
0.587584
Taco_11129
C
[ "find_longest_path", "longest_path_in_tree" ]
2
[ [ "longest_path_in_tree", "find_longest_path" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86f8179151c8fa7f1588c565629ba60f589282c2
bede10777763f537c2de826d451a4e1eb1080ce0
v1.0
complete
Taco
Taco_11092_C
import heapq from typing import List def is_valid(x, y, n, m): return 0 <= x < n and 0 <= y < m def min_energy_path(grid: List[List[int]]) -> int: """Find the minimum energy path in a given grid from the top-left corner to the bottom-right corner. >>> min_energy_path([[1, 3, 1], [1, 5, 1], [4, 2, 1]])...
import heapq def min_energy_path(grid): n = len(grid) m = len(grid[0]) directions = [(0, 1), (1, 0), (0, -1), (-1, 0)] def is_valid(x, y): return 0 <= x < n and 0 <= y < m pq = [(grid[0][0], 0, 0)] min_cost = [[float('inf')] * m for _ in range(n)] min_cost[0][0] = grid...
def test_min_energy_path_example_1(): grid = [ [1, 3, 1], [1, 5, 1], [4, 2, 1] ] assert min_energy_path(grid) == 7 def test_min_energy_path_example_2(): grid = [ [2, 2], [1, 1] ] assert min_energy_path(grid) == 4 def test_min_energy_path_single_cell(): ...
[ { "docstring": null, "function_declaration": "def min_energy_path(grid):", "function_name": "min_energy_path", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def parse_grid_and_calculate_min_energy(n, m, grid_values):", "function_name": "parse_grid_and_ca...
[ 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 heapq\n\ndef min_energy_required(n, m, grid):\n \"\"\"\n Returns the minimum energy required to reach the bottom-right corner from the top-left corner...
trial_gpt4o_4
{ "original_instruction": "In a city grid, you start at the top-left corner (1, 1) and need to reach the bottom-right corner (n, m). However, some cells in the grid contain mud and are harder to pass through. Each cell contains an integer representing the energy required to pass through it. You can move in four direc...
0.609133
Taco_11092
C
[ "min_energy_path", "parse_grid_and_calculate_min_energy" ]
2
[ [ "parse_grid_and_calculate_min_energy", "min_energy_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9b247ee20a166baba953487e352225ed32c07a43
3ff08baebeb54b17d3c00fb8a1c5444d4a016211
v1.0
complete
Taco
Taco_11622_C
import heapq from typing import List, Tuple def longest_shortest_path(n: int, m: int, edges: List[Tuple[int, int, int]], q: int, queries: List[List[int]]) -> List[int]: """ You are given an undirected graph with n nodes and m edges. Each edge has a positive weight. Compute and print the length of the longest s...
import heapq def dijkstra(graph, start): distances = {node: float('infinity') for node in graph} distances[start] = 0 priority_queue = [(0, start)] while priority_queue: current_distance, current_node = heapq.heappop(priority_queue) if current_distance > distances[current_node]: ...
def test_solution(): n = 5 m = 4 edges = [(1, 2, 4), (1, 3, 2), (3, 4, 7), (2, 5, 5)] q = 2 queries = [ [1, 2, 3], [4, 5], ] expected_output = [6, -1] result = longest_shortest_path(n, m, edges, q, queries) assert result == expected_output def test_single_node(): ...
[ { "docstring": null, "function_declaration": "def dijkstra(graph, start):", "function_name": "dijkstra", "parameter_list": "(graph, start)" }, { "docstring": null, "function_declaration": "def longest_shortest_path(n, m, edges, q, queries):", "function_name": "longest_shortest_path",...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(graph, start):\n distances = {node: float('infinity') for node in graph}\n distances[start] = 0\n priority_queue = [(0, start...
trial_gpt4o_0
{ "original_instruction": "You are given an undirected graph with $n$ nodes and $m$ edges. Each edge has a positive weight. Your task is to compute and print the length of the longest shortest path in the graph for each query.\n\nA shortest path between two nodes is the path with the minimum total weight between them...
0.685028
Taco_11622
C
[ "dijkstra", "longest_shortest_path" ]
2
[ [ "longest_shortest_path", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c431f37e8b13348f96fd3b9cc2e28c83549ebad3
752a315be1ce0aea460a15c156a932fe7b0b241b
v1.0
complete
Taco
Taco_11273_C
def distinct_subsequences_count(s: str) -> int: """ Calculate the number of distinct subsequences of the string s modulo 1000000007. >>> distinct_subsequences_count("abc") 7 >>> distinct_subsequences_count("aaa") 3 """ pass def calculate_beauty_of_strings(strings: List[str]) -> List[in...
MOD = 1000000007 def distinct_subsequences_count(s): """ Calculate the number of distinct subsequences of the string s modulo 1000000007. """ n = len(s) dp = [0] * (n + 1) last = {} dp[0] = 1 # There's always one subsequence which is the empty subsequence for i in range(1, n + 1)...
from solution import calculate_beauty_of_strings, distinct_subsequences_count def test_distinct_subsequences_count(): assert distinct_subsequences_count("abc") == 7 assert distinct_subsequences_count("aaa") == 3 assert distinct_subsequences_count("aab") == 5 assert distinct_subsequences_count("abcdefgh...
[ { "docstring": "Calculate the number of distinct subsequences of the string s modulo 1000000007.", "function_declaration": "def distinct_subsequences_count(s):", "function_name": "distinct_subsequences_count", "parameter_list": "(s)" }, { "docstring": null, "function_declaration": "def c...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "MOD = 1000000007\n\ndef distinct_subsequences_count(s):\n \"\"\"\n Calculate the number of distinct subsequences of the string s modulo 1000000007.\n \"\"...
trial_gpt4o_0
{ "original_instruction": "Alice is a big fan of puzzles. Recently, she discovered a new puzzle that involves strings and their beauty. The beauty of a string is determined by the number of distinct subsequences it contains. A subsequence of a string is a sequence that can be derived from the string by deleting some ...
0.638344
Taco_11273
C
[ "distinct_subsequences_count", "calculate_beauty_of_strings" ]
2
[ [ "calculate_beauty_of_strings", "distinct_subsequences_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b4d97cc7f7577e30b8d8bf8a1a007fed7258898d
eda3afbe7f095295f9384f15973d2071ea24771c
v1.0
complete
Taco
Taco_11417_C
def shortest_path(n, m, start, end, constructions): """ Determine the length of the shortest path from start to end while avoiding constructions. Parameters: n (int): Number of intersections along the north-south direction. m (int): Number of intersections along the east-west direction...
from collections import deque def is_valid_move(x, y, n, m, grid): """ Check if the move x, y is valid within the grid bounds and is not under construction. """ return 0 <= x < n and 0 <= y < m and grid[x][y] == 0 def shortest_path(n, m, start, end, constructions): """ Determine the length of ...
import pytest from solution import shortest_path def test_shortest_path_basic(): # Basic example provided n, m = 5, 5 start = (1, 1) end = (5, 5) constructions = [(2, 2), (3, 3)] assert shortest_path(n, m, start, end, constructions) == 8 def test_shortest_path_no_possible_path(): n, m = 3,...
[ { "docstring": "Check if the move x, y is valid within the grid bounds and is not under construction.", "function_declaration": "def is_valid_move(x, y, n, m, grid):", "function_name": "is_valid_move", "parameter_list": "(x, y, n, m, grid)" }, { "docstring": "Determine the length of the shor...
[ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(n, m, start, end, blocked):\n directions = [(-1,0), (1,0), (0,-1), (0,1)]\n start_x, start_y = start\n ...
trial_gpt4o_8
{ "original_instruction": "You’re developing a navigation app, and you need to implement a feature that finds the shortest path between points in a city. The city is represented as a grid of intersections and streets.\n\nHowever, certain streets are under construction and cannot be used for navigation. You are given ...
0.634558
Taco_11417
C
[ "is_valid_move", "shortest_path" ]
2
[ [ "shortest_path", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
941a76792d84efb0c4b4969859a20572d9e2e072
2cea0b1f6cf8b591cf263a60790c9c776a0de2bc
v1.0
complete
Taco
Taco_11565_C
import itertools import math from typing import List, Tuple def shortest_route(N: int, points: List[Tuple[int, int]]) -> float: """ Calculate the shortest round-trip route that visits every delivery point exactly once. >>> shortest_route(4, [(0, 0), (2, 0), (2, 2), (0, 2)]) 8.000 >>> shortest_route(3, ...
import itertools import math def euclidean_distance(p1, p2): return math.sqrt((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) def shortest_route(N, points): min_route_length = float('inf') permutations = itertools.permutations(points[1:]) for perm in permutations: current_route_length = eucl...
from solution import shortest_route def test_example_1(): N = 4 points = [(0, 0), (2, 0), (2, 2), (0, 2)] assert shortest_route(N, points) == 8.000 def test_example_2(): N = 3 points = [(0, 0), (1, 1), (1, 0)] assert shortest_route(N, points) == 3.414 def test_two_points(): N = 2 poin...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def shortest_route(N, points):", "function_name": "shortest_route", "parameter_list...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\nimport math\n\ndef calculate_distance(x1, y1, x2, y2):\n \"\"\"\n Calculates the Euclidean distance between two points (x1, y1) and (x2, y2...
trial_gpt4o_3
{ "original_instruction": "You are working as a software engineer at a logistics company. You are tasked with developing a route optimization algorithm for delivery trucks. Each delivery truck needs to visit a series of delivery points in a given order and return to the starting point. The goal is to determine the sh...
0.595992
Taco_11565
C
[ "euclidean_distance", "shortest_route" ]
2
[ [ "shortest_route", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ab8b67104c71aae027921364f61077b22c3a85f1
9d6d3a91acfd2e43587eb37ee7c9b1934523f987
v1.0
complete
Taco
Taco_11216_C
import re from typing import List def validate_password(password: str) -> str: """ Validates a single password according to company rules. A valid password must: - Be at least 8 characters long. - Contain at least one uppercase letter. - Contain at least one lowercase letter. - Contain at ...
import re def validate_password(password): if len(password) < 8: return "Invalid" if not re.search(r'[A-Z]', password): return "Invalid" if not re.search(r'[a-z]', password): return "Invalid" if not re.search(r'[0-9]', password): return "Invalid" if not re.search(r'[...
from solution import validate_passwords, validate_password def test_single_valid_password(): assert validate_password("Abcd1234!") == "Valid" def test_single_invalid_password_length(): assert validate_password("Abc12!") == "Invalid" def test_single_invalid_password_no_uppercase(): assert validate_passwor...
[ { "docstring": null, "function_declaration": "def validate_password(password):", "function_name": "validate_password", "parameter_list": "(password)" }, { "docstring": null, "function_declaration": "def validate_passwords(passwords):", "function_name": "validate_passwords", "para...
[ 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 re\n\ndef validate_passwords(passwords):\n \"\"\"\n Validates a list of passwords based on the specific company's rules.\n \n Args:\n passwor...
trial_gpt4o_2
{ "original_instruction": "You are working as a software developer for SynthWave Technologies, a company specializing in authentication security systems. Your next project involves creating a system that validates passwords according to specific company requirements.\n\nYou are provided with a set of rules that a val...
0.628662
Taco_11216
C
[ "validate_password", "validate_passwords" ]
2
[ [ "validate_passwords", "validate_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5cee2a7139f755c8670def2ee3e2da3fc2aefd98
d36f1ad397bc818de9dfa10ea88eec8461dca9b9
v1.0
complete
Taco
Taco_11806_C
def is_happy_number(n: int) -> bool: """ Returns True if n is a happy number; otherwise, returns False. """ pass def determine_happiness(m: int, numbers: List[int]) -> List[str]: """ For each number in numbers, determines if it is a happy number and returns a list of "HAPPY" or "UNHAPPY" for ea...
def is_happy_number(n): """ Returns True if n is a happy number; otherwise, returns False. """ seen = set() while n != 1 and n not in seen: seen.add(n) n = sum(int(digit) ** 2 for digit in str(n)) return n == 1 def determine_happiness(m, numbers): """ For each number in ...
from solution import is_happy_number, determine_happiness def test_is_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(20) == False def test_determine_happiness(): as...
[ { "docstring": "Returns True if n is a happy number; otherwise, returns False.", "function_declaration": "def is_happy_number(n):", "function_name": "is_happy_number", "parameter_list": "(n)" }, { "docstring": "For each number in numbers, determines if it is a happy number and\nreturns a lis...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_happy_number(n):\n \"\"\"\n Returns True if n is a happy number; otherwise, returns False.\n \"\"\"\n seen = set()\n while n != 1 and n not i...
trial_gpt4o_0
{ "original_instruction": "You are given several integers. Write a program that determines if each integer is a happy number. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the nu...
0.697551
Taco_11806
C
[ "is_happy_number", "determine_happiness" ]
2
[ [ "determine_happiness", "is_happy_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ccf0c6138bccee8befcad239ef107122c94d14b0
33d3f6a7fd36d88b049ab682472798ac59cb2141
v1.0
complete
Taco
Taco_11174_C
from typing import List, Tuple def dijkstra_max_security(n: int, edges: List[Tuple[int, int, int, int]], start: int) -> List[int]: """ Computes the maximum security level required by any pipe along the shortest path from the starting chamber. :param n: Number of chambers. :param edges: List of tuples ...
import heapq def read_input(): n, q = map(int, input().split()) security_levels = list(map(int, input().split())) edges = [] for _ in range(n - 1): a, b, l = map(int, input().split()) a -= 1 b -= 1 security_restriction = min(security_levels[a], security_levels[b]) ...
def test_dijkstra_max_security(): n = 5 edges = [ (0, 1, 3, 1), (1, 2, 2, 1), (2, 3, 5, 4), (3, 4, 7, 2) ] start = 0 result = dijkstra_max_security(n, edges, start) assert result == [0, 1, 1, 4, 4] def test_solve_transport_operations(): n, q = 5, 3 securi...
[ { "docstring": null, "function_declaration": "def read_input():", "function_name": "read_input", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def dijkstra_max_security(n, edges, start):", "function_name": "dijkstra_max_security", "parameter_list": "(n, ...
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef max_security_level_on_shortest_path(n, q, security_levels, pipes, transport_operations):\n def dijkstra_max_security(n, start, adj_list):\n ...
trial_gpt4o_7
{ "original_instruction": "A group of researchers is planning an experiment in a special laboratory that contains n chambers connected by non-directional pipes. Each chamber has a unique security level s, and each pipe has a length l and a security restriction r, denoting the minimum security level required to pass t...
0.576348
Taco_11174
C
[ "read_input", "dijkstra_max_security", "solve_transport_operations" ]
3
[ [ "solve_transport_operations", "dijkstra_max_security" ], [ "solve_transport_operations", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
false
[]
true
5a0c52ff0e8aa37e21c6727121ac92d8495bc245
524573c8494ac655062caef6ab7254e5a121d74f
v1.0
complete
Taco
Taco_11610_C
from typing import List, Tuple def shortest_paths(n: int, m: int, edges: List[Tuple[int, int, int]], s: int) -> List[str]: """ Calculate the shortest paths from a given starting node to all other nodes using Dijkstra's algorithm. Args: n (int): Number of nodes in the graph. m (int): Number of edges in ...
import heapq def dijkstra(n, edges, s): graph = {i: [] for i in range(1, n + 1)} for u, v, w in edges: graph[u].append((w, v)) distances = {i: float('inf') for i in range(1, n + 1)} distances[s] = 0 priority_queue = [(0, s)] while priority_queue: current_distance, u = h...
def test_shortest_paths(): n, m = 5, 6 edges = [(1, 2, 2), (1, 3, 4), (2, 3, 1), (2, 4, 7), (3, 5, 3), (4, 5, 1)] s = 1 assert shortest_paths(n, m, edges, s) == ["0", "2", "3", "9", "6"] def test_disconnected_graph(): n, m = 4, 2 edges = [(1, 2, 3), (3, 4, 5)] s = 1 assert shortest_path...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, s):", "function_name": "dijkstra", "parameter_list": "(n, edges, s)" }, { "docstring": null, "function_declaration": "def shortest_paths(n, m, edges, s):", "function_name": "shortest_paths", "parameter_list": "(...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, edges, s):\n graph = [[] for _ in range(n)]\n for u, v, w in edges:\n graph[u-1].append((v-1, w)) # Adjust 1-based in...
trial_gpt4o_1
{ "original_instruction": "You are working on a project involving network connections and need to calculate the shortest paths between nodes using Dijkstra's algorithm. The structure of the network is given by a weighted, directed graph.\n\nYour task is to write a program that reads the graph data and computes the sh...
0.645513
Taco_11610
C
[ "dijkstra", "shortest_paths" ]
2
[ [ "shortest_paths", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
393316e22400755c9cc5819088101a7aa5c5d7b3
6167d1f65e3e18c86b6be3c5f4299883d63d8c0b
v1.0
complete
Taco
Taco_11631_C
def can_form_palindrome(s): """ Checks if a given string can be rearranged to form a palindrome. :param s: The input string. :return: 'Yes' if the string can be rearranged to form a palindrome, otherwise 'No'. """ def check_palindromes(n, strings): """ Goes through a list of strings and...
def can_form_palindrome(s): """ Checks if a given string can be rearranged to form a palindrome. :param s: The input string. :return: 'Yes' if the string can be rearranged to form a palindrome, otherwise 'No'. """ from collections import Counter char_counts = Counter(s) odd_count = ...
from solution import can_form_palindrome, check_palindromes def test_can_form_palindrome(): assert can_form_palindrome("civic") == "Yes" assert can_form_palindrome("ivicc") == "Yes" assert can_form_palindrome("hello") == "No" assert can_form_palindrome("aabb") == "Yes" assert can_form_palindrome("x...
[ { "docstring": "Checks if a given string can be rearranged to form a palindrome.\n:param s: The input string.\n:return: 'Yes' if the string can be rearranged to form a palindrome, otherwise 'No'.", "function_declaration": "def can_form_palindrome(s):", "function_name": "can_form_palindrome", "parame...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_palindrome(s):\n from collections import Counter\n count = Counter(s)\n odd_count = sum(1 for val in count.values() if val % 2 == 1)\n ret...
trial_gpt4o_2
{ "original_instruction": "Alice likes symmetry and finds palindromes to be fascinating. She decides to play a game with her friend Bob using this concept. She provides Bob with various strings, and for each string, she wants to determine if it can be rearranged to form a palindrome.\n\nA string can be rearranged to ...
0.750846
Taco_11631
C
[ "can_form_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "can_form_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0267b06fe9ff79c2093742dc687f47e9ea2c7b72
e011f1bbebaa4efc46d2840fb1ec2b41d5e667d6
v1.0
complete
Taco
Taco_11833_C
def is_palindromic(number: int) -> bool: """ Checks if a given number is palindromic. >>> is_palindromic(121) == True >>> is_palindromic(131) == True >>> is_palindromic(123) == False >>> is_palindromic(1331) == True >>> is_palindromic(12321) == True """ pass def find_smallest_palind...
def is_palindromic(number): """ Checks if a given number is palindromic. """ str_number = str(number) return str_number == str_number[::-1] def find_smallest_palindrome(n): """ Finds the smallest palindromic number greater than or equal to n. """ while not is_palindromic(n): ...
from solution import is_palindromic, find_smallest_palindrome def test_is_palindromic(): assert is_palindromic(121) == True assert is_palindromic(131) == True assert is_palindromic(123) == False assert is_palindromic(1331) == True assert is_palindromic(12321) == True def test_find_smallest_palindr...
[ { "docstring": "Checks if a given number is palindromic.", "function_declaration": "def is_palindromic(number):", "function_name": "is_palindromic", "parameter_list": "(number)" }, { "docstring": "Finds the smallest palindromic number greater than or equal to 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 smallest_palindrome(n: int) -> int:\n \"\"\"\n Returns the smallest palindromic number greater than or equal to n.\n \"\"\"\n def is_palindrome(x: ...
trial_gpt4o_2
{ "original_instruction": "Alina is fascinated by palindromic numbers. A palindromic number is a number that remains the same when its digits are reversed. For example, 121 and 1331 are palindromic numbers, while 123 and 1234 are not.\n\nAlina wonders if she can find the smallest palindromic number greater than or eq...
0.731985
Taco_11833
C
[ "is_palindromic", "find_smallest_palindrome" ]
2
[ [ "find_smallest_palindrome", "is_palindromic" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c6d9981c559ed3f37071a58570816e01cb83d004
4a089fecd2ebbf87731c132c40794a15a44f7061
v1.0
complete
Taco
Taco_11947_C
from typing import List def find_primes(nums: List[int]) -> List[int]: """ Returns a list of prime numbers from the given list of integers. Example: >>> find_primes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) [2, 3, 5, 7] >>> find_primes([11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) [11, 13, ...
from typing import List def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: ...
from solution import find_primes def test_find_primes_basic(): assert find_primes([2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 3, 5, 7, 11] assert find_primes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert find_primes([11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == [11, 13, 17, 19, 23, 29, 31, 37,...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def find_pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List\n\ndef is_prime(n: int) -> bool:\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if n <= 1:\n r...
trial_gpt4o_1
{ "original_instruction": "Write a function that takes a list of integers and returns a new list containing only the prime numbers from the original list. The returned list should have the prime numbers in the same order as they appeared in the input list. Note that 1 is not considered a prime number.\n\n**Function S...
0.708269
Taco_11947
C
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b0e180db52e190420948d7176dc36a7806f83a5a
e20eb8275f0f7310c2c161c1cf315328e7e554ba