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_75295_C | def decode_instruction(instruction: str) -> str:
"""
Decodes a single encoded instruction by doubling each digit.
>>> decode_instruction("a2b4")
'a22b44'
>>> decode_instruction("z1x2c3")
'z11x22c33'
>>> decode_instruction("g9h")
'g99h'
>>> decode_instruction("abc"... | def decode_instruction(instruction):
"""
Decodes a single encoded instruction by doubling each digit.
"""
decoded = []
for char in instruction:
if char.isdigit():
decoded.append(char * 2)
else:
decoded.append(char)
return ''.join(decoded)
def decode_instr... | from solution import decode_instruction, decode_instructions
def test_decode_instruction():
assert decode_instruction("a2b4") == "a22b44"
assert decode_instruction("z1x2c3") == "z11x22c33"
assert decode_instruction("g9h") == "g99h"
assert decode_instruction("abc") == "abc"
assert decode_instruction... | [
{
"docstring": "Decodes a single encoded instruction by doubling each digit.",
"function_declaration": "def decode_instruction(instruction):",
"function_name": "decode_instruction",
"parameter_list": "(instruction)"
},
{
"docstring": "Decodes a list of encoded instructions.",
"function_d... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def decode_instruction(instruction):\n \"\"\"\n Decode the given instruction string according to the rules:\n - Each lowercase letter remains unchanged.\n... | trial_gpt4o_2 | {
"original_instruction": "During a treasure hunt, a team discovers an old map that provides encoded instructions to find the treasure. Each instruction is a string that consists of lowercase letters and digits. The team must decode the instructions to make any sense of them.\n\nThe decoding rule is very simple:\n- E... | 0.633643 | Taco_75295 | C | [
"decode_instruction",
"decode_instructions"
] | 2 | [
[
"decode_instructions",
"decode_instruction"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 05344e4d21f8d69fd10ecf7678922998695b7bed | 90c35ecd703e71fd5c26fb5888c00c068f82e8e0 | |||
v1.0 | complete | Taco | Taco_75360_C | from typing import List
def longest_common_subsequence(sequences: List[List[int]]) -> List[int]:
""" Calculate the longest subsequence of numbers that are present in at least two different sequences from a given list of sequences.
>>> longest_common_subsequence([
[1, 2, 3, 4, 5, 6],
[5, 6, 7, 8... | from typing import List
def is_subsequence(small: List[int], large: List[int]) -> bool:
"""
Helper function to check if `small` is subsequence of `large`.
"""
it = iter(large)
return all(elem in it for elem in small)
def generate_all_subsequences(seq: List[int]) -> List[List[int]]:
"""
Hel... | from solution import longest_common_subsequence
def test_longest_common_subsequence_general():
sequences = [
[1, 2, 3, 4, 5, 6],
[5, 6, 7, 8, 9],
[1, 2, 8, 9, 10]
]
result = longest_common_subsequence(sequences)
assert result == [5, 6] or result == [8, 9]
def test_longest_commo... | [
{
"docstring": "Helper function to check if `small` is subsequence of `large`.",
"function_declaration": "def is_subsequence(small, large):",
"function_name": "is_subsequence",
"parameter_list": "(small, large)"
},
{
"docstring": "Helper function to generate all possible subsequences of a se... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from typing import List\n\ndef is_subsequence(shorter: List[int], longer: List[int]) -> bool:\n \"\"\"\n Helper function to determine if `shorter` is a subse... | trial_gpt4o_2 | {
"original_instruction": "Your task is to write a function that will calculate the longest subsequence of numbers that are present in at least two different sequences from a given list of sequences.\n\nFor example, suppose the input is as follows:\n\n```python\nsequences = [\n [1, 2, 3, 4, 5, 6],\n [5, 6, 7, 8... | 0.700568 | Taco_75360 | C | [
"is_subsequence",
"generate_all_subsequences",
"longest_common_subsequence"
] | 3 | [
[
"longest_common_subsequence",
"generate_all_subsequences"
],
[
"longest_common_subsequence",
"is_subsequence"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | c7d0dda6a36c54ed51dc6755865be1fc9d35f598 | 87a62618c25b75b022dff55c4f2e1aa2e952e3bc | |||
v1.0 | complete | Taco | Taco_74868_C | def sieve_of_eratosthenes(max_num):
"""
Generates a list of prime numbers up to a given number using the Sieve of Eratosthenes.
"""
pass
def get_prime_pairs(n, primes):
"""
Finds all pairs of primes (p, q) such that p < q and p + q = n.
"""
pass
def find_prime_pairs(t, cases):
"""
... | def sieve_of_eratosthenes(max_num):
is_prime = [True] * (max_num + 1)
is_prime[0], is_prime[1] = False, False
for start in range(2, int(max_num**0.5) + 1):
if is_prime[start]:
for multiple in range(start * start, max_num + 1, start):
is_prime[multiple] = False
return ... | from solution import sieve_of_eratosthenes, get_prime_pairs, find_prime_pairs
def test_sieve_of_eratosthenes():
assert sieve_of_eratosthenes(10) == [2, 3, 5, 7]
assert sieve_of_eratosthenes(20) == [2, 3, 5, 7, 11, 13, 17, 19]
assert sieve_of_eratosthenes(1) == []
assert sieve_of_eratosthenes(2) == [2]
... | [
{
"docstring": null,
"function_declaration": "def sieve_of_eratosthenes(max_num):",
"function_name": "sieve_of_eratosthenes",
"parameter_list": "(max_num)"
},
{
"docstring": null,
"function_declaration": "def get_prime_pairs(n, primes):",
"function_name": "get_prime_pairs",
"para... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def sieve(limit):\n \"\"\" Use the Sieve of Eratosthenes to generate a list of primes up to 'limit' \"\"\"\n is_prime = [True] * (limit + 1)\n is_prime[0]... | trial_gpt4o_9 | {
"original_instruction": "Deepak loves prime numbers. He wants to find all pairs of primes $(p, q)$ such that $p < q$ and $p + q = n$ for a given number $n$. Could you help Deepak find all such pairs?\n\n-----Input-----\n\nThe first line contains an integer $t$ ($1 \\le t \\le 10^3$) — the number of test cases.\n\nE... | 0.705704 | Taco_74868 | C | [
"sieve_of_eratosthenes",
"get_prime_pairs",
"find_prime_pairs"
] | 3 | [
[
"find_prime_pairs",
"get_prime_pairs"
],
[
"find_prime_pairs",
"sieve_of_eratosthenes"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | dca5a3bbb4541127d8a632203a62aa049c28af6c | 3613db8944290d9ac376d2b43922efd1998aa291 | |||
v1.0 | complete | Taco | Taco_75437_C | from typing import List
def is_prime(num: int) -> bool:
"""
Helper function to check if a number is prime.
>>> is_prime(2)
True
>>> is_prime(3)
True
>>> is_prime(4)
False
>>> is_prime(11)
True
>>> is_prime(15)
False
"""
pass
def next_prime(n: int) -> int:
""... | def is_prime(num):
"""
Helper function to check if a number is prime.
"""
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return F... | from solution import is_prime, next_prime
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(11) == True
assert is_prime(15) == False
def test_next_prime():
assert next_prime(17) == 19
assert next_prime(10) == 11
asser... | [
{
"docstring": "Helper function to check if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns the smallest prime number greater than n.",
"function_declaration": "def next_prime(n):",
"... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n r... | trial_gpt4o_2 | {
"original_instruction": "Sam is a software developer who is fascinated by prime numbers. He wants to write a program that can determine the smallest prime number greater than a given integer n.\n\nYour task is to help Sam by writing a function that, given an integer n, returns the smallest prime number greater than... | 0.832119 | Taco_75437 | C | [
"is_prime",
"next_prime"
] | 2 | [
[
"next_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b58674101b1266a13030d17cbdd67bb9914ac3eb | 36b9fcf3e51e51ce42a6f32fb306bcb7c333b217 | |||
v1.0 | complete | Taco | Taco_75340_C | def is_valid_subsequence(students):
"""
Function to check whether there exists a non-empty subsequence of students
satisfying the given conditions.
"""
pass
def check_subsequences_for_cases(test_cases):
"""
Function to check each test case and print result accordingly.
"""
pass
de... | def is_valid_subsequence(students):
"""
Function to check whether there exists a non-empty subsequence of students
satisfying the given conditions.
"""
n = len(students)
# Sort students overall on math marks as primary key, science marks as secondary key
students.sort()
# Chec... | from solution import check_subsequences_for_cases, read_input
def test_basic_example():
input_data = """2
3
70 80 90
60 75 90
80 80 70
5
55 65 75
60 60 70
70 70 65
75 80 80
50 65 85"""
expected_output = ["YES", "YES"]
test_cases = read_input(input_data)
assert check_subsequences_for_cases(test_cases) =... | [
{
"docstring": "Function to check whether there exists a non-empty subsequence of students \nsatisfying the given conditions.",
"function_declaration": "def is_valid_subsequence(students):",
"function_name": "is_valid_subsequence",
"parameter_list": "(students)"
},
{
"docstring": "Function t... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_valid_subsequence(students):\n \"\"\"\n Function to check whether there exists a non-empty subsequence of students \n satisfying the given conditio... | trial_gpt4o_0 | {
"original_instruction": "You are given a list of `n` students, each with their respective marks in three subjects - Math, Science, and English. You need to find out if there exists a non-empty subsequence of these students such that:\n1. The students in this subsequence have their marks sorted in increasing order i... | 0.560611 | Taco_75340 | C | [
"is_valid_subsequence",
"check_subsequences_for_cases",
"read_input"
] | 3 | [
[
"check_subsequences_for_cases",
"is_valid_subsequence"
]
] | 1 | [
"read_input"
] | false | [] | false | pytest | true | [] | true | 4c40f3bb9ad43a22718ddf2211ba1b78e15cf3e4 | b5a313b0828bba39f22b29c825d1da7d5462e886 | |||
v1.0 | complete | Taco | Taco_75490_C | def replace_primes_and_multiples_of_five(lst):
""" Takes a list of integers and returns the same list with all prime
numbers replaced by the string "prime", and all multiples of 5 replaced
by the string "five". If a number is both a prime and a multiple of 5,
it should be replaced by the string "prim... | def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def replace_primes_and_multiples_of_five(lst):
if isinstance(lst, list) and all(isinstance(x, int) for x in lst):
for i in range(len(lst)):
... | from solution import replace_primes_and_multiples_of_five
def test_valid_input():
assert replace_primes_and_multiples_of_five([2, 5, 10, 15, 17, 20]) == ["prime", "prime-five", "five", "five", "prime", "five"]
def test_empty_list():
assert replace_primes_and_multiples_of_five([]) == []
def test_non_prime_num... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def replace_primes_and_multiples_of_five(lst):",
"function_name": "replace_primes_and_multiples_of_five",
"parame... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def replace_primes_and_fives(lst):\n \"\"\"\n Replaces prime numbers with \"prime\", multiples of 5 with \"five\",\n and numbers that are both with \"prim... | trial_gpt4o_2 | {
"original_instruction": "Write a function that takes a list of integers and returns the same list with all prime numbers replaced by the string \"prime\", and all multiples of 5 replaced by the string \"five\". If a number is both a prime and a multiple of 5, it should be replaced by the string \"prime-five\".\n\nF... | 0.571975 | Taco_75490 | C | [
"is_prime",
"replace_primes_and_multiples_of_five"
] | 2 | [
[
"replace_primes_and_multiples_of_five",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 60606ddc81def425c07b44a4efba8e6a5e825086 | e05fec223e649fbc6a6bd3e54d7774efd067e846 | |||
v1.0 | complete | Taco | Taco_75630_C | import math
def is_relatively_prime(a, b):
"""
Check if two integers a and b are relatively prime.
"""
pass
def find_relatively_prime_numbers(n, m):
"""
Find the first n integers that are relatively prime to m.
>>> find_relatively_prime_numbers(3, 10) [1, 3, 7]
>>> find_relatively_prim... | import math
def is_relatively_prime(a, b):
"""
Check if two integers a and b are relatively prime.
"""
return math.gcd(a, b) == 1
def find_relatively_prime_numbers(n, m):
"""
Find the first n integers that are relatively prime to m.
"""
result = []
k = 1
while len(result) < n:
... | from solution import is_relatively_prime, find_relatively_prime_numbers
def test_is_relatively_prime():
assert is_relatively_prime(1, 10) == True
assert is_relatively_prime(3, 10) == True
assert is_relatively_prime(2, 10) == False
assert is_relatively_prime(7, 12) == True
assert is_relatively_prime... | [
{
"docstring": "Check if two integers a and b are relatively prime.",
"function_declaration": "def is_relatively_prime(a, b):",
"function_name": "is_relatively_prime",
"parameter_list": "(a, b)"
},
{
"docstring": "Find the first n integers that are relatively prime to m.",
"function_decl... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef relatively_prime_integers(n, m):\n \"\"\"\n Finds the first n integers that are relatively prime to m.\n \n :param n: Number of inte... | trial_gpt4o_2 | {
"original_instruction": "Write a program to find the first n integers that are relatively prime to a given integer m. Two integers are relatively prime if the greatest common divisor (GCD) of the two numbers is 1.\n\nExample 1:\nInput: n = 3, m = 10\nOutput: [1, 3, 7]\nExplanation: The first three integers that are... | 0.621444 | Taco_75630 | C | [
"is_relatively_prime",
"find_relatively_prime_numbers"
] | 2 | [
[
"find_relatively_prime_numbers",
"is_relatively_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3d85c6be8c2e1e72a05eb98a0e4eb189c3291022 | 13f6b3b28efcc460625ef653747b03d3e3d296b4 | |||
v1.0 | complete | Taco | Taco_75723_C | def is_palindrome(s: str) -> bool:
"""
Check if a given string is a palindrome.
>>> is_palindrome("radar") True
>>> is_palindrome("hello") False
>>> is_palindrome("level") True
"""
def check_palindromes(strings: List[str]) -> List[str]:
"""
Given a list of strings, return a list of ... | def is_palindrome(s):
"""
Check if a given string is a palindrome.
"""
return s == s[::-1]
def check_palindromes(strings):
"""
Given a list of strings, return a list of "Yes" or "No" for each string depending on
whether it is a palindrome or not.
"""
results = []
for s in string... | from solution import is_palindrome, check_palindromes
def test_is_palindrome():
assert is_palindrome("radar") == True
assert is_palindrome("hello") == False
assert is_palindrome("level") == True
assert is_palindrome("") == True
assert is_palindrome("a") == True
assert is_palindrome("ab") == Fal... | [
{
"docstring": "Check if a given string is a palindrome.",
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": "Given a list of strings, return a list of \"Yes\" or \"No\" for each string depending on\nwhether it is a p... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_palindrome(s):\n \"\"\"\n Determines if the given string is a palindrome.\n \n :param s: Input string\n :return: 'Yes' if the string is a pal... | trial_gpt4o_2 | {
"original_instruction": "You are given a collection of strings and you need to determine if each string is a palindrome. A palindrome is a string that reads the same backward as forward.\n\n-----Input:-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases.\n- The next T... | 0.833546 | Taco_75723 | C | [
"is_palindrome",
"check_palindromes"
] | 2 | [
[
"check_palindromes",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | d5b64492f69c076daf34bca8556c507233a6bbfc | 9b8f3291ab4dcf0370dcc650b37d7d97925993b2 | |||
v1.0 | complete | Taco | Taco_75464_C | def find(parent, i):
""" Helper function to find the parent of a node in the union-find data structure."""
pass
def union(parent, rank, x, y):
""" Helper function to union two sets in the union-find data structure."""
pass
def kruskal_mst(num_islands, bridges):
""" Implementation of Kruskal's algo... | def find(parent, i):
if parent[i] == i:
return i
else:
return find(parent, parent[i])
def union(parent, rank, x, y):
xroot = find(parent, x)
yroot = find(parent, y)
if rank[xroot] < rank[yroot]:
parent[xroot] = yroot
elif rank[xroot] > rank[yroot]:
parent[yr... | from solution import minimum_cost_to_connect_islands
def test_case_1():
T = 2
test_cases = [
(4, 5, [(1, 2, 1), (2, 3, 2), (3, 4, 4), (1, 3, 3), (1, 4, 5)]),
(3, 1, [(1, 2, 1)])
]
assert minimum_cost_to_connect_islands(T, test_cases) == [7, -1]
def test_single_island():
T = 1
t... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n rootX = find(parent, x)\n... | trial_gpt4o_2 | {
"original_instruction": "Samantha is working as a software engineer and recently, she has been assigned a task to develop a simulation for a fictional game. In this game, there are several islands connected by bridges. Each bridge has a certain cost associated with crossing it.\n\nThe game requires Samantha to find... | 0.650811 | Taco_75464 | C | [
"find",
"union",
"kruskal_mst",
"minimum_cost_to_connect_islands"
] | 4 | [
[
"kruskal_mst",
"find"
],
[
"kruskal_mst",
"union"
],
[
"minimum_cost_to_connect_islands",
"kruskal_mst"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | aa482d427eb5552d21b8b80e683e13ec998dc636 | a839bfec812194b7f34b072672b8b4e6ba7719ee | |||
v1.0 | complete | Taco | Taco_75529_C | def decode_all_messages(T: int, inputs: List) -> List[str]:
"""
The Pandavas need to send coded messages back and forth during the war to strategize and foil the plans of the Kauravas.
Yudhishthira comes up with an ingenious idea for encoding these messages. He decides that each message will be
conver... | def factorize(n, primes):
factors = []
for p in primes:
while n % p == 0:
factors.append(p)
n //= p
if n == 1:
return factors
return None
def decode_message(messages, num, prime_map):
primes = sorted(prime_map.values())
factors = factorize(num, primes)
... | from solution import decode_all_messages
def test_sample_input1():
T = 2
inputs = [
3, 'a 2',
'b 3',
'c 5',
30,
5,
'a 2',
'b 3',
'c 5',
'd 7',
'e 11',
77
]
expected = ['abc', 'de']
result = decode... | [
{
"docstring": null,
"function_declaration": "def factorize(n, primes):",
"function_name": "factorize",
"parameter_list": "(n, primes)"
},
{
"docstring": null,
"function_declaration": "def decode_message(messages, num, prime_map):",
"function_name": "decode_message",
"parameter_l... | [
1,
0
] | 1 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def factorize(n, primes):\n factors = []\n for p in primes:\n while n % p == 0:\n factors.append(p)\n n //= p\n if n == 1:\n ... | trial_gpt4o_0 | {
"original_instruction": "The Pandavas need to send coded messages back and forth during the war to strategize and foil the plans of the Kauravas. Yudhishthira comes up with an ingenious idea for encoding these messages. He decides that each message will be converted to a number based on a custom numbering system wh... | 0.600749 | Taco_75529 | C | [
"factorize",
"decode_message",
"decode_all_messages"
] | 3 | [
[
"decode_all_messages",
"decode_message"
],
[
"decode_message",
"factorize"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | d7fe3ad94eac1497bd44da5eeca1722450b23157 | 094af9200a62960d182788f813385d7e04a14dac | |||
v1.0 | complete | Taco | Taco_75687_C | def is_palindrome(s):
"""
Check if a string is a palindrome.
"""
pass
def palindromic_partitions(s):
"""
Generate all possible palindromic partitions of the given string.
:param s: input string containing only lowercase letters
:return: list of lists, where each list contains a set... | def is_palindrome(s):
"""
Check if a string is a palindrome.
"""
return s == s[::-1]
def palindromic_partitions(s):
"""
Generate all possible palindromic partitions of the given string.
:param s: input string containing only lowercase letters
:return: list of lists, where each list... | from solution import palindromic_partitions
def test_empty_string():
assert palindromic_partitions("") == [[]]
def test_single_character():
assert palindromic_partitions("a") == [['a']]
def test_two_characters():
assert palindromic_partitions("aa") == [['a', 'a'], ['aa']]
assert palindromic_partition... | [
{
"docstring": "Check if a string is a palindrome.",
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": "Generate all possible palindromic partitions of the given string.\n\n:param s: input string containing only lower... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_palindrome(s):\n \"\"\"\n Check if a given string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindromic_partitions(s):\n \"\"\... | trial_gpt4o_2 | {
"original_instruction": "Implement a function that generates all possible **palindromic partitions** of a given string. A palindrome is a string that reads the same backward as forward. For instance, for the string \"aab\", the palindromic partitions are [\"a\", \"a\", \"b\"], and [\"aa\", \"b\"].\n\n1. Your functi... | 0.796253 | Taco_75687 | C | [
"is_palindrome",
"palindromic_partitions"
] | 2 | [
[
"palindromic_partitions",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f10d1700e6a93de6f6291d2714841e63fbe095b6 | 9c766937d83a3879a3fbcacdc660dc48b145150a | |||
v1.0 | complete | Taco | Taco_75643_C | from typing import List, Tuple, Union
def word_transformation(start: str, target: str, dictionary: List[str]) -> Union[Tuple[str], Tuple[str, List[str]]]:
""" Find the shortest transformation sequence from a starting word to a target word
by changing one letter at a time, with each intermediate word being a va... | from collections import deque
def one_letter_diff(word1, word2):
count = sum(1 for a, b in zip(word1, word2) if a != b)
return count == 1
def word_transformation(start, target, dictionary):
if start == target:
return ("YES", [start])
dictionary = set(dictionary)
if target not in ... | from solution import word_transformation
def test_example_1():
start = "hit"
target = "cog"
dictionary = ["hot", "dot", "dog", "lot", "log", "cog"]
assert word_transformation(start, target, dictionary) == ("YES", ['hit', 'hot', 'dot', 'dog', 'cog'])
def test_example_2():
start = "hit"
target =... | [
{
"docstring": null,
"function_declaration": "def one_letter_diff(word1, word2):",
"function_name": "one_letter_diff",
"parameter_list": "(word1, word2)"
},
{
"docstring": null,
"function_declaration": "def word_transformation(start, target, dictionary):",
"function_name": "word_tran... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef one_letter_diff(word1, word2):\n count = sum(1 for a, b in zip(word1, word2) if a != b)\n return count == 1\n\ndef word_... | trial_gpt4o_0 | {
"original_instruction": "A group of friends is playing a word transformation game. The game involves transforming a starting word into a target word by changing one letter at a time, such that each intermediate word must also be a valid word from the given dictionary. Your task is to find the shortest transformatio... | 0.686175 | Taco_75643 | C | [
"one_letter_diff",
"word_transformation"
] | 2 | [
[
"word_transformation",
"one_letter_diff"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 03a2a3224dbad1af69f099d6d84b6f7c04c7a7bb | d53bfa21d231d3c2881c1abd101d88e11e5f9e63 | |||
v1.0 | complete | Taco | Taco_75819_C | def can_satisfy_everyone(i, p, available_items, preferences):
"""
Determines if it is possible to satisfy everyone with at least one item from
their list of preferred items based on the available items.
Parameters:
i (int): number of available items.
p (int): number of people.
availabl... | def can_satisfy_everyone(i, p, available_items, preferences):
"""
Determines if it is possible to satisfy everyone with at least one item from
their list of preferred items based on the available items.
Parameters:
i (int): number of available items.
p (int): number of people.
availabl... | import pytest
from solution import can_satisfy_everyone, from_input_string, to_output_string
def test_example_1():
input_str = """5 3
burger hotdog fries salad soda
2 burger soda
3 fries hotdog salad
1 hotdog"""
expected_output = "yes"
i, p, available_items, preferences = from_input_string(input_str)
a... | [
{
"docstring": "Determines if it is possible to satisfy everyone with at least one item from \ntheir list of preferred items based on the available items.\n\nParameters:\ni (int): number of available items.\np (int): number of people.\navailable_items (list): list of available items.\npreferences (list of lists... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def can_satisfy_everyone(i, p, available_items, people_preferences):\n \"\"\"\n Determines if it's possible to satisfy all people by giving each person at le... | trial_gpt4o_2 | {
"original_instruction": "You are hosting a barbecue event and you want to ensure that there's enough food for everyone. You have a list of people attending and each person has preferences for what they want to eat. Every person will be satisfied if they get at least one item from their list of preferred items. You ... | 0.599688 | Taco_75819 | C | [
"can_satisfy_everyone",
"parse_input",
"from_input_string",
"to_output_string"
] | 4 | [
[
"from_input_string",
"parse_input"
]
] | 1 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | b9578eca30ebf9b3200f950cd5c0b965654ddb59 | 3e02574f579c10c412c00b9a946ab93a7ad4ec97 | |||
v1.0 | complete | Taco | Taco_75507_C | def max_overlapping_employees(test_cases):
""" Calculate the maximum number of overlapping employees at any given time.
:param test_cases: List of test cases where each test case is a list of intervals represented by tuples.
:return: List of integers representing the maximum number of overlapping employees ... | def max_overlapping_employees(test_cases):
results = []
for shifts in test_cases:
time_points = []
for start, end in shifts:
time_points.append((start, 'start'))
time_points.append((end, 'end'))
time_points.sort()
max_overlaps = 0
... | def test_max_overlapping_employees():
input_data = "2\n3\n1 4\n2 6\n8 10\n4\n1 2\n2 3\n3 4\n4 5"
expected_output = "2\n1"
assert run(input_data) == expected_output
input_data = "1\n5\n1 5\n2 6\n4 8\n3 7\n8 10"
expected_output = "4"
assert run(input_data) == expected_output
input_data = "2\... | [
{
"docstring": null,
"function_declaration": "def max_overlapping_employees(test_cases):",
"function_name": "max_overlapping_employees",
"parameter_list": "(test_cases)"
},
{
"docstring": null,
"function_declaration": "def parse_input(input_string):",
"function_name": "parse_input",
... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_overlapping_employees(test_cases):\n results = []\n for shifts in test_cases:\n time_points = []\n for start, end in shifts:\n ... | trial_gpt4o_0 | {
"original_instruction": "A company wants to streamline its employee work schedules to maximize productivity. It has employees working different shifts, each represented by an interval [start, end]. Two employees are considered \"overlapping\" if their working intervals intersect. The goal is to find out the maximum... | 0.589385 | Taco_75507 | C | [
"max_overlapping_employees",
"parse_input",
"prepare_output",
"run"
] | 4 | [
[
"run",
"max_overlapping_employees"
],
[
"run",
"parse_input"
],
[
"run",
"prepare_output"
]
] | 3 | [
"parse_input",
"prepare_output"
] | false | [] | false | pytest | false | [] | true | c16403addf72d9209f9a9c38c2e12006a15e8ac4 | caf33ceaf494e2f495f79faa04c5a617284b825e | |||
v1.0 | complete | Taco | Taco_75943_C | def process_input_and_find_mst_weight(input_string: str) -> int:
"""
Watson and Holmes are trying to solve a series of mysterious crimes in London.
Watson has represented each crime scene as a node and each clue as an edge with a weight.
Your task is to help them find the minimum spanning tree (MST) of... | def find_mst_weight(n, edges):
"""
Function to find the total weight of the Minimum Spanning Tree (MST) using Kruskal's Algorithm.
:param n: Number of nodes (crime scenes)
:param edges: List of tuples (u, v, w) where u and v are nodes and w is the weight of the edge between them.
:return: Total... | def test_sample_input():
input_data = "4 5\n1 2 5\n1 3 10\n2 3 4\n2 4 11\n3 4 8"
assert process_input_and_find_mst_weight(input_data) == 17
def test_single_edge():
input_data = "2 1\n1 2 10"
assert process_input_and_find_mst_weight(input_data) == 10
def test_disconnected_graph():
input_data = "3 1... | [
{
"docstring": "Function to find the total weight of the Minimum Spanning Tree (MST) using Kruskal's Algorithm.\n\n:param n: Number of nodes (crime scenes)\n:param edges: List of tuples (u, v, w) where u and v are nodes and w is the weight of the edge between them.\n:return: Total weight of the MST",
"funct... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_mst_weight(n, edges):\n \"\"\"\n Function to find the total weight of the Minimum Spanning Tree (MST) using Kruskal's Algorithm.\n \n :param n... | trial_gpt4o_0 | {
"original_instruction": "Dr. Watson and Sherlock Holmes are trying to solve a series of mysterious crimes in London. They find that every crime scene can be represented as a node, and each pair of nodes contains a unique clue that can help link two different cases. Watson, being a methodical person, decided to repr... | 0.661699 | Taco_75943 | C | [
"find_mst_weight",
"process_input_and_find_mst_weight"
] | 2 | [
[
"process_input_and_find_mst_weight",
"find_mst_weight"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 7fb85cdaf302ffc9f9070d49e513012df1e4f78b | ee151ae603f78f92a92f40dcbc067586dc53db6d | |||
v1.0 | complete | Taco | Taco_75972_C | def sum_of_digit_pairs(number):
digits = list(map(int, str(number)))
n = len(digits)
sum_pairs = 0
for i in range(n):
for j in range(i + 1, n):
sum_pairs += digits[i] + digits[j]
return sum_pairs
def largest_sum_of_digit_pairs(N, numbers):
"""
Determines the smallest nu... | def sum_of_digit_pairs(number):
digits = list(map(int, str(number)))
n = len(digits)
sum_pairs = 0
for i in range(n):
for j in range(i + 1, n):
sum_pairs += digits[i] + digits[j]
return sum_pairs
def largest_sum_of_digit_pairs(N, numbers):
max_sum = -1
min_number_with_ma... | from solution import largest_sum_of_digit_pairs
def test_with_examples():
assert largest_sum_of_digit_pairs(4, [123, 456, 789, 101112]) == 789
def test_single_number():
assert largest_sum_of_digit_pairs(1, [98765432123456789]) == 98765432123456789
def test_tie_sum_choose_smaller_number():
assert largest_... | [
{
"docstring": null,
"function_declaration": "def sum_of_digit_pairs(number):",
"function_name": "sum_of_digit_pairs",
"parameter_list": "(number)"
},
{
"docstring": null,
"function_declaration": "def largest_sum_of_digit_pairs(N, numbers):",
"function_name": "largest_sum_of_digit_pa... | [
0,
0,
0,
0,
0,
1,
0,
0,
1,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def digit_pair_sum(num):\n \"\"\"\n Given a number, splits it into all possible pairs of digits and calculates the sum of these pairs.\n \"\"\"\n num_s... | trial_gpt4o_5 | {
"original_instruction": "Mike likes playing number games and has recently invented a new game involving digit pairs of numbers. Given a number, he splits it into all possible pairs of digits and calculates the sum of these pairs. Mike wants your help to determine which numbers in a list of numbers have the largest ... | 0.675592 | Taco_75972 | C | [
"sum_of_digit_pairs",
"largest_sum_of_digit_pairs"
] | 2 | [
[
"largest_sum_of_digit_pairs",
"sum_of_digit_pairs"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c248d58781b762ccfe12467ce33d3e54260ba5f8 | 94e416885ffd044e19e68cb92bb28329a707dd52 | |||
v1.0 | complete | Taco | Taco_76049_C | def custom_sort(input_list):
"""
Sorts a list of integers in non-decreasing order, while retaining the order
of duplicate elements as they appeared in the original list.
Arguments:
input_list -- a list of integers
Returns:
A sorted list of integers in non-decreasing order, with rel... | def custom_sort(input_list):
"""
Sorts a list of integers in non-decreasing order, while retaining the order
of duplicate elements as they appeared in the original list.
Arguments:
input_list -- a list of integers
Returns:
A sorted list of integers in non-decreasing order, with rel... | from solution import read_sort_output
def test_example_1():
assert read_sort_output("4 5 2 3 3 1 4 5") == "1 2 3 3 4 4 5 5"
def test_example_2():
assert read_sort_output("-1 -5 0 3 -5 2 1") == "-5 -5 -1 0 1 2 3"
def test_empty_input():
assert read_sort_output("") == ""
def test_single_element():
ass... | [
{
"docstring": "Sorts a list of integers in non-decreasing order, while retaining the order\nof duplicate elements as they appeared in the original list.\n\nArguments:\ninput_list -- a list of integers\n\nReturns:\nA sorted list of integers in non-decreasing order, with relative order of equal elements preserve... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def sort_list_preserving_order(lst):\n \"\"\"\n Sorts a list in non-decreasing order, retaining the relative order of equal elements.\n \n Args:\n l... | trial_gpt4o_2 | {
"original_instruction": "You are given a list of integers and your task is to sort this list in non-decreasing order, but if two numbers have the same value, the one that appeared first in the original list should come first.\n\nWrite a function that implements this sorting algorithm.\n\nInput\n\nThe input consists... | 0.778672 | Taco_76049 | C | [
"custom_sort",
"read_sort_output"
] | 2 | [
[
"read_sort_output",
"custom_sort"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e5a814a837d20eef1da2eec6236e1020eda182b0 | 504d3754199b78990b716c4055f88455bf366645 | |||
v1.0 | complete | Taco | Taco_75996_C | def process_input(n: int, m: int, grid_lines: List[str], q: int, queries: List[Tuple[int, int]]) -> None:
"""
Consider a grid with n rows and m columns, each cell initially occupied by a person.
Each person can either be sitting or standing, and they can only see other standing
people in the same row o... | def count_pairs(grid, n, m):
horz_pairs = 0
vert_pairs = 0
# Calculate horizontal pairs
for r in range(n):
count = 0
for c in range(m):
if grid[r][c] == 'T':
count += 1
else:
if count > 1:
horz_pairs += count * ... | from solution import process_input
def test_example():
n = 4
m = 4
grid_lines = [
"SSSS",
"STTT",
"SSSS",
"STSS"
]
q = 3
queries = [
(2, 2),
(3, 4),
(4, 2)
]
process_input(n, m, grid_lines, q, queries)
def test_all_sitting():
... | [
{
"docstring": null,
"function_declaration": "def count_pairs(grid, n, m):",
"function_name": "count_pairs",
"parameter_list": "(grid, n, m)"
},
{
"docstring": null,
"function_declaration": "def toggle_and_count(n, m, grid, queries):",
"function_name": "toggle_and_count",
"parame... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_pairs(grid):\n n = len(grid)\n m = len(grid[0])\n pairs = 0\n\n # Count visible pairs in rows\n for i in range(n):\n standing_count... | trial_gpt4o_1 | {
"original_instruction": "Consider a grid with n rows and m columns, each cell initially occupied by a person. Each person can either be sitting or standing, and they can only see other standing people in the same row or column until blocked by another sitting person.\n\nYou are given the initial state of the grid a... | 0.634154 | Taco_75996 | C | [
"count_pairs",
"toggle_and_count",
"process_input"
] | 3 | [
[
"process_input",
"toggle_and_count"
],
[
"toggle_and_count",
"count_pairs"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | 9aa093e1b4ecb55ff38ecd3826aac1eb58a8c1dc | c06437355101dd4f13aa3d1d847433b1ed06b8f2 | |||
v1.0 | complete | Taco | Taco_75813_C | from datetime import datetime
from typing import List, Tuple
def is_leap_year(year: int) -> bool:
"""
Determines if a given year is a leap year.
Args:
year (int): The year to check.
Returns:
bool: True if the year is a leap year, False otherwise.
"""
def days_between_dates(ye... | from datetime import datetime
def is_leap_year(year):
"""
Determines if a given year is a leap year.
Args:
year (int): The year to check.
Returns:
bool: True if the year is a leap year, False otherwise.
"""
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
r... | from solution import is_leap_year, days_between_dates, process_input
def test_is_leap_year():
assert is_leap_year(2020) == True
assert is_leap_year(2021) == False
assert is_leap_year(1900) == False
assert is_leap_year(2000) == True
def test_days_between_dates():
assert days_between_dates(2020, "1/... | [
{
"docstring": "Determines if a given year is a leap year.\n\nArgs:\nyear (int): The year to check.\n\nReturns:\nbool: True if the year is a leap year, False otherwise.",
"function_declaration": "def is_leap_year(year):",
"function_name": "is_leap_year",
"parameter_list": "(year)"
},
{
"docs... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from datetime import date\n\ndef is_leap_year(year):\n if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):\n return True\n return False\n\nde... | trial_gpt4o_1 | {
"original_instruction": "You are required to write a program that determines if a given year is a leap year and then calculates the number of days between two given dates within that year.\n\nInput\n\nThe input consists of multiple datasets. Each dataset contains one integer y, representing the year, followed by tw... | 0.702876 | Taco_75813 | C | [
"is_leap_year",
"days_between_dates",
"process_input"
] | 3 | [
[
"process_input",
"days_between_dates"
]
] | 1 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | f5f1bdf395cdf0ffe0d3197197650394dd2e5ad4 | 7bb716726f048fac718e45695dea1aa009f42eca | |||
v1.0 | complete | Taco | Taco_75998_C | def is_strong_password(password: str) -> str:
"""
Determines if a given password is strong or weak based on the following conditions:
1. It has a length of at least 8 characters.
2. It contains at least one lowercase letter.
3. It contains at least one uppercase letter.
4. It contains at least o... | def is_strong_password(password):
special_characters = set('!@#$%^&*()-+')
if len(password) < 8:
return 'WEAK'
has_lower = any(c.islower() for c in password)
has_upper = any(c.isupper() for c in password)
has_digit = any(c.isdigit() for c in password)
has_special = any(c in spe... | from solution import is_strong_password, check_passwords
def test_is_strong_password():
assert is_strong_password("P@ssw0rd") == "STRONG"
assert is_strong_password("weakpassword") == "WEAK"
assert is_strong_password("StrongPass1") == "WEAK"
assert is_strong_password("12345678!") == "WEAK"
assert is... | [
{
"docstring": null,
"function_declaration": "def is_strong_password(password):",
"function_name": "is_strong_password",
"parameter_list": "(password)"
},
{
"docstring": null,
"function_declaration": "def check_passwords(passwords):",
"function_name": "check_passwords",
"paramete... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\n\ndef check_password_strength(password):\n \"\"\"\n Determines if the given password is strong or weak based on predefined criteria.\n \"\"\"\n... | trial_gpt4o_1 | {
"original_instruction": "Password Strength Checker\n\nA company's security policy requires all passwords to be strong. A password is considered strong if it satisfies the following conditions:\n\n1. It has a length of at least 8 characters.\n2. It contains at least one lowercase letter.\n3. It contains at least one... | 0.59326 | Taco_75998 | C | [
"is_strong_password",
"check_passwords"
] | 2 | [
[
"check_passwords",
"is_strong_password"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f5ad526089e091f4bd800e92010547cef83c2fa8 | 0fe25d2b07a57aa2161c7be05c896728c6fef5c4 | |||
v1.0 | complete | Taco | Taco_75696_C | import heapq
from typing import List, Tuple
def dijkstra(n: int, graph: dict, start: int, end: int) -> int:
"""
Finds the shortest path in a graph from start to end using Dijkstra's algorithm.
:param n: Number of cities
:param graph: Adjacency list of the graph where graph[u] is a list of (v, cost) pa... | import heapq
def dijkstra(n, graph, start, end):
"""
Finds the shortest path in a graph from start to end using Dijkstra's algorithm.
:param n: Number of cities
:param graph: Adjacency list of the graph where graph[u] is a list of (v, cost) pairs
:param start: Starting city A
:param end: Destin... | def test_dijkstra_basic():
graph = {
1: [(2, 10), (3, 30)],
2: [(1, 10), (3, 20), (4, 50)],
3: [(1, 30), (2, 20)],
4: [(2, 50)]
}
assert dijkstra(4, graph, 1, 4) == 60
assert dijkstra(4, graph, 1, 3) == 30
assert dijkstra(4, graph, 2, 3) == 20
assert dijkstra(4, g... | [
{
"docstring": "Finds the shortest path in a graph from start to end using Dijkstra's algorithm.\n:param n: Number of cities\n:param graph: Adjacency list of the graph where graph[u] is a list of (v, cost) pairs\n:param start: Starting city A\n:param end: Destination city B\n:return: Minimum cost from start to ... | [
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\nimport sys\n\ndef find_min_travel_cost(T, test_cases):\n results = []\n \n for i in range(T):\n N, M, edges, A, B = test_cases[i]\n ... | trial_gpt4o_9 | {
"original_instruction": "Bozo is planning a journey through different cities and wants to know the minimum travel cost. He needs to travel from city A to city B. Given the direct travel costs between some pairs of cities, help Bozo determine the minimum cost to travel from city A to city B.\n\nInput:-\n\nThe first ... | 0.682673 | Taco_75696 | C | [
"dijkstra",
"min_travel_cost",
"solve"
] | 3 | [
[
"min_travel_cost",
"dijkstra"
],
[
"solve",
"min_travel_cost"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | d5a76f2d6be36133fe66c8c3809d597121776abe | 72ab6f238224dba06a57188faf8be88252575955 | |||
v1.0 | complete | Taco | Taco_75924_C | def daily_rewards(m: int, data: List[List[int]]) -> int:
"""
Determine how many days Landa will get rewarded based on the quality scores for several days.
Parameters:
m (int): The number of days.
data (List[List[int]]): Each element is a list where the first number denotes the number of lenses prod... | def count_rewards(m, quality_scores):
"""
Returns the number of days Landa gets the reward.
Parameters:
m : int : The number of days.
quality_scores : list : Each element is a list containing the quality scores for a day.
Returns:
int : The number of days Landa gets the reward.
... | from solution import daily_rewards
def test_example_1():
m = 3
data = [
[3, 2, 4, 6],
[4, 3, 5, 7, 9],
[3, 8, 8, 8]
]
assert daily_rewards(m, data) == 2
def test_example_2():
m = 2
data = [
[2, 1, 5],
[3, 2, 2, 2]
]
assert daily_rewards(m, data) ... | [
{
"docstring": "Returns the number of days Landa gets the reward.\n\nParameters:\nm : int : The number of days.\nquality_scores : list : Each element is a list containing the quality scores for a day.\n\nReturns:\nint : The number of days Landa gets the reward.",
"function_declaration": "def count_rewards(m... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_rewards(m, days_quality_scores):\n \"\"\"\n Calculate the number of days Landa will get rewarded.\n \n Args:\n m (int): Number of days... | trial_gpt4o_2 | {
"original_instruction": "Landa works in a factory that produces lenses. Each lens can have different quality scores based on various factors. She maintains a record of the quality score for each lens produced daily. The factory rewards Landa if the average quality score of the lenses produced in a day is higher tha... | 0.6451 | Taco_75924 | C | [
"count_rewards",
"daily_rewards"
] | 2 | [
[
"daily_rewards",
"count_rewards"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 741631bb04f05543544836e7d9a3d25483702c02 | c0a38a23a0e027de6438a9653c88dc8ee25551d3 | |||
v1.0 | complete | Taco | Taco_76176_C | def longest_increasing_prime_subsequence(nums: List[int]) -> int:
""" Determines the length of the longest strictly increasing subsequence of prime numbers.
>>> longest_increasing_prime_subsequence([10, 2, 3, 5, 7, 11]) 5
>>> longest_increasing_prime_subsequence([4, 6, 8, 10, 12]) 0
""" | def is_prime(num):
"""
Checks if the number is a prime number.
"""
if num <= 1:
return False
if num <= 3:
return True
if num % 2 == 0 or num % 3 == 0:
return False
i = 5
while i * i <= num:
if num % i == 0 or num % (i + 2) == 0:
return False
... | from solution import longest_increasing_prime_subsequence
def test_example_1():
assert longest_increasing_prime_subsequence([10, 2, 3, 5, 7, 11]) == 5
def test_example_2():
assert longest_increasing_prime_subsequence([4, 6, 8, 10, 12]) == 0
def test_all_primes_increasing():
assert longest_increasing_prim... | [
{
"docstring": "Checks if the number is a prime number.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Determines the length of the longest strictly increasing subsequence of prime numbers.",
"function_declaration... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n r... | trial_gpt4o_1 | {
"original_instruction": "Petya is a lover of prime numbers. He enjoys numbers which have exactly two distinct positive divisors: 1 and the number itself. Petya wants to challenge you with constructing a prime sequence in a unique way. He gives you a set of integers and asks you to find the longest subsequence such ... | 0.643381 | Taco_76176 | C | [
"is_prime",
"longest_increasing_prime_subsequence"
] | 2 | [
[
"longest_increasing_prime_subsequence",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f3b681b63c3c481abae4185006d3570c8c7ef901 | e8e9f6a81b3b4680b3ca1000c96ca74544139feb | |||
v1.0 | complete | Taco | Taco_76227_C | def min_conference_rooms(meetings):
""" Find the minimum number of conference rooms required so that no meetings overlap.
>>> min_conference_rooms([[1, 4], [2, 5], [7, 9]])
2
>>> min_conference_rooms([[1, 3], [4, 6], [7, 9]])
1
>>> min_conference_rooms([[1, 4], [2, 5], [3, 6]])
3
>>> min... | import heapq
def min_conference_rooms(meetings):
if not meetings:
return 0
meetings.sort(key=lambda x: x[0])
heap = []
heapq.heappush(heap, meetings[0][1])
for i in range(1, len(meetings)):
if meetings[i][0] >= heap[0]:
heapq.heappop(heap)
... | from solution import min_conference_rooms
def test_min_conference_rooms():
meetings = [[1, 4], [2, 5], [7, 9]]
assert min_conference_rooms(meetings) == 2
def test_non_overlapping_meetings():
meetings = [[1, 3], [4, 6], [7, 9]]
assert min_conference_rooms(meetings) == 1
def test_all_meetings_overl... | [
{
"docstring": null,
"function_declaration": "def min_conference_rooms(meetings):",
"function_name": "min_conference_rooms",
"parameter_list": "(meetings)"
},
{
"docstring": null,
"function_declaration": "def min_conference_rooms_from_input():",
"function_name": "min_conference_rooms... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef min_conference_rooms(meetings):\n \"\"\"\n Returns the minimum number of conference rooms required so that no meetings overlap.\n \"\"... | trial_gpt4o_1 | {
"original_instruction": "A company wants to optimize the use of its conference rooms. Each conference room can be reserved for one or more meetings throughout the day. A meeting is defined by its start time and end time. Given the list of all the meetings that are planned for the day, you need to find the minimum n... | 0.583842 | Taco_76227 | C | [
"min_conference_rooms",
"min_conference_rooms_from_input"
] | 2 | [
[
"min_conference_rooms_from_input",
"min_conference_rooms"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 920a1af5617db13a6a6c780d49ceb001b2825c93 | ce875ab0acd0761ddecc5fdb15a15ca5c4908bc0 | |||
v1.0 | complete | Taco | Taco_76082_C | def determine_magic_square(grid_str: str) -> str:
"""
Given a 3x3 grid of numbers as a space-separated string, determine if it is a magic square.
A magic square is a grid of numbers where the sum of every row, column, and both main diagonals are equal.
Args:
grid_str: str: A space-separate... | def is_magic_square(grid):
"""
Determines whether the provided 3x3 grid is a magic square.
Parameters:
grid (list): A list of 9 integers representing the grid in row-major order.
Returns:
str: "Magic Square" if the grid is a magic square, "Not a Magic Square" otherwise.
"""
if ... | from solution import determine_magic_square
def test_magic_square():
assert determine_magic_square("8 1 6 3 5 7 4 9 2") == "Magic Square"
def test_not_magic_square():
assert determine_magic_square("1 2 3 4 5 6 7 8 9") == "Not a Magic Square"
def test_not_magic_square_negative_numbers():
assert determine_... | [
{
"docstring": "Determines whether the provided 3x3 grid is a magic square.\n\nParameters:\ngrid (list): A list of 9 integers representing the grid in row-major order.\n\nReturns:\nstr: \"Magic Square\" if the grid is a magic square, \"Not a Magic Square\" otherwise.",
"function_declaration": "def is_magic_... | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_magic_square(grid):\n # Convert grid list into 3x3 matrix\n matrix = [grid[i:i+3] for i in range(0, 9, 3)]\n \n # Sum of the first row to set th... | trial_gpt4o_8 | {
"original_instruction": "A game company is developing a new feature that involves magical squares. You are asked to determine whether a grid is a magic square.\n\nA magic square is a grid of numbers where the sum of every row, column, and both main diagonals are equal.\n\nGiven a 3x3 grid, determine if it is a magi... | 0.548942 | Taco_76082 | C | [
"is_magic_square",
"determine_magic_square"
] | 2 | [
[
"determine_magic_square",
"is_magic_square"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2a1715740a4176a9a3c8f4ca9e3beb51d34be99e | 554b3e2ad2dd12ae8e9187a459eda8a01a096b50 | |||
v1.0 | complete | Taco | Taco_76157_C | from typing import List, Tuple
def find_max_word_length(grid_dimensions: Tuple[int, int], grid: List[str], words: List[str]) -> int:
""" Given a rectangular grid of characters and a list of words, identify the maximum
length of any word in the list that can be found in the grid. A word can be constructed
f... | def exist(board, word):
rows, cols = len(board), len(board[0])
def dfs(r, c, i):
if i == len(word):
return True
if (r < 0 or r >= rows or c < 0 or c >= cols or board[r][c] != word[i]):
return False
temp = board[r][c]
board[r][c] = '#'
fou... | from solution import find_max_word_length
def test_example_case():
grid_dimensions = (4, 4)
grid = [
"abcd",
"efgh",
"ijkl",
"mnop"
]
words = ["abc", "fij", "ghk", "mnop", "abcdef"]
assert find_max_word_length(grid_dimensions, grid, words) == 4
def test_single_cell_... | [
{
"docstring": null,
"function_declaration": "def exist(board, word):",
"function_name": "exist",
"parameter_list": "(board, word)"
},
{
"docstring": null,
"function_declaration": "def max_word_length_in_grid(grid, words):",
"function_name": "max_word_length_in_grid",
"parameter_... | [
0,
0,
0,
1,
1
] | 2 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_max_word_length(grid, words):\n def dfs(x, y, word, index, visited):\n if index == len(word): \n return True\n \n if x ... | trial_gpt4o_4 | {
"original_instruction": "Given a rectangular grid of characters and a list of words, your task is to identify the maximum length of any word in the list that can be found in the grid. A word can be constructed from characters of sequentially adjacent cells, where \"adjacent\" cells are those horizontally, verticall... | 0.677302 | Taco_76157 | C | [
"exist",
"max_word_length_in_grid",
"find_max_word_length"
] | 3 | [
[
"find_max_word_length",
"max_word_length_in_grid"
],
[
"max_word_length_in_grid",
"exist"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 29af261cda06f7646e24bcaf73063d6d2881b29d | 69c3b1f367a966e56caf932173ddbcbb8c789e28 | |||
v1.0 | complete | Taco | Taco_76144_C | def is_pangram(s):
"""
Check if the string s is a pangram.
A pangram is a sentence that contains every letter of the English alphabet at least once.
"""
pass
def check_pangrams(test_cases):
"""
For each test case, determine if the provided string is a pangram.
Return results as a list o... | def is_pangram(s):
"""
Check if the string s is a pangram.
A pangram is a sentence that contains every letter of the English alphabet at least once.
"""
alphabet_set = set("abcdefghijklmnopqrstuvwxyz")
return alphabet_set.issubset(set(s.lower()))
def check_pangrams(test_cases):
"""
For ... | from solution import check_pangrams, is_pangram
def test_is_pangram():
assert is_pangram("The quick brown fox jumps over the lazy dog") == True
assert is_pangram("Hello World") == False
assert is_pangram("Pack my box with five dozen liquor jugs") == True
assert is_pangram("Sphinx of black quartz, judge... | [
{
"docstring": "Check if the string s is a pangram.\nA pangram is a sentence that contains every letter of the English alphabet at least once.",
"function_declaration": "def is_pangram(s):",
"function_name": "is_pangram",
"parameter_list": "(s)"
},
{
"docstring": "For each test case, determi... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_pangram(string):\n \"\"\"\n Returns \"YES\" if the string is a pangram, otherwise \"NO\".\n \"\"\"\n alphabet = set('abcdefghijklmnopqrstuvwxyz'... | trial_gpt4o_2 | {
"original_instruction": "Given a string, determine if it is a panagram. A panagram is a sentence containing every letter in the English Alphabet at least once.\n\nINPUT\nFirst line contains number of test cases T. Each test case contains a single string S.\n\nOUTPUT\nFor each test case, print \"YES\" if the string ... | 0.611355 | Taco_76144 | C | [
"is_pangram",
"check_pangrams",
"process_input_output"
] | 3 | [
[
"check_pangrams",
"is_pangram"
],
[
"process_input_output",
"check_pangrams"
]
] | 2 | [
"process_input_output"
] | false | [] | false | pytest | true | [] | true | 0ab98ac42574e4a7736a972b54e682ed73f9ce07 | 0bb219753a0cf7e68febcd15062a334e352e5a5c | |||
v1.0 | complete | Taco | Taco_76158_C | class TreeNode:
def __init__(self, value):
self.value = value
self.children = []
def build_tree(nodes, edges):
"""Builds a tree from a list of nodes and edges
"""
node_dict = {i+1: TreeNode(i+1) for i in range(nodes)}
for u, v in edges:
node_dict[u].children.append(node_dict... | class TreeNode:
def __init__(self, value):
self.value = value
self.children = []
def build_tree(nodes, edges):
node_dict = {i+1: TreeNode(i+1) for i in range(nodes)}
for u, v in edges:
node_dict[u].children.append(node_dict[v])
node_dict[v].children.append(node_dict[u])
... | from solution import parse_input, build_tree, tree_diameter
def test_sample_input():
input_str = "2\n5\n1 2 3 4 5\n1 2\n1 3\n3 4\n3 5\n3\n1 2 3\n1 2\n1 3"
expected_output = [3, 2]
assert parse_input(input_str) == expected_output
def test_single_tree():
input_str = "1\n4\n1 2 3 4\n1 2\n2 3\n3 4"
ex... | [] | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\n\ndef diameter_of_tree(n, edges):\n if not edges:\n return 0\n\n def bfs(start):\n visited = [-1] *... | trial_gpt4o_1 | {
"original_instruction": "Emma loves to work with binary trees. Given a binary tree, she wants to find the longest path between any two nodes in the tree. The path may or may not pass through the root node. \n\nShe describes this as finding the diameter of the binary tree, which is the number of edges in the longest... | 0.63847 | Taco_76158 | C | [
"build_tree",
"diameter_helper",
"tree_diameter",
"parse_input",
"handle_input"
] | 5 | [
[
"handle_input",
"parse_input"
],
[
"parse_input",
"build_tree"
],
[
"parse_input",
"tree_diameter"
],
[
"tree_diameter",
"diameter_helper"
]
] | 4 | [
"parse_input",
"handle_input"
] | false | [
"TreeNode"
] | true | pytest | true | [] | true | cc5f3987032ef064251773fc000baee88f259369 | 0ca451a5d776949b37df840f8a426eab86ab18e8 | |||
v1.0 | complete | Taco | Taco_76320_C | def digit_sum(n):
""" Calculate the digit sum of a given number.
"""
return sum(int(d) for d in str(n))
def digit_sum_pairs(numbers):
"""
Find all unique pairs in the list whose digit sums are equal.
Each integer in the list must be used at most once for pairing, and a number cannot be paired... | def digit_sum(n):
return sum(int(d) for d in str(n))
def digit_sum_pairs(numbers):
digit_sum_map = {}
for number in numbers:
ds = digit_sum(number)
if ds in digit_sum_map:
digit_sum_map[ds].append(number)
else:
digit_sum_map[ds] = [number]
pairs_count = ... | import pytest
from solution import count_digit_sum_pairs, digit_sum_pairs
def test_example_case():
input_data = "6\n34 12 52 41 71 23"
assert count_digit_sum_pairs(input_data) == 2
def test_no_pairs():
input_data = "5\n12 23 34 45 56"
assert count_digit_sum_pairs(input_data) == 0
def test_multiple_pa... | [
{
"docstring": null,
"function_declaration": "def digit_sum(n):",
"function_name": "digit_sum",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def digit_sum_pairs(numbers):",
"function_name": "digit_sum_pairs",
"parameter_list": "(numbers)"
},
{
... | [
0,
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def digit_sum(n):\n \"\"\"Calculate the digit sum of a number.\"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef digit_sum_pairs(n, numbers):\n \"... | trial_gpt4o_5 | {
"original_instruction": "-----\nDIGIT SUM PAIRS\n-----\n\nIn a sequence of positive integers, the digit sum of a number is defined as the sum of its digits. For instance, the digit sum of 123 is 1+2+3=6.\n\nGiven a list of integers, your task is to find all unique pairs (a, b) in the list such that the digit sum of... | 0.701369 | Taco_76320 | C | [
"digit_sum",
"digit_sum_pairs",
"count_digit_sum_pairs"
] | 3 | [
[
"count_digit_sum_pairs",
"digit_sum_pairs"
],
[
"digit_sum_pairs",
"digit_sum"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 09cfed2223d8492b1dc546a35c068ce8fcb309e2 | 55290ac8045f10ff14a1091dab7cd50dc6bce4cc | |||
v1.0 | complete | Taco | Taco_76521_C | MOD = 10**9 + 7
def count_matches(n: int) -> int:
"""Determine how many different ways the company can arrange the matches.
Args:
n (int): The number of employees.
Returns:
int: The number of different ways to arrange the matches, modulo 10^9 + 7.
Example:
>>> count_match... | MOD = 10**9 + 7
def factorial_mod(n, mod=MOD):
if n <= 1:
return 1
result = 1
for i in range(2, n + 1):
result = (result * i) % mod
return result
def count_matches(n):
if n % 2 != 0:
return 0
half_n = n // 2
factorial = factorial_mod(n)
denominator = (factorial_... | from solution import count_matches
def test_even_number_of_employees():
assert count_matches(4) == 3
assert count_matches(6) == 15
def test_odd_number_of_employees():
assert count_matches(1) == 0
assert count_matches(3) == 0
assert count_matches(5) == 0
def test_large_even_number_of_employees():
... | [
{
"docstring": null,
"function_declaration": "def factorial_mod(n, mod=MOD):",
"function_name": "factorial_mod",
"parameter_list": "(n, mod=MOD)"
},
{
"docstring": null,
"function_declaration": "def count_matches(n):",
"function_name": "count_matches",
"parameter_list": "(n)"
}... | [
0,
0,
0,
0,
0,
0,
1,
0,
1,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "MOD = 10**9 + 7\n\ndef num_ways_to_arrange_matches(n):\n if n % 2 != 0:\n return 0\n \n dp = [0] * (n + 1)\n dp[0] = 1\n \n for i in range... | trial_gpt4o_6 | {
"original_instruction": "A company is planning an inter-departmental table tennis tournament. The company has $n$ employees, and they want to arrange the tournament such that each employee participates in exactly one match. Each match will consist of exactly two employees.\n\nGiven that some employees might not be ... | 0.525111 | Taco_76521 | C | [
"factorial_mod",
"count_matches"
] | 2 | [
[
"count_matches",
"factorial_mod"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6da1f3ed74a41170d5a7fd2af0b492d8acbde219 | 8d9e09f5016037d474b1e15cd3c53eb6c5c3faf8 | |||
v1.0 | complete | Taco | Taco_76438_C | def is_balanced(sequence: str) -> str:
"""
Returns 'YES' if the sequence of parentheses, brackets, and braces is balanced and 'NO' otherwise.
>>> is_balanced("({[]})")
'YES'
>>> is_balanced("(]{[})")
'NO'
>>> is_balanced("[({})]")
'YES'
>>> is_balanced("[[")
'NO'
>>> is... | def is_balanced(sequence):
"""
Returns 'YES' if the sequence of parentheses, brackets, and braces is balanced and 'NO' otherwise.
"""
stack = []
matching_bracket = {')': '(', ']': '[', '}': '{'}
for char in sequence:
if char in matching_bracket.values():
stack.append(cha... | from solution import is_balanced, check_sequences
def test_is_balanced():
assert is_balanced("({[]})") == "YES"
assert is_balanced("(]{[})") == "NO"
assert is_balanced("[({})]") == "YES"
assert is_balanced("[[") == "NO"
assert is_balanced("{[()]}") == "YES"
assert is_balanced("(()") == "NO"
... | [
{
"docstring": "Returns 'YES' if the sequence of parentheses, brackets, and braces is balanced and 'NO' otherwise.",
"function_declaration": "def is_balanced(sequence):",
"function_name": "is_balanced",
"parameter_list": "(sequence)"
},
{
"docstring": "Returns the list of 'YES' or 'NO' for e... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_balanced(sequence):\n \"\"\"\n Returns \"YES\" if sequence is balanced, \"NO\" otherwise.\n A sequence is balanced if it contains equal numbers of ... | trial_gpt4o_1 | {
"original_instruction": "Given a sequence of parentheses, brackets, and braces, create a program that determines whether each sequence is balanced. A sequence is considered balanced if the following conditions are met:\n\n1. It contains equal numbers of opening and closing characters of each of type.\n2. Every clos... | 0.699107 | Taco_76438 | C | [
"is_balanced",
"check_sequences"
] | 2 | [
[
"check_sequences",
"is_balanced"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0d442b959b4a74371406df941615b0960b48cb98 | 98ff77e1f9aa98f5705e19863b35bf27306f2103 | |||
v1.0 | complete | Taco | Taco_76465_C | def is_special_number(num):
"""
Determines if a number is special. A number is special if it contains
the digits '5' or '9'.
>>> is_special_number(59) == True
>>> is_special_number(9) == True
>>> is_special_number(5) == True
>>> is_special_number(123) == False
>>> is_special_number(467) ... | def is_special_number(num):
"""
Determines if a number is special. A number is special if it contains
the digits '5' or '9'.
"""
num_str = str(num)
return '5' in num_str or '9' in num_str
def is_sum_special(arr):
"""
Determines if the sum of an array of integers is a special number.
... | def test_is_special_number():
assert is_special_number(59) == True
assert is_special_number(9) == True
assert is_special_number(5) == True
assert is_special_number(123) == False
assert is_special_number(467) == False
assert is_special_number(78) == False
def test_is_sum_special():
asser... | [
{
"docstring": "Determines if a number is special. A number is special if it contains\nthe digits '5' or '9'.",
"function_declaration": "def is_special_number(num):",
"function_name": "is_special_number",
"parameter_list": "(num)"
},
{
"docstring": "Determines if the sum of an array of integ... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_special_number(num):\n \"\"\"\n Returns whether the given number is special (contains digit 5 or 9).\n \"\"\"\n return '5' in str(num) or '9' in... | trial_gpt4o_1 | {
"original_instruction": "Egor loves programming challenges. One of his favorite tasks involves special numbers. A number is considered special if its decimal representation contains at least one of the special digits 5 or 9.\n\nFor example, numbers 59, 95, and 5 are special, while 123, 467, and 78 are not.\n\nRecen... | 0.663471 | Taco_76465 | C | [
"is_special_number",
"is_sum_special"
] | 2 | [
[
"is_sum_special",
"is_special_number"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | b8eb0c0b6d99e0597f0fc29bc96808b2401820bb | 41b0de6b747ed4eab381633918e5032aed4d9dbf | |||
v1.0 | complete | Taco | Taco_76599_C | from typing import List, Tuple
def minimizeMaxDistance(points: List[Tuple[int, int]]) -> float:
"""
Pair the given even number of points on a 2D plane such that the maximum distance
between any paired points is minimized. The distance between any two points
(x1, y1) and (x2, y2) is given by the Eucli... | import math
from typing import List, Tuple
def euclidean_distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float:
return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)
def minimizeMaxDistance(points: List[Tuple[int, int]]) -> float:
import itertools
n = len(points)
min_distance = float('i... | from solution import minimizeMaxDistance
def test_example():
points = [(0, 1), (1, 0), (2, 0), (0, 2), (2, 2), (1, 1)]
assert math.isclose(minimizeMaxDistance(points), 1.414213562, rel_tol=1e-9)
def test_two_points():
points = [(0, 0), (1, 1)]
assert math.isclose(minimizeMaxDistance(points), math.sqrt... | [
{
"docstring": null,
"function_declaration": "def euclidean_distance(p1, p2):",
"function_name": "euclidean_distance",
"parameter_list": "(p1, p2)"
},
{
"docstring": null,
"function_declaration": "def minimizeMaxDistance(points):",
"function_name": "minimizeMaxDistance",
"paramet... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import itertools\nimport math\nfrom typing import List, Tuple\n\ndef distance(p1: Tuple[int, int], p2: Tuple[int, int]) -> float:\n return math.sqrt((p1[0] - p2... | trial_gpt4o_1 | {
"original_instruction": "You are given an even number of points on a 2D plane. Pair these points such that the maximum distance between any paired points is minimized. \n\nThe distance between any two points $(x1, y1)$ and $(x2, y2)$ is given by the Euclidean distance formula: \n$$d = \\sqrt{(x2 - x1)^2 + (y2 - y1)... | 0.737893 | Taco_76599 | C | [
"euclidean_distance",
"minimizeMaxDistance"
] | 2 | [
[
"minimizeMaxDistance",
"euclidean_distance"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | d1b58ea89ac6465c39b14cc93e64500928e463d2 | 74ba265e76c9889fdcfb8dcb7c70a71bc120be19 | |||
v1.0 | complete | Taco | Taco_76668_C | def count_even_digits(n):
"""
Given an integer n, return the count of even digits in it.
>>> count_even_digits(123456) == 3
>>> count_even_digits(7890) == 2
>>> count_even_digits(13579) == 0
>>> count_even_digits(24680) == 5
>>> count_even_digits(0) == 1
>>> count_even_digits(2222) == 4
... | def count_even_digits(n):
"""
Given an integer n, return the count of even digits in it.
"""
even_digits = {'0', '2', '4', '6', '8'}
count = 0
for digit in str(n):
if digit in even_digits:
count += 1
return count
def process_numbers(numbers):
"""
Process a list o... | from solution import count_even_digits, process_numbers
def test_count_even_digits():
assert count_even_digits(123456) == 3
assert count_even_digits(7890) == 2
assert count_even_digits(13579) == 0
assert count_even_digits(24680) == 5
assert count_even_digits(0) == 1
assert count_even_digits(222... | [
{
"docstring": "Given an integer n, return the count of even digits in it.",
"function_declaration": "def count_even_digits(n):",
"function_name": "count_even_digits",
"parameter_list": "(n)"
},
{
"docstring": "Process a list of numbers and return a list of counts of even digits for each num... | [
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 count_even_digits(n):\n \"\"\"\n Returns the number of even digits in the integer n.\n \"\"\"\n even_digits = {'0', '2', '4', '6', '8'}\n count ... | trial_gpt4o_2 | {
"original_instruction": "You are given a list of integers. For each integer, determine how many digits are even.\n\n\nInput\nN: number of inputs N ≤ 100\nthen N lines with input X, where 0 ≤ X ≤ 10^9\n\n\nOutput\nThe output for the corresponding input X\n\n\nExample\n\nInput:\n4\n123456\n7890\n13579\n24680\n\nOutpu... | 0.794011 | Taco_76668 | C | [
"count_even_digits",
"process_numbers"
] | 2 | [
[
"process_numbers",
"count_even_digits"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 21ba52949c7c81d67c360a04f9c2feeceb8f02fe | 3b87bd8e0f2303c3c251126e92d8edd513487b99 | |||
v1.0 | complete | Taco | Taco_76716_C | def min_max_sum_dumplings(T: int, test_cases: List[Tuple[Tuple[int, int], List[int]]]) -> List[int]:
""" Determine the minimum possible maximum sum of deliciousness in any group after distributing the plates.
>>> min_max_sum_dumplings(2, [( (5, 2), [1, 2, 3, 4, 5] ), ( (4, 3), [10, 20, 30, 40] )])
[9, ... | def can_divide_into_k_groups(max_sum, N, K, A):
current_sum = 0
groups_formed = 1
for i in range(N):
if A[i] > max_sum:
return False
if current_sum + A[i] > max_sum:
groups_formed += 1
current_sum = A[i]
if groups_formed > K:
... | def test_min_max_sum_dumplings_single_case_1():
T = 1
test_cases = [
((5, 2), [1, 2, 3, 4, 5])
]
assert min_max_sum_dumplings(T, test_cases) == [9]
def test_min_max_sum_dumplings_single_case_2():
T = 1
test_cases = [
((4, 3), [10, 20, 30, 40])
]
assert min_max_sum_dumpli... | [
{
"docstring": null,
"function_declaration": "def can_divide_into_k_groups(max_sum, N, K, A):",
"function_name": "can_divide_into_k_groups",
"parameter_list": "(max_sum, N, K, A)"
},
{
"docstring": null,
"function_declaration": "def min_max_sum_dumplings(T, test_cases):",
"function_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 can_divide_into_k_groups(max_sum, N, K, A):\n current_sum = 0\n groups_formed = 1\n \n for i in range(N):\n if A[i] > max_sum:\n ... | trial_gpt4o_0 | {
"original_instruction": "Po has mastered the art of gathering the most delicious dumplings and now must distribute his dumplings among the Furious Five as evenly as possible. Given $N$ plates of dumplings with deliciousness values $A_1, A_2, \\ldots, A_N$, Po wants to distribute the dumplings into $K$ groups such t... | 0.65994 | Taco_76716 | C | [
"can_divide_into_k_groups",
"min_max_sum_dumplings"
] | 2 | [
[
"min_max_sum_dumplings",
"can_divide_into_k_groups"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 102748ef9b15119c717659bee7aa050337628127 | 446695bf1d7982ffcce74c77f7e59c451d74a9d2 | |||
v1.0 | complete | Taco | Taco_76745_C | from typing import List
def longest_prefix_suffix(s: str) -> int:
""" Finds the longest prefix which is also a suffix for a given string.
>>> longest_prefix_suffix("abxabx") 3
>>> longest_prefix_suffix("abcdef") 0
"""
def process_string(s: str) -> int:
""" Removes the longest prefix which is also... | def longest_prefix_suffix(s):
"""
Finds the longest prefix which is also a suffix.
"""
n = len(s)
lps = [0] * n
j = 0
i = 1
while i < n:
if s[i] == s[j]:
j += 1
lps[i] = j
i += 1
else:
if j != 0:
j = lps... | from solution import process_string, final_string_lengths
def test_process_string():
assert process_string("abxabx") == 0
assert process_string("abcdef") == 0
assert process_string("xyzxyzxyz") == 0
assert process_string("aaaa") == 0
assert process_string("ababab") == 0
def test_final_string_lengt... | [
{
"docstring": "Finds the longest prefix which is also a suffix.",
"function_declaration": "def longest_prefix_suffix(s):",
"function_name": "longest_prefix_suffix",
"parameter_list": "(s)"
},
{
"docstring": null,
"function_declaration": "def process_string(s):",
"function_name": "pr... | [
0,
0,
0,
0,
0,
1,
0,
1,
0
] | 2 | hard | 0.222 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_longest_prefix_suffix(s):\n n = len(s)\n lps = [0]*n\n length = 0 \n i = 1\n \n while i < n:\n if s[i] == s[length]:\n ... | trial_gpt4o_8 | {
"original_instruction": "Given a string of lowercase letters, you have to perform the following operation until you are left with no characters in the string:\n1. Find the length of the longest prefix which is also a suffix of the string (excluding the entire string itself).\n2. Remove this longest prefix from the ... | 0.83968 | Taco_76745 | C | [
"longest_prefix_suffix",
"process_string",
"final_string_lengths"
] | 3 | [
[
"final_string_lengths",
"process_string"
],
[
"process_string",
"longest_prefix_suffix"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 0fe07aacf4b5c5d4de63bf74f66c932d511d5f7c | 6a5eb4d232d1192d6173d3e47b772592d41ee299 | |||
v1.0 | complete | Taco | Taco_76662_C | def is_prime(n):
"""
Checks whether a number is prime.
"""
def is_palindrome(n):
"""
Checks whether a number is a palindrome.
"""
def prime_palindrome(x):
"""
Finds the smallest prime palindromic number greater than or equal to x.
>>> prime_palindrome(6)
7
>>> prime_palind... | def is_prime(n):
"""
Checks whether a number is prime.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
retur... | from solution import prime_palindrome
def test_prime_palindrome_example1():
assert prime_palindrome(6) == 7
def test_prime_palindrome_example2():
assert prime_palindrome(31) == 101
def test_prime_palindrome_minimum_input():
assert prime_palindrome(1) == 2
def test_prime_palindrome_small_palindrome_prime... | [
{
"docstring": "Checks whether a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Checks whether a number is a palindrome.",
"function_declaration": "def is_palindrome(n):",
"function_name": "is_pal... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Checks whether a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if ... | trial_gpt4o_0 | {
"original_instruction": "Manoj loves palindromes and prime numbers. He has a special interest in finding numbers that are both prime and palindromic. The prime palindromic numbers are the numbers that remain the same when their digits are reversed and are also prime. Manoj has given you a number x and wants to find... | 0.721489 | Taco_76662 | C | [
"is_prime",
"is_palindrome",
"prime_palindrome"
] | 3 | [
[
"prime_palindrome",
"is_palindrome"
],
[
"prime_palindrome",
"is_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 468cc6e07eea7417ccbb58d27cda43edc667ed8f | edf5689826469b7e4383f848020bc5f5f2961491 | |||
v1.0 | complete | Taco | Taco_76694_C | def dinner_party_solution(n: int, m: int, ingredients_list: List[str], dishes_list: List[str]) -> int:
""" Given the number of available ingredients and list of dishes with their required ingredients,
find the maximum number of dishes that can be made without reusing any ingredient.
>>> n = 5
>>> m... | def max_dishes(n, m, ingredients, dishes):
"""
Returns the maximum number of dishes that can be made given available ingredients and recipes.
"""
from itertools import combinations
ingredient_set = set(ingredients)
valid_dishes = []
# Filter dishes that have ingredients present in the ingr... | import pytest
from solution import dinner_party_solution
def test_example_case():
n = 5
m = 3
ingredients_list = [
"tomato",
"cheese",
"lettuce",
"bread",
"chicken"
]
dishes_list = [
"2 tomato cheese",
"2 bread cheese",
"3 chicken ... | [
{
"docstring": "Returns the maximum number of dishes that can be made given available ingredients and recipes.",
"function_declaration": "def max_dishes(n, m, ingredients, dishes):",
"function_name": "max_dishes",
"parameter_list": "(n, m, ingredients, dishes)"
},
{
"docstring": null,
"f... | [
0,
0,
0,
0,
0,
1,
0,
1,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_dishes(n, m, ingredients, dishes):\n from itertools import combinations\n\n # Function to check if all ingredients of a dish are available in remaini... | trial_gpt4o_7 | {
"original_instruction": "Sarah is organizing a dinner party and wants to create the most diverse menu possible with the ingredients available. She has a list of unique ingredients and a list of dishes, where each dish requires a specific set of ingredients. Each ingredient can only be used in one dish, and each dis... | 0.725249 | Taco_76694 | C | [
"max_dishes",
"dinner_party_solution"
] | 2 | [
[
"dinner_party_solution",
"max_dishes"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 31002cbc0cf90fc9a7ebc2f2e7c5c3a515e97f2b | 34ee7ae298c7829ea55a2d63dac4e8a902ecc049 | |||
v1.0 | complete | Taco | Taco_76725_C | def get_sorted_hashtags(posts: List[str]) -> List[str]:
"""
Given a list of social media posts, extract and return hashtags sorted by their popularity.
The popularity of a hashtag is determined by:
1. The number of posts it appears in (higher is better).
2. The total number of times it appears... | def extract_hashtags(posts):
"""
Extracts and ranks hashtags by their popularity according to the rules provided.
"""
from collections import defaultdict, Counter
hashtag_post_count = defaultdict(int)
hashtag_total_count = Counter()
for post in posts:
hashtags_in_post = set() # to... | from solution import get_sorted_hashtags
def test_single_post_single_hashtag():
posts = ["#test"]
assert get_sorted_hashtags(posts) == ["#test"]
def test_multiple_posts_same_hashtag():
posts = ["#test", "Another post with #test"]
assert get_sorted_hashtags(posts) == ["#test"]
def test_posts_with_diff... | [
{
"docstring": "Extracts and ranks hashtags by their popularity according to the rules provided.",
"function_declaration": "def extract_hashtags(posts):",
"function_name": "extract_hashtags",
"parameter_list": "(posts)"
},
{
"docstring": "Given a list of social media posts, extract and retur... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\nfrom collections import defaultdict\n\ndef extract_and_rank_hashtags(n, posts):\n hashtag_posts_count = defaultdict(set)\n hashtag_total_count = d... | trial_gpt4o_1 | {
"original_instruction": "You are given a list of social media posts, where each post contains a series of hashtags. A hashtag is defined as any contiguous word starting with the '#' symbol. Your task is to identify and rank the hashtags by their popularity. The popularity of a hashtag is determined by the number of... | 0.576768 | Taco_76725 | C | [
"extract_hashtags",
"get_sorted_hashtags"
] | 2 | [
[
"get_sorted_hashtags",
"extract_hashtags"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 36473e1567f33f01f36a288e55939e87b425e24f | 2d95db15788e8dc129efb8a30eacba43e281e333 | |||
v1.0 | complete | Taco | Taco_76763_C | def solution(input_str: str) -> int:
""" Given a list of streets, determine if the network of intersections is strongly connected.
If it is not, determine the minimum number of streets that need to be added to make it strongly connected.
Parameters:
input_str (str): A string representation of the i... | from collections import defaultdict, deque
def strongly_connected(n, m, streets):
# Create adjacency list for the graph and its transpose
graph = defaultdict(list)
reverse_graph = defaultdict(list)
for u, v in streets:
graph[u].append(v)
reverse_graph[v].append(u)
def bfs(... | from solution import solution
def test_example_1():
input_str = "4 4\n1 2\n2 3\n3 4\n4 1"
assert solution(input_str) == 0
def test_example_2():
input_str = "4 2\n1 2\n3 4"
assert solution(input_str) == 2
def test_single_node():
input_str = "1 0"
assert solution(input_str) == 0
def test_disco... | [
{
"docstring": null,
"function_declaration": "def strongly_connected(n, m, streets):",
"function_name": "strongly_connected",
"parameter_list": "(n, m, streets)"
},
{
"docstring": null,
"function_declaration": "def process_input(input_str):",
"function_name": "process_input",
"pa... | [
0,
0,
0,
1,
0
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict, deque\n\ndef is_strongly_connected(n, streets):\n def bfs(start, adj_list):\n visited = set()\n queue = deque... | trial_gpt4o_3 | {
"original_instruction": "A city has a system of one-way streets. Each street connects two different intersections in one direction. The city planners are concerned with ensuring that emergency vehicles can reach every intersection from a central station. To ensure this, they want to make sure that the street networ... | 0.634974 | Taco_76763 | C | [
"strongly_connected",
"process_input",
"solution"
] | 3 | [
[
"solution",
"process_input"
],
[
"solution",
"strongly_connected"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | a56bddd00de1e142258f8062be238b313e5b87e2 | eb6129fa1cc2731dfe1501dcca9d4d15a1eb3d8d | |||
v1.0 | complete | Taco | Taco_76485_C | from typing import List
def best_delivery_center(points: List[List[int]]) -> List[int]:
""" Given a list of points representing locations of homes in a 2D plane,
determine the best location for the delivery center in order to minimize
the maximum delivery distance to any home.
Args:
points (List[... | from math import sqrt
def euclidean_distance(p1, p2):
return sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)
def best_delivery_center(points):
best_point = None
min_max_distance = float('inf')
for candidate in points:
max_distance = 0
for point in points:
distance = eucl... | from solution import best_delivery_center
def test_best_delivery_center_example_1():
points = [[0,0], [4,0], [2,3], [3,3], [1,4]]
assert best_delivery_center(points) == [2,3]
def test_best_delivery_center_example_2():
points = [[1,1], [2,2], [3,3]]
assert best_delivery_center(points) == [2,2]
def tes... | [
{
"docstring": null,
"function_declaration": "def euclidean_distance(p1, p2):",
"function_name": "euclidean_distance",
"parameter_list": "(p1, p2)"
},
{
"docstring": null,
"function_declaration": "def best_delivery_center(points):",
"function_name": "best_delivery_center",
"param... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef euclidean_distance(p1, p2):\n \"\"\"\n Calculate Euclidean distance between two points p1 and p2.\n \"\"\"\n return math.sqrt((p1[0]... | trial_gpt4o_2 | {
"original_instruction": "You are given a list of points representing locations of homes in a 2D plane. A delivery center needs to be placed at one of these points to minimize the maximum distance any home has to travel to the delivery center. Afterwards, this delivery center will provide daily deliveries to each ho... | 0.62644 | Taco_76485 | C | [
"euclidean_distance",
"best_delivery_center"
] | 2 | [
[
"best_delivery_center",
"euclidean_distance"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0a6d69696d453cd2015e62724d29fd9d08aa362e | 3231e283b213c947ec243ad5a54beb2c16d5d447 | |||
v1.0 | complete | Taco | Taco_76784_C | def solve(R: int, C: int, grid: List[str]) -> str:
""" Determine the outcome of the game if both players play optimally.
>>> solve(3, 3, [
... ".#.",
... ".#.",
... "..#"
... ]) == "Draw"
>>> solve(2, 2, [
... "..",
... "#."
... ]) == "Alice"
"""
pass
... | from collections import deque
def bfs(grid, start, target):
"""
Performs breadth-first search to find the shortest path from start to target.
"""
R, C = len(grid), len(grid[0])
visited = [[False] * C for _ in range(R)]
queue = deque([(start[0], start[1], 0)]) # (row, col, distance)
visited... | def test_case_1():
R = 3
C = 3
grid = [
".#.",
".#.",
"..#"
]
assert solve(R, C, grid) == "Draw"
def test_case_2():
R = 2
C = 2
grid = [
"..",
"#."
]
assert solve(R, C, grid) == "Alice"
def test_case_3():
R = 2
C = 2
grid = [
... | [
{
"docstring": "Performs breadth-first search to find the shortest path from start to target.",
"function_declaration": "def bfs(grid, start, target):",
"function_name": "bfs",
"parameter_list": "(grid, start, target)"
},
{
"docstring": null,
"function_declaration": "def solve(R, C, grid... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef bfs(grid, start, target):\n R, C = len(grid), len(grid[0])\n queue = deque([start])\n visited = set([start])\n \n ... | trial_gpt4o_8 | {
"original_instruction": "You are given a rectangular grid with R rows and C columns. Each cell in the grid is either empty (denoted by '.') or contains an obstacle (denoted by '#').\n\nAlice and Bob are playing a game in which they take turns moving. Alice starts the game.\n\n- In her turn, Alice can move to any em... | 0.654375 | Taco_76784 | C | [
"bfs",
"solve",
"game_outcome"
] | 3 | [
[
"game_outcome",
"solve"
],
[
"solve",
"bfs"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 76ed72745105d125f35b2602184dd1b095380b4a | 5e8591afce9570dfdb5cdd22e05832ff749fe77c | |||
v1.0 | complete | Taco | Taco_76865_C | def list_primes_less_than(n: int) -> list:
""" Return the list of all prime numbers less than 'n'.
>>> list_primes_less_than(10)
[2, 3, 5, 7]
>>> list_primes_less_than(20)
[2, 3, 5, 7, 11, 13, 17, 19]
>>> list_primes_less_than(2)
[]
>>> list_primes_less_than(15)
[2, 3, 5, 7, 11, 13]
... | def is_prime(num):
"""
Returns True if num is a prime number, False otherwise.
"""
if num < 2:
return False
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
return False
return True
def list_primes_less_than(n):
"""
Returns a list of all prime numbers... | from solution import list_primes_less_than
def test_list_primes_less_than_10():
assert list_primes_less_than(10) == [2, 3, 5, 7]
def test_list_primes_less_than_20():
assert list_primes_less_than(20) == [2, 3, 5, 7, 11, 13, 17, 19]
def test_list_primes_less_than_2():
assert list_primes_less_than(2) == []
... | [
{
"docstring": "Returns True if num is a prime number, False otherwise.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns a list of all prime numbers less than n.",
"function_declaration": "def list_primes_le... | [
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, False otherwise.\n \"\"\"\n if num < 2:\n return False\n for i in range(... | trial_gpt4o_0 | {
"original_instruction": "# Task\nGiven an integer `n`, return the list of all prime numbers less than `n`.\n\n# Input/Output\n\n`[input]` integer `n`\n\nAn integer `n` such that 2 ≤ n ≤ 100.\n\n`[output]` array of integers\n\nThe array of all prime numbers less than `n`.\n\n# Example\n\nFor `n = 10`, the output sho... | 0.765212 | Taco_76865 | C | [
"is_prime",
"list_primes_less_than"
] | 2 | [
[
"list_primes_less_than",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 06e6bd63df9f533f2f1fc406b3177f3624472dfa | f563a2625e4083e0439ee90d9b59a0e220264232 | |||
v1.0 | complete | Taco | Taco_76780_C | from math import gcd
from functools import reduce
def find_gcd(a, b):
"""Return the GCD of a and b."""
pass
def find_lcm(a, b):
"""Return the LCM of a and b."""
pass
def alice_bob_game(n, arr):
""" Simulate the Alice and Bob game.
>>> alice_bob_game(3, [6, 9, 15]) 3
>>> alice_bob_game(4, ... | from math import gcd
from functools import reduce
def find_gcd(a, b):
"""Return the GCD of a and b."""
return gcd(a, b)
def find_lcm(a, b):
"""Return the LCM of a and b."""
return a * b // gcd(a, b)
def alice_bob_game(n, arr):
# Alice's turn -> find GCD of all elements
gcd_all = reduce(find_g... | from solution import find_gcd, find_lcm, alice_bob_game, process_game
def test_find_gcd():
assert find_gcd(6, 9) == 3
assert find_gcd(12, 15) == 3
assert find_gcd(17, 19) == 1
def test_find_lcm():
assert find_lcm(6, 9) == 18
assert find_lcm(12, 15) == 60
assert find_lcm(17, 19) == 323
def tes... | [
{
"docstring": "Return the GCD of a and b.",
"function_declaration": "def find_gcd(a, b):",
"function_name": "find_gcd",
"parameter_list": "(a, b)"
},
{
"docstring": "Return the LCM of a and b.",
"function_declaration": "def find_lcm(a, b):",
"function_name": "find_lcm",
"paramet... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from math import gcd\nfrom functools import reduce\n\ndef find_gcd(a, b):\n \"\"\"Return the GCD of a and b.\"\"\"\n return gcd(a, b)\n\ndef find_lcm(a, b):\... | trial_gpt4o_0 | {
"original_instruction": "Alice and Bob are playing a game using a list of positive integers. Alice starts by picking any two distinct integers, and replaces them with their greatest common divisor (GCD). Bob then takes his turn, picking any two distinct integers from the list and replacing them with their least com... | 0.633235 | Taco_76780 | C | [
"find_gcd",
"find_lcm",
"alice_bob_game",
"process_game",
"game_from_input"
] | 5 | [
[
"alice_bob_game",
"find_gcd"
],
[
"game_from_input",
"process_game"
],
[
"process_game",
"alice_bob_game"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | ff7a3a3957fe9a7c3818c74df7b8ce1e7a8c0f20 | 5880d3cf604429840e22674fa27e0f62e00d1b3b | |||
v1.0 | complete | Taco | Taco_76657_C | def build_tree(n, edges):
"""
Given the number of nodes and edges defining a binary tree, builds the tree and returns the root.
"""
pass
def tree_height_and_leaf_count(root):
"""
Computes the height of the binary tree and the number of leaf nodes.
"""
pass
def solve(test_cases):
""... | class TreeNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def build_tree(n, edges):
nodes = {i: TreeNode(i) for i in range(1, n+1)}
for u, v, c in edges:
if c == 0:
nodes[u].left = nodes[v]
else:
nodes[u]... | def test_tree_height_and_leaf_count():
input_string = "2\n3\n1 2 0\n1 3 1\n5\n1 2 0\n1 3 1\n2 4 0\n3 5 1\n"
test_cases = parse_input(input_string)
results = solve(test_cases)
assert results == [(1, 2), (2, 2)]
def test_single_node():
input_string = "1\n1\n"
test_cases = parse_input(input_string... | [] | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef build_tree(n, edges):\n ... | trial_gpt4o_0 | {
"original_instruction": "You are given a binary tree with N nodes, where each node has a unique value between 1 and N. Each node can have at most two children. The tree is provided to you in the form of parent-child relationships. Specifically, for each node, you are given its parent and whether it is a left or rig... | 0.654642 | Taco_76657 | C | [
"build_tree",
"tree_height_and_leaf_count",
"solve",
"parse_input"
] | 4 | [
[
"solve",
"build_tree"
],
[
"solve",
"tree_height_and_leaf_count"
]
] | 2 | [
"parse_input"
] | false | [
"TreeNode"
] | true | pytest | false | [] | true | 1729f44c61290cf0c1a4fb78a7b902ecbfd62227 | d0b1ee9574c358ac8c3f0abedde1a044ee765097 | |||
v1.0 | complete | Taco | Taco_76766_C | def largest_park_area(matrix):
""" Determine the largest possible area of the park that can be built on available lots.
The park should consist of only available lots ('A'), and must have a width and height of at least one cell.
Args:
matrix (List[List[str]]): The grid representing the current sta... | def largest_park_area(matrix):
if not matrix or not matrix[0]:
return 0
n, m = len(matrix), len(matrix[0])
max_area = 0
heights = [0] * m
for i in range(n):
for j in range(m):
if matrix[i][j] == 'A':
heights[j] += 1
else:
... | def test_largest_park_small_grid():
matrix = [
['A', 'B'],
['B', 'A']
]
assert largest_park_area(matrix) == 1
def test_largest_park_single_line():
matrix = [
['A', 'A', 'A', 'A'],
['A', 'B', 'A', 'A']
]
assert largest_park_area(matrix) == 4
def test_largest_park... | [
{
"docstring": null,
"function_declaration": "def largest_park_area(matrix):",
"function_name": "largest_park_area",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def max_histogram_area(heights):",
"function_name": "max_histogram_area",
"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 maximalRectangle(grid):\n if not grid:\n return 0\n \n n = len(grid)\n m = len(grid[0])\n max_area = 0\n heights = [0] * (m + 1)\n ... | trial_gpt4o_2 | {
"original_instruction": "You are a specialist in urban development working on a new project for the city of Logiville. The city is planned on an $n$-by-$m$ grid, where each cell represents a building lot. Some lots are already built-up and cannot be changed, while other lots are available for construction.\n\nYour ... | 0.651101 | Taco_76766 | C | [
"largest_park_area",
"max_histogram_area"
] | 2 | [
[
"largest_park_area",
"max_histogram_area"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | d45380ff7d2a1d4d3874bac9380b876e17de0c76 | 666cefd419135368cae11e437aa9387f41919e36 | |||
v1.0 | complete | Taco | Taco_76523_C | def max_subarray_sum(T: int, test_cases: List[Tuple[int, List[int]]]) -> List[int]:
""" Given the number of test cases and a list of test cases where each test case
contains the length of the array followed by the array of integers, this function
computes the maximum sum of any contiguous subarray.
I... | def max_subarray_sum(T, test_cases):
results = []
for case in test_cases:
N, array = case
max_current = max_global = array[0]
for i in range(1, N):
max_current = max(array[i], max_current + array[i])
if max_current > max_global:
max_g... | def test_max_subarray_sum():
# A list of test cases
test_cases = [
(2, [
9,
[-2, 1, -3, 4, -1, 2, 1, -5, 4],
5,
[-1, -2, -3, -4, -5]
]),
(1, [
3,
[1, 2, 3]
]),
(1, [
4,
[-1, -2... | [
{
"docstring": null,
"function_declaration": "def max_subarray_sum(T, test_cases):",
"function_name": "max_subarray_sum",
"parameter_list": "(T, test_cases)"
},
{
"docstring": null,
"function_declaration": "def process_input(T, arrays):",
"function_name": "process_input",
"parame... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_subarray_sum(arr):\n \"\"\"\n Calculate the maximum contiguous subarray sum for the given array.\n\n :param arr: List of integers\n :return: In... | trial_gpt4o_2 | {
"original_instruction": "You are participating in a programming competition where you have to solve several challenges. One of the challenges requires you to calculate the maximum contiguous subarray sum for a given sequence of integers. However, there's a twist – in this competition, you need to handle sequences t... | 0.755627 | Taco_76523 | C | [
"max_subarray_sum",
"process_input",
"solution"
] | 3 | [
[
"solution",
"max_subarray_sum"
],
[
"solution",
"process_input"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | false | [] | true | 111124d12cbc7bdbbf4a548ad8a86ba9c54c1123 | 3414db541249548d3693954632736269faaf61c0 | |||
v1.0 | complete | Taco | Taco_76877_C | def factorial(n):
"""
Returns the factorial of n.
"""
pass
def sum_of_digits(n):
"""
Returns the sum of digits of n.
"""
pass
def sum_of_digits_of_factorials(N):
"""
For an integer N, returns a list of sums of digits of the factorials of numbers from 1 to N.
>>> sum_of_digi... | def factorial(n):
"""
Returns the factorial of n.
"""
if n == 0 or n == 1:
return 1
result = 1
for i in range(2, n + 1):
result *= i
return result
def sum_of_digits(n):
"""
Returns the sum of digits of n.
"""
return sum(int(digit) for digit in str(n))
def su... | from solution import factorial, sum_of_digits, sum_of_digits_of_factorials
def test_factorial():
assert factorial(1) == 1
assert factorial(2) == 2
assert factorial(3) == 6
assert factorial(4) == 24
assert factorial(5) == 120
def test_sum_of_digits():
assert sum_of_digits(1) == 1
assert sum... | [
{
"docstring": "Returns the factorial of n.",
"function_declaration": "def factorial(n):",
"function_name": "factorial",
"parameter_list": "(n)"
},
{
"docstring": "Returns the sum of digits of n.",
"function_declaration": "def sum_of_digits(n):",
"function_name": "sum_of_digits",
... | [
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 factorial(n):\n \"\"\"\n Returns the factorial of n.\n \"\"\"\n if n == 0 or n == 1:\n return 1\n result = 1\n for i in range(2, n + 1... | trial_gpt4o_0 | {
"original_instruction": "Given an integer `N`, you are required to determine the factorial of numbers `1` to `N` and then find the sum of the digits of each factorial.\n\n-----Input-----\nN: an integer 1 <= N <= 100\n\n-----Output-----\nThe output will be `N` lines, each line containing the sum of digits of the fac... | 0.708531 | Taco_76877 | C | [
"factorial",
"sum_of_digits",
"sum_of_digits_of_factorials"
] | 3 | [
[
"sum_of_digits_of_factorials",
"factorial"
],
[
"sum_of_digits_of_factorials",
"sum_of_digits"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 5de758fdb82cc2b7f551adb1ef7c5c58bd0539be | b39432bfbfef45db219e5b763c76fe3e411440b3 | |||
v1.0 | complete | Taco | Taco_76956_C | def rearrange_to_rel_prime_sequence(n: int, sequence: List[int]) -> Union[List[int], int]:
""" Rearrange the sequence such that every adjacent pair of elements are relatively prime. If it is not possible, return -1.
>>> rearrange_to_rel_prime_sequence(4, [2, 3, 4, 5])
[2, 3, 4, 5]
>>> rearrange_to_rel_p... | from itertools import permutations
from math import gcd
def is_relatively_prime_sequence(seq):
for i in range(len(seq) - 1):
if gcd(seq[i], seq[i+1]) != 1:
return False
return True
def rearrange_to_rel_prime_sequence(n, sequence):
for perm in permutations(sequence):
if is_relat... | from solution import rearrange_to_rel_prime_sequence
def test_example_1():
assert rearrange_to_rel_prime_sequence(4, [2, 3, 4, 5]) == [2, 3, 4, 5]
def test_example_2():
assert rearrange_to_rel_prime_sequence(3, [2, 4, 6]) == -1
def test_single_element():
assert rearrange_to_rel_prime_sequence(1, [1]) == ... | [
{
"docstring": null,
"function_declaration": "def is_relatively_prime_sequence(seq):",
"function_name": "is_relatively_prime_sequence",
"parameter_list": "(seq)"
},
{
"docstring": null,
"function_declaration": "def rearrange_to_rel_prime_sequence(n, sequence):",
"function_name": "rea... | [
0,
0,
0,
0,
0,
0,
1,
1,
1
] | 3 | 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\nfrom math import gcd\n\ndef rearrange_relative_prime(n, sequence):\n \"\"\"\n Rearranges the given sequence such that eve... | trial_gpt4o_8 | {
"original_instruction": "You are given a sequence of integers. Your task is to rearrange the sequence such that every adjacent pair of elements are relatively prime. Two integers are relatively prime if their greatest common divisor (GCD) is 1.\n\nIf it is possible to rearrange the sequence to satisfy this conditio... | 0.553586 | Taco_76956 | C | [
"is_relatively_prime_sequence",
"rearrange_to_rel_prime_sequence"
] | 2 | [
[
"rearrange_to_rel_prime_sequence",
"is_relatively_prime_sequence"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 095ec0bdda0680c29be943c05a9a7d1de8d38254 | 852f8b204ee880254b5eb4def5043cf8f9e2ba50 | |||
v1.0 | complete | Taco | Taco_76918_C | def vault_status(n: int, states: List[str]) -> str:
"""
Determine if the vault can be unlocked using the given binary states.
The vault is unlocked if there is a valid path from "000" to "111" where each step
only changes one bit and all intermediate states are within the allowed states.
Arg... | def can_unlock_vault(n, states):
def is_bit_change_one(a, b):
"""
Check if there is exactly one bit difference between two binary strings a and b
"""
return sum(x != y for x, y in zip(a, b)) == 1
states_set = set(states)
# Check if both "000" and "111" are in the allowe... | from solution import vault_status
def test_vault_openable():
assert vault_status(8, ["000", "001", "010", "011", "100", "101", "110", "111"]) == "OPEN"
assert vault_status(3, ["000", "001", "011"]) == "LOCKED"
assert vault_status(5, ["000", "001", "011", "010", "111"]) == "OPEN"
assert vault_status(5, ... | [
{
"docstring": null,
"function_declaration": "def can_unlock_vault(n, states):",
"function_name": "can_unlock_vault",
"parameter_list": "(n, states)"
},
{
"docstring": null,
"function_declaration": "def vault_status(n, states):",
"function_name": "vault_status",
"parameter_list":... | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import deque\n\ndef can_unlock_vault(n, states):\n \"\"\"\n Determines if the vault can be unlocked given the states.\n\n :param n: Numbe... | trial_gpt4o_5 | {
"original_instruction": "You are tasked with designing a secure vault that is protected by a custom lock system. The vault can be opened only when given a specific sequence of binary numbers. Each binary number represents a specific lock state, and the sequence must follow a predetermined rule.\n\nThe vault will on... | 0.504776 | Taco_76918 | C | [
"can_unlock_vault",
"vault_status"
] | 2 | [
[
"vault_status",
"can_unlock_vault"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 521542200d747cf78cb1f97faf5e7be8e39cb9d6 | 11350e705df79d5f104e465cf4965951fc70ebbb | |||
v1.0 | complete | Taco | Taco_76367_C | from typing import List, Tuple
def max_histogram_area(histogram: List[int]) -> int:
"""
Given a list of non-negative integers representing the histogram's bar height where
the width of each bar is 1, find the area of the largest rectangle in the histogram.
>>> max_histogram_area([1, 2, 3, 4])
6
... | def max_histogram_area(histogram):
stack = []
max_area = 0
index = 0
while index < len(histogram):
if not stack or histogram[stack[-1]] <= histogram[index]:
stack.append(index)
index += 1
else:
top_of_stack = stack.pop()
area = (histogram[t... | def test_max_histogram_area():
assert max_histogram_area([1, 2, 3, 4]) == 6
assert max_histogram_area([6, 2, 5, 4, 5, 1, 6]) == 12
def test_max_rectangle_area():
grid1 = [
[1, 0, 1, 0, 0, 1],
[1, 0, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0],
[1, 0, 0, 1, 0, 1],
[1, 1, 1, 1, 1,... | [
{
"docstring": null,
"function_declaration": "def max_histogram_area(histogram):",
"function_name": "max_histogram_area",
"parameter_list": "(histogram)"
},
{
"docstring": null,
"function_declaration": "def max_rectangle_area(grid):",
"function_name": "max_rectangle_area",
"param... | [
1,
1
] | 2 | easy | 1 | {
"trial_gpt4o_0": null,
"trial_gpt4o_1": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl",
"solution_code": "def maximalRectangle(grid):\n if not grid:\n return 0\n \n H = len(grid)\n W = len(grid[0])\n max_area = 0\n \n ... | trial_gpt4o_2 | {
"original_instruction": "Tom's dog, Max, has a unique talent: he can detect shapes in a forest grid. After a walk through the grid, Max can sense if any rectangular shapes have been formed by overlapping test areas.\n\nEach cell of the grid can be either 0 (no tree) or 1 (tree). Max wants to detect the maximum size... | 0.650359 | Taco_76367 | C | [
"max_histogram_area",
"max_rectangle_area",
"process_input",
"parse_input",
"main"
] | 5 | [
[
"max_rectangle_area",
"max_histogram_area"
],
[
"process_input",
"max_rectangle_area"
]
] | 2 | [
"process_input",
"parse_input"
] | false | [] | false | pytest | false | [] | true | cc508d99ad227ed20177aeae5a0422c1a4f920a7 | 41799fc9344e398635eff6b467bfb21595c2d3f5 | |||
v1.0 | complete | Taco | Taco_77020_C | from typing import List
def can_form_equal_page_stacks(test_cases: List[List[int]]) -> List[str]:
"""Determine if comic books can be arranged in stacks with the same number of pages.
>>> can_form_equal_page_stacks([[1, 2, 3]]) ["NO"]
>>> can_form_equal_page_stacks([[3, 3]]) ["YES"]
>>> can_form_equal_p... | import math
from functools import reduce
def gcd(a, b):
while b:
a, b = b, a % b
return a
def find_gcd_of_list(arr):
return reduce(gcd, arr)
def can_form_equal_page_stacks(test_cases):
results = []
for pages in test_cases:
if len(pages) == 1:
results.append("YES")
... | from solution import can_form_equal_page_stacks
def test_single_book():
assert can_form_equal_page_stacks([[5]]) == ["YES"]
def test_all_same_pages():
assert can_form_equal_page_stacks([[3, 3]]) == ["YES"]
def test_no_common_gcd():
assert can_form_equal_page_stacks([[1, 2, 3]]) == ["NO"]
def test_common... | [
{
"docstring": null,
"function_declaration": "def gcd(a, b):",
"function_name": "gcd",
"parameter_list": "(a, b)"
},
{
"docstring": null,
"function_declaration": "def find_gcd_of_list(arr):",
"function_name": "find_gcd_of_list",
"parameter_list": "(arr)"
},
{
"docstring":... | [
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 math\nfrom functools import reduce\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef can_arrange_stacks(t, test_cases):\n res... | trial_gpt4o_3 | {
"original_instruction": "Sam loves collecting comic books and he has recently received a large shipment. Each comic book has a certain number of pages, and Sam wants to arrange them in stacks such that all stacks have exactly the same number of pages. He can choose any number of stacks, but each stack must contain ... | 0.509627 | Taco_77020 | C | [
"gcd",
"find_gcd_of_list",
"can_form_equal_page_stacks"
] | 3 | [
[
"can_form_equal_page_stacks",
"find_gcd_of_list"
],
[
"find_gcd_of_list",
"gcd"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | b34f7f8b41b8a58a308016ff730784ab4892a493 | 94a6af16901ad25b6c5e999109ba9b90c2fc10c6 | |||
v1.0 | complete | Taco | Taco_76996_C | import math
from typing import List
def is_prime(num: int) -> bool:
"""
Check if a number is prime.
>>> is_prime(2)
True
>>> is_prime(3)
True
>>> is_prime(4)
False
"""
pass
def primes_from(start: int, n: int) -> List[int]:
"""
Returns a list of 'n' prime numbers startin... | import math
def is_prime(num):
"""
Check if a number is prime.
"""
if num < 2:
return False
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
def primes_from(start, n):
"""
Returns a list of 'n' prime numbers starting from... | from solution import primes_from, is_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_primes_from_edge_case():
result = primes_from(2, 5)
expected = [2, 3, 5, 7, 11... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns a list of 'n' prime numbers starting from 'start'.",
"function_declaration": "def primes_from(start, n):",
"fu... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if ... | trial_gpt4o_1 | {
"original_instruction": "Create a function that returns a list of 'n' prime numbers starting from a given number 'start'.\n\n-----Constraints-----\n- `1 \\leq n \\leq 10^3`\n- `2 \\leq start \\leq 10^5`\n- Both `n` and `start` are integers.\n\n-----Input-----\nInput is given from Standard Input in the following for... | 0.769338 | Taco_76996 | C | [
"is_prime",
"primes_from"
] | 2 | [
[
"primes_from",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | af656fb7e5667eb68caf453729c08b36570e3ab0 | da875e410a317b2440edbec2f581d7b341bc8958 | |||
v1.0 | complete | Taco | Taco_77088_C | def number_of_distinct_prime_factors(N: int, arr: List[int]) -> int:
""" Find the number of distinct prime factors of the sum of all elements of the array.
>>> number_of_distinct_prime_factors(3, [2, 4, 7])
1
>>> number_of_distinct_prime_factors(1, [10])
2
""" | def distinct_prime_factors(arr):
from math import isqrt
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... | import pytest
from solution import number_of_distinct_prime_factors
def test_small_array():
assert number_of_distinct_prime_factors(3, [2, 4, 7]) == 1
def test_array_with_single_element():
assert number_of_distinct_prime_factors(1, [10]) == 2
def test_large_sum_with_multiple_factors():
assert number_of_d... | [
{
"docstring": null,
"function_declaration": "def distinct_prime_factors(arr):",
"function_name": "distinct_prime_factors",
"parameter_list": "(arr)"
},
{
"docstring": null,
"function_declaration": "def number_of_distinct_prime_factors(N, arr):",
"function_name": "number_of_distinct_... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef distinct_prime_factors_count(arr):\n \"\"\"\n Returns the number of distinct prime factors of the sum of all elements of the array.\n \... | trial_gpt4o_2 | {
"original_instruction": "You are given an integer array. You need to find the number of distinct prime factors of the sum of all elements of the array.\n\nInput:\nThe first line contains a single integer N, the number of elements in the array.\nThe second line contains N space-separated integers representing the el... | 0.743717 | Taco_77088 | C | [
"distinct_prime_factors",
"number_of_distinct_prime_factors"
] | 2 | [
[
"number_of_distinct_prime_factors",
"distinct_prime_factors"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 72e0eab4d29101704f9cc72089017ab4f570651e | 7af86488fe52887d184f67e95532894e92459547 | |||
v1.0 | complete | Taco | Taco_77024_C | def escape_check(input_data: str) -> str:
"""
Determine if all sheep can escape the wolves on the grid.
The function takes a string input representing the grid size, number of sheep, number of wolves, and their respective positions.
>>> escape_check("5 2 2\n2 2\n4 4\n1 1\n5 5")
'ESCAPED'
>>... | def can_sheep_escape(N, S, W, sheep_positions, wolf_positions):
def is_captured(sheep, wolves):
for wolf in wolves:
if sheep == wolf:
return True
return False
for sheep in sheep_positions:
if is_captured(sheep, wolf_positions):
return "CAUGHT"... | def test_escape_check_case1():
input_data = "5 2 2\n2 2\n4 4\n1 1\n5 5"
assert escape_check(input_data) == "ESCAPED"
def test_escape_check_case2():
input_data = "5 2 2\n2 2\n4 4\n2 2\n5 5"
assert escape_check(input_data) == "CAUGHT"
def test_escape_check_case3():
input_data = "2 1 1\n1 1\n2 2"
... | [
{
"docstring": null,
"function_declaration": "def can_sheep_escape(N, S, W, sheep_positions, wolf_positions):",
"function_name": "can_sheep_escape",
"parameter_list": "(N, S, W, sheep_positions, wolf_positions)"
},
{
"docstring": null,
"function_declaration": "def process_input(input_dat... | [
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_sheep_escape(grid_size, sheep_positions, wolf_positions):\n from collections import deque\n\n N = grid_size\n S = len(sheep_positions)\n W = le... | trial_gpt4o_1 | {
"original_instruction": "Problem:\n\nConsider a grid of size N x N. You are given the initial positions of S sheep and W wolves scattered across the grid. Sheep can move one step up, down, left, or right. Wolves can also move one step up, down, left, or right. However, a wolf catches a sheep if it moves to the same... | 0.522935 | Taco_77024 | C | [
"can_sheep_escape",
"process_input",
"escape_check"
] | 3 | [
[
"escape_check",
"can_sheep_escape"
],
[
"escape_check",
"process_input"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | false | [] | true | 79a11227e6dce67a1b793d3f22aeb2624692e4fe | c55d953a7a01d531e3f9e7fe1eef84ec0d9751a2 | |||
v1.0 | complete | Taco | Taco_77142_C | def find_smallest_subarray(n: int, x: int, arr: List[int]) -> int:
"""
Find the length of the smallest subarray with a sum greater than x.
If no such subarray exists, return -1.
>>> find_smallest_subarray(6, 51, [1, 4, 45, 6, 0, 19])
3
>>> find_smallest_subarray(5, 9, [1, 10, 5, 2, 7])
... | def smallest_subarray_length(arr, x):
n = len(arr)
# Initialize the variables
min_length = float('inf')
start = 0
current_sum = 0
for end in range(n):
current_sum += arr[end]
# Shrink the window as small as possible while the current_sum is greater than x
... | from solution import find_smallest_subarray
def test_example1():
assert find_smallest_subarray(6, 51, [1, 4, 45, 6, 0, 19]) == 3
def test_example2():
assert find_smallest_subarray(5, 9, [1, 10, 5, 2, 7]) == 1
def test_example3():
assert find_smallest_subarray(4, 100, [1, 2, 4, 5]) == -1
def test_small_a... | [
{
"docstring": null,
"function_declaration": "def smallest_subarray_length(arr, x):",
"function_name": "smallest_subarray_length",
"parameter_list": "(arr, x)"
},
{
"docstring": null,
"function_declaration": "def find_smallest_subarray(n, x, arr):",
"function_name": "find_smallest_su... | [
0,
0,
0,
0,
0,
1,
0,
0,
1,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def smallest_subarray_with_sum_greater_than_x(arr, x):\n n = len(arr)\n min_length = n + 1\n \n start = 0\n end = 0\n current_sum = 0\n \n ... | trial_gpt4o_8 | {
"original_instruction": "You are given an integer array `arr` and an integer `x`. You need to find and print the length of the smallest subarray with a sum greater than the given `x`. If no such subarray exists, print `-1`.\n\nA subarray is defined as a contiguous part of an array.\n\n**Input format:**\n\n- The fir... | 0.817363 | Taco_77142 | C | [
"smallest_subarray_length",
"find_smallest_subarray"
] | 2 | [
[
"find_smallest_subarray",
"smallest_subarray_length"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ebade53378806ed40c8f3666409d8d5270f67e55 | 5cef36e6ad8ddb793909d51152bf43fcc5406865 | |||
v1.0 | complete | Taco | Taco_76772_C | from typing import List, Tuple
def final_sequence(n: int, m: int, sequence: List[int], transformations: List[Tuple[int, int, int]]) -> List[int]:
"""Apply a series of transformation rules to an initial sequence of integers.
Args:
n (int): The number of elements in the sequence.
m (int): The number... | def apply_transformation(n, m, sequence, transformations):
for transformation in transformations:
l, r, k = transformation
for i in range(l-1, r):
sequence[i] += k
return sequence
def final_sequence(n, m, sequence, transformations):
return apply_transformation(n, m, sequence, tr... | from solution import final_sequence
def test_final_sequence_1():
n = 5
m = 3
sequence = [1, 2, 3, 4, 5]
transformations = [(1, 3, 2), (2, 4, -1), (3, 5, 3)]
assert final_sequence(n, m, sequence, transformations) == [3, 3, 7, 6, 8]
def test_final_sequence_2():
n = 4
m = 2
sequence = [10... | [
{
"docstring": null,
"function_declaration": "def apply_transformation(n, m, sequence, transformations):",
"function_name": "apply_transformation",
"parameter_list": "(n, m, sequence, transformations)"
},
{
"docstring": null,
"function_declaration": "def final_sequence(n, m, sequence, tr... | [
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 apply_transformations(n, m, sequence, rules):\n # Apply each rule to the sequence\n for rule in rules:\n l, r, k = rule\n for i in range(l-... | trial_gpt4o_2 | {
"original_instruction": "Little Zooey is fascinated by patterns and sequences. She loves creating new sequences from existing ones by applying specific rules repeatedly. Here's a sequence transformation challenge she has devised.\n\nYou are given a sequence of `n` integers `a1, a2, ..., an` and `m` transformation r... | 0.668524 | Taco_76772 | C | [
"apply_transformation",
"final_sequence"
] | 2 | [
[
"final_sequence",
"apply_transformation"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 64c211a76296705b632209ae96b8cba72fb35aed | 7d269631a23586770391f7b7d5b28ba205f7a817 | |||
v1.0 | complete | Taco | Taco_77040_C | import math
import sys
def calculate_distance(point1, point2):
"""
Calculate the Euclidean distance between two points in 2D space.
:param point1: Tuple representing the first point (x1, y1)
:param point2: Tuple representing the second point (x2, y2)
:return: Euclidean distance between the two poin... | import math
import sys
def calculate_distance(point1, point2):
return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2)
def closest_pair(points):
def closest_pair_rec(px, py):
if len(px) <= 3:
return min((calculate_distance(px[i], px[j]), (px[i], px[j]))
... | def test_calculate_distance():
assert math.isclose(calculate_distance((0, 0), (3, 4)), 5.0)
def test_closest_pair_case1():
points = [(0, 0), (0, 2), (2, 0), (2, 2)]
assert math.isclose(closest_pair(points), 2.0, rel_tol=1e-4)
def test_closest_pair_case2():
points = [(-1, -1), (-4, 3), (-2, 2)]
ass... | [
{
"docstring": null,
"function_declaration": "def calculate_distance(point1, point2):",
"function_name": "calculate_distance",
"parameter_list": "(point1, point2)"
},
{
"docstring": null,
"function_declaration": "def closest_pair(points):",
"function_name": "closest_pair",
"param... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef closest_pair_of_points(points):\n \"\"\"\n Returns the distance between the closest pair of points to four decimal places.\n points: A ... | trial_gpt4o_2 | {
"original_instruction": "Write a program that finds the closest pair of points in a given set of points in a 2D plane.\n\nThe program should print the distance between the closest pair of points, rounded to four decimal places, for each set of points. The input consists of several sets of points, with each set havi... | 0.692916 | Taco_77040 | C | [
"calculate_distance",
"closest_pair",
"process_input"
] | 3 | [
[
"closest_pair",
"calculate_distance"
],
[
"process_input",
"closest_pair"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | false | [] | true | e82285554c79492eabc6211eaf0795ea1d3b2074 | 372a4e8d5eaac0469780fef0806d480bfce3e4d8 | |||
v1.0 | complete | Taco | Taco_77129_C | from typing import List, Tuple
def employees_under_manager(n: int, q: int, employee_manager_pairs: List[Tuple[int, int]], queries: List[int]) -> List[int]:
""" Determine the number of employees under each manager.
Given a number of employees `n` and number of queries `q`, along with a list of
`employ... | from collections import defaultdict, deque
def build_hierarchy(employee_manager_pairs, n):
hierarchy = defaultdict(list)
for emp, mngr in employee_manager_pairs:
hierarchy[mngr].append(emp)
return hierarchy
def count_subordinates(hierarchy, query):
visited = set()
queue = deque()
queue... | from solution import employees_under_manager
def test_single_employee_no_subordinates():
n, q = 1, 1
employee_manager_pairs = []
queries = [1]
assert employees_under_manager(n, q, employee_manager_pairs, queries) == [0]
def test_multiple_employees_simple_hierarchy():
n, q = 3, 1
employee_manag... | [
{
"docstring": null,
"function_declaration": "def build_hierarchy(employee_manager_pairs, n):",
"function_name": "build_hierarchy",
"parameter_list": "(employee_manager_pairs, n)"
},
{
"docstring": null,
"function_declaration": "def count_subordinates(hierarchy, query):",
"function_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": "from collections import defaultdict, deque\n\ndef build_hierarchy(employee_manager_pairs, n):\n hierarchy = defaultdict(list)\n for emp, mngr in employee_man... | trial_gpt4o_0 | {
"original_instruction": "In a company, employees have a hierarchical structure. Each employee has a unique ID and is managed by exactly one other employee, except for the CEO who does not have a manager. You are given a list of employee-manager pairs and need to determine the number of employees under each manager.... | 0.658001 | Taco_77129 | C | [
"build_hierarchy",
"count_subordinates",
"employees_under_manager"
] | 3 | [
[
"employees_under_manager",
"build_hierarchy"
],
[
"employees_under_manager",
"count_subordinates"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 688401aa8cc766995e1196163789c156e0f45a72 | 1280bf3bb78c2c1d41c3877b4be210e2226ca8fa | |||
v1.0 | complete | Taco | Taco_77222_C | def is_prime(n: int) -> bool:
"""
Helper function to check if a number is prime.
Args:
n (int): Number to check if it is prime.
Returns:
bool: True if n is prime, False otherwise.
>>> is_prime(2)
True
>>> is_prime(4)
False
>>> is_prime(17)
True
>>> is_prime(1)
F... | def is_prime(n):
"""
Helper function to check if a number is prime.
"""
if n <= 1:
return False
if n == 2:
return True
if n % 2 == 0:
return False
p = 3
while p * p <= n:
if n % p == 0:
return False
p += 2
return True
def absolute_... | from solution import is_prime, absolute_diff_prime_nonprime, process_input
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(20) == False
assert is_prime(1) == False
def test_absolute_diff_prime_no... | [
{
"docstring": "Helper function to check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Function to calculate the absolute difference between the sum of prime numbers \nand non-prime numbers in the a... | [
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return Tru... | trial_gpt4o_5 | {
"original_instruction": "Given an array of integers, you need to find the absolute difference between the sum of all prime numbers present in the array and the sum of all non-prime numbers present in the array. If the array contains no prime numbers or no non-prime numbers, print -1.\n\nA prime number is defined as... | 0.713773 | Taco_77222 | C | [
"is_prime",
"absolute_diff_prime_nonprime",
"process_input",
"main"
] | 4 | [
[
"absolute_diff_prime_nonprime",
"is_prime"
],
[
"process_input",
"absolute_diff_prime_nonprime"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | true | [] | true | 001cf23896858497439321e0645ae7adb1e2bdcb | eb66feea6cc7127033f6a6611b1335c6274f0a5e | |||
v1.0 | complete | Taco | Taco_77402_C | import heapq
def dijkstra(n, edges, start, end):
""" Use Dijkstra's algorithm to find the minimal travel cost between two cities in a graph.
Args:
n (int): Number of cities.
edges (List[Tuple[int, int, int]]): List of direct routes with costs.
start (int): The start city.
end (int): The destina... | import heapq
def dijkstra(n, edges, start, end):
graph = {i: [] for i in range(1, n + 1)}
for u, v, w in edges:
graph[u].append((v, w))
graph[v].append((u, w))
pq = [(0, start)]
dist = {i: float('inf') for i in range(1, n + 1)}
dist[start] = 0
while pq:
current... | from solution import minimal_travel_cost
def test_case_1():
n = 5
m = 6
routes = [(1, 2, 3), (1, 3, 10), (2, 3, 1), (2, 4, 2), (3, 4, 4), (4, 5, 3)]
assert minimal_travel_cost(n, m, routes, 1, 5) == 8
def test_case_2():
n = 3
m = 3
routes = [(1, 2, 1), (2, 3, 2), (1, 3, 4)]
assert mini... | [
{
"docstring": null,
"function_declaration": "def dijkstra(n, edges, start, end):",
"function_name": "dijkstra",
"parameter_list": "(n, edges, start, end)"
},
{
"docstring": null,
"function_declaration": "def minimal_travel_cost(n, m, routes, start, end):",
"function_name": "minimal_... | [
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\n\ndef dijkstra(n, edges, start, end):\n graph = {i: [] for i in range(1, n + 1)}\n for u, v, w in edges:\n graph[u].append((v, w))\n ... | trial_gpt4o_0 | {
"original_instruction": "Problem\n\nA traveling salesman is planning his routes between various cities. To optimize his travels, he wants to determine the minimal travel cost between any two cities in his itinerary.\n\nThe cities and the travel costs between them can be represented using a graph where each node rep... | 0.712713 | Taco_77402 | C | [
"dijkstra",
"minimal_travel_cost"
] | 2 | [
[
"minimal_travel_cost",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6085049ed6a1d0b10e512e8e527abdf348661f61 | 3e784d864b54fbce5b3aa7fd25209d85414516d4 | |||
v1.0 | complete | Taco | Taco_77152_C | def find_kth_rank_score(test_cases):
"""Find the score of the participant who ranks k-th for each test case.
Args:
test_cases: List of tuples, where each tuple contains
n (int): number of participants
k (int): rank to find
scores (List[int]): scores of participants
... | def find_kth_rank_score(test_cases):
results = []
for case in test_cases:
n, k, scores = case
scores.sort(reverse=True)
results.append(scores[k - 1])
return results
def parse_input(input_string):
lines = input_string.strip().split('\n')
T = int(lines[0])
test_cases = []
... | def test_find_kth_rank_score():
input_string = "2\n5 2\n50 30 40 10 20\n4 1\n100 90 80 70\n"
expected_output = [40, 100]
assert process_input_and_find_scores(input_string) == expected_output
def test_with_minimum_values():
input_string = "1\n1 1\n10\n"
expected_output = [10]
assert process_inpu... | [
{
"docstring": null,
"function_declaration": "def find_kth_rank_score(test_cases):",
"function_name": "find_kth_rank_score",
"parameter_list": "(test_cases)"
},
{
"docstring": null,
"function_declaration": "def parse_input(input_string):",
"function_name": "parse_input",
"paramet... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_kth_rank_score(test_cases):\n results = []\n for case in test_cases:\n n, k, scores = case\n scores.sort(reverse=True)\n result... | trial_gpt4o_0 | {
"original_instruction": "A company is organizing an online coding competition where n participants will compete. Each participant is assigned a unique score based on their performance in the competition. The company wants to find the score of the participant who ranks k-th in the competition.\n\nGiven a list of sco... | 0.647437 | Taco_77152 | C | [
"find_kth_rank_score",
"parse_input",
"process_input_and_find_scores"
] | 3 | [
[
"process_input_and_find_scores",
"find_kth_rank_score"
],
[
"process_input_and_find_scores",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | e1dffe52169368b0f006e06667bd65190cf70b60 | fbb65c465fc860515f095a861167b830d7ff7d86 | |||
v1.0 | complete | Taco | Taco_77448_C | def main(input_data: str) -> List[int]:
""" Construct a Minimum Spanning Tree (MST) for the network and determine its total edge distance.
>>> main("2\n4 5\n1 2 1\n1 3 4\n2 3 2\n2 4 3\n3 4 5\n3 3\n1 2 1\n2 3 3\n1 3 2")
[6, 3]
>>> main("1\n2 1\n1 2 4")
[4]
>>> main("1\n3 3\n1 2 1\n1 3 2\n2 3 4")
... | import heapq
def find(parent, i):
if parent[i] == i:
return i
else:
return find(parent, parent[i])
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if rank[root_x] < rank[root_y]:
parent[root_x] = root_y
elif rank[root_x] > rank[root... | def test_minimum_spanning_tree():
input_data = "2\n4 5\n1 2 1\n1 3 4\n2 3 2\n2 4 3\n3 4 5\n3 3\n1 2 1\n2 3 3\n1 3 2"
expected_output = [6, 3]
assert main(input_data) == expected_output
def test_single_edge():
input_data = "1\n2 1\n1 2 4"
expected_output = [4]
assert main(input_data) == expected... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = find(parent, x)\n... | trial_gpt4o_1 | {
"original_instruction": "The Galactic Empire has recently deployed a new communication network across its planets. Each planet is represented as a node in a network graph, and each communication channel between two planets is an undirected edge with a certain distance. However, due to budget constraints, the Empire... | 0.640963 | Taco_77448 | C | [
"find",
"union",
"kruskal",
"solve_cases",
"main"
] | 5 | [
[
"kruskal",
"find"
],
[
"kruskal",
"union"
],
[
"solve_cases",
"kruskal"
],
[
"union",
"find"
]
] | 4 | [
"solve_cases"
] | false | [] | false | pytest | false | [] | true | 0faaa01a805a6a2f51a7b2dfe2e34c67a111454e | bd3b747100662520184be55f53712f698f310519 | |||
v1.0 | complete | Taco | Taco_77311_C | def sum_of_all_paths(T: int, testcases: List[Tuple[int, List[Tuple[int, int, str]]]]) -> List[int]:
""" Calculates the sum of all unique root-to-node paths for each test case.
>>> sum_of_all_paths(1, [
... (5, [(1, 2, 'L'), (1, 3, 'R'), (2, 4, 'L'), (2, 5, 'R')])
... ]) == [262]
"""
from solution i... | class TreeNode:
def __init__(self, value):
self.val = value
self.left = None
self.right = None
def build_tree(edges):
nodes = {}
for parent, child, direction in edges:
if parent not in nodes:
nodes[parent] = TreeNode(parent)
if child not in nodes:
... | from solution import sum_of_all_paths
def test_single_path():
T = 1
testcases = [
(3, [
(1, 2, 'L'),
(2, 3, 'L')
])
]
result = sum_of_all_paths(T, testcases)
assert result == [123]
def test_multiple_paths():
T = 1
testcases = [
(5, [
... | [] | [
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": "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_3 | {
"original_instruction": "Anna is a software engineer who loves working with binary trees. She has a deep interest in finding unique paths from the root to each node and is curious to know more about them. Given a binary tree, she wants to find the sum of all root-to-node paths. Can you help her?\n\n-----Input:-----... | 0.584535 | Taco_77311 | C | [
"build_tree",
"sum_root_to_node_paths",
"sum_of_all_paths"
] | 3 | [
[
"sum_of_all_paths",
"build_tree"
],
[
"sum_of_all_paths",
"sum_root_to_node_paths"
]
] | 2 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | 5a03e79ef819449baceb88b08fe2966a51df5dad | 2df8c36873397c6b2b571cfaf4512e3cf60aef70 | |||
v1.0 | complete | Taco | Taco_77454_C | def solve_knapsack_problem(n: int, W: int, items: List[Tuple[int, int]]) -> int:
"""
Solves the 0/1 knapsack problem.
Parameters:
n (int): Number of items
W (int): Maximum capacity of the backpack
items (list of tuples): List of items where each item is represented as (weight, value)
... | def knapsack(n, W, items):
"""
Solves the 0/1 knapsack problem.
Parameters:
n (int): Number of items
W (int): Maximum capacity of the backpack
items (list of tuples): List of items where each item is represented as (weight, value)
Returns:
int: The maximum value that can be pa... | from solution import solve_knapsack_problem
def test_example_1():
n = 4
W = 7
items = [(2, 10), (3, 20), (4, 30), (5, 40)]
assert solve_knapsack_problem(n, W, items) == 50
def test_example_2():
n = 3
W = 50
items = [(10, 60), (20, 100), (30, 120)]
assert solve_knapsack_problem(n, W, it... | [
{
"docstring": "Solves the 0/1 knapsack problem.\n\nParameters:\nn (int): Number of items \nW (int): Maximum capacity of the backpack\nitems (list of tuples): List of items where each item is represented as (weight, value)\n\nReturns:\nint: The maximum value that can be packed into the backpack without exceedin... | [
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 knapsack(n, W, items):\n \"\"\"\n Finds the maximum value of items that can be packed into the backpack\n without exceeding the maximum weight.\n\n ... | trial_gpt4o_2 | {
"original_instruction": "Han wants to go on a hiking trip. He has a backpack with a maximum capacity of W (in kilograms). He has n items, each item i has a weight w_i and a value v_i. Han wants to maximize the total value of items he can pack into his backpack, but the total weight of items should not exceed W.\n\n... | 0.627094 | Taco_77454 | C | [
"knapsack",
"solve_knapsack_problem"
] | 2 | [
[
"solve_knapsack_problem",
"knapsack"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | afdcc06e7e3bad2f41f0f82dc25d1ffc57267b56 | 82a4b28bb110f97bb8969dfd483d3223436254c4 | |||
v1.0 | complete | Taco | Taco_77616_C | def has_terminating_sequence(n: int) -> bool:
""" Returns True if the sequence starting from n terminates at 1, False otherwise.
>>> has_terminating_sequence(1)
True
>>> has_terminating_sequence(2)
True
"""
def find_terminating_sequences(n: int) -> List[int]:
""" Returns a list of numbers b... | def has_terminating_sequence(n):
"""
Returns True if the sequence starting from n terminates at 1, False otherwise.
"""
seen = set()
while n != 1:
if n in seen:
return False
seen.add(n)
if n % 2 == 0:
n //= 2
else:
n = 3 * n + 1
... | from solution import has_terminating_sequence, find_terminating_sequences
def test_has_terminating_sequence():
assert has_terminating_sequence(1) == True
assert has_terminating_sequence(2) == True
assert has_terminating_sequence(3) == True
assert has_terminating_sequence(4) == True
assert has_termi... | [
{
"docstring": "Returns True if the sequence starting from n terminates at 1, False otherwise.",
"function_declaration": "def has_terminating_sequence(n):",
"function_name": "has_terminating_sequence",
"parameter_list": "(n)"
},
{
"docstring": "Returns a list of numbers below n that have ter... | [
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_terminating_sequence(x):\n \"\"\"\n Returns True if the sequence starting from x reaches 1, False otherwise.\n \"\"\"\n seen = set()\n while ... | trial_gpt4o_3 | {
"original_instruction": "Peter is fascinated by a certain numerical pattern he discovered. This pattern contains sequences of numbers, each starting from a given positive integer. Each next number in the sequence is calculated by the following rules:\n\n- If the number is even, divide it by 2.\n- If the number is o... | 0.643978 | Taco_77616 | C | [
"has_terminating_sequence",
"find_terminating_sequences"
] | 2 | [
[
"find_terminating_sequences",
"has_terminating_sequence"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7134c24c1b94bf4b7d513dc19b67c90851c37371 | 8b50c00d4fd2fc2ad0730e1d81b84f6959505d72 | |||
v1.0 | complete | Taco | Taco_77496_C | def organize_books(T, test_cases):
"""
Organizes books by genre and identifier.
Parameters:
T (int): Number of test cases.
test_cases (list): A list of lists where each sublist corresponds to a test case.
Each sublist contains a tuple that represents a book (genre, identi... | def organize_books(T, test_cases):
"""
Organizes books by genre and identifier.
Parameters:
T (int): Number of test cases.
test_cases (list): A list of lists where each sublist corresponds to a test case.
Each sublist contains a tuple that represents a book (genre, identi... | def test_organize_books():
input_string = "2\n3\nfiction 2\nnonfiction 1\nfiction 1\n4\nromance 1\nscience 2\nromance 3\nscience 1\n"
expected_output = "fiction:\n1 2\nnonfiction:\n1\n\nromance:\n1 3\nscience:\n1 2"
assert handle_books(input_string) == expected_output
def test_single_genre():
input_str... | [
{
"docstring": "Organizes books by genre and identifier.\n\nParameters:\nT (int): Number of test cases.\ntest_cases (list): A list of lists where each sublist corresponds to a test case.\n Each sublist contains a tuple that represents a book (genre, identifier).\n \nReturns:\... | [
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 organize_books(test_cases):\n results = []\n for case in test_cases:\n N, books = case\n genre_dict = {}\n ordered_genres = []\n ... | trial_gpt4o_2 | {
"original_instruction": "A digital library wants to organize a large number of books efficiently. Each book has a unique identifier and belongs to a specific genre. The library wants to place all the books on shelves such that each shelf contains books of only one genre. Furthermore, within a genre, all books shoul... | 0.524282 | Taco_77496 | C | [
"organize_books",
"parse_input",
"handle_books"
] | 3 | [
[
"handle_books",
"organize_books"
],
[
"handle_books",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | false | [] | true | 0e6ce3b0f552f7b83387f5f1838260d700df3abb | 6351e17732de14f959adc6b7e8fb9f6b1fc7205b | |||
v1.0 | complete | Taco | Taco_77669_C | from typing import List, Tuple
def is_balanced_tree(nodes: List[Tuple[int, int, str]]) -> bool:
""" Determine if a binary tree is balanced based on the given nodes.
>>> is_balanced_tree([(1, 2, 'L'), (1, 3, 'R'), (2, 4, 'L'), (2, 5, 'R'), (3, 6, 'L')])
True
>>> is_balanced_tree([(1, 2, 'L'), (1, 3, 'R'... | from typing import List, Tuple
class TreeNode:
def __init__(self, key):
self.left = None
self.right = None
self.val = key
def build_tree(nodes: List[Tuple[int, int, str]]) -> TreeNode:
if not nodes:
return None
node_dict = {}
for parent, child, direction i... | from solution import is_balanced_tree
def test_balanced_tree():
tree1 = [(1, 2, 'L'), (1, 3, 'R'), (2, 4, 'L'), (2, 5, 'R'), (3, 6, 'L')]
assert is_balanced_tree(tree1) == True
def test_unbalanced_tree():
tree2 = [(1, 2, 'L'), (1, 3, 'R'), (2, 4, 'L'), (2, 5, 'R'), (4, 8, 'L')]
assert is_balanced_tree... | [] | [
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 typing import List, Tuple, Optional\n\nclass TreeNode:\n def __init__(self, value: int):\n self.value = value\n self.left = None\n sel... | trial_gpt4o_1 | {
"original_instruction": "Given a binary tree, write a function to determine if it is a balanced binary tree. A balanced binary tree is defined as a binary tree in which the left and right subtrees of every node differ in height by no more than 1.\n\n------ Input Format ------ \n\n- The input consists of lines in wh... | 0.800882 | Taco_77669 | C | [
"build_tree",
"is_balanced_tree"
] | 2 | [
[
"is_balanced_tree",
"build_tree"
]
] | 1 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | ddead32721afc53436c92bb733a57e439d017c03 | 48eb77563d0790e0750168f0c5dd7a61c9bce828 | |||
v1.0 | complete | Taco | Taco_77584_C | from typing import List, Tuple
def max_cooperative_group(n: int, towers: List[Tuple[int, int, int]]) -> int:
""" Determine the maximum number of towers that can form a single cooperative group on the grid.
>>> max_cooperative_group(5, [(0, 0, 2), (3, 0, 2), (1, 1, 2), (4, 4, 2), (5, 5, 2)])
3
>>> max_c... | def calculate_union_find(parents, tower):
if parents[tower] != tower:
parents[tower] = calculate_union_find(parents, parents[tower])
return parents[tower]
def union(parents, rank, tower1, tower2):
root1 = calculate_union_find(parents, tower1)
root2 = calculate_union_find(parents, tower2)
if... | from solution import max_cooperative_group
def test_example_1():
n = 5
towers = [
(0, 0, 2),
(3, 0, 2),
(1, 1, 2),
(4, 4, 2),
(5, 5, 2)
]
assert max_cooperative_group(n, towers) == 3
def test_no_overlap():
n = 3
towers = [
(0, 0, 2),
(10,... | [
{
"docstring": null,
"function_declaration": "def calculate_union_find(parents, tower):",
"function_name": "calculate_union_find",
"parameter_list": "(parents, tower)"
},
{
"docstring": null,
"function_declaration": "def union(parents, rank, tower1, tower2):",
"function_name": "union... | [
0,
1
] | 1 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def max_cooperative_towers(n, towers):\n def can_communicate(t1, t2):\n x1, y1, s1 = t1\n x2, y2, s2 = t2\n x1_min, x1_max = x1 - s1 // 2, ... | trial_gpt4o_1 | {
"original_instruction": "Manao is now tasked with optimizing the location of research towers on a vast grid. The research towers must be placed at specific points and each tower covers an influence area defined by a square centered at the tower's location. Two towers can cooperate if their influence areas overlap o... | 0.606617 | Taco_77584 | C | [
"calculate_union_find",
"union",
"max_cooperative_group",
"main"
] | 4 | [
[
"max_cooperative_group",
"calculate_union_find"
],
[
"max_cooperative_group",
"union"
],
[
"union",
"calculate_union_find"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | c41d4ce917902eefa02ce1674a09a5653dc6cf07 | 14d972f7b4c448f2aa20ce80c71b2f36cf876ca0 | |||
v1.0 | complete | Taco | Taco_77896_C | def replace_with_nearest_primes(lst):
"""
Replace each integer in the list with the nearest prime number. If the integer itself
is a prime, it remains unchanged. If there is a tie between two prime numbers, choose the smaller one.
Args:
lst (List[int]): A list of integers.
Returns:
... | def is_prime(n):
"""
Check if a number is prime.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True... | from solution import replace_with_nearest_primes
def test_replace_with_nearest_primes():
assert replace_with_nearest_primes([4, 10, 27, 38, 59]) == [3, 11, 29, 37, 59]
assert replace_with_nearest_primes([7, 12, 1, 100, 250]) == [7, 11, 2, 101, 251]
assert replace_with_nearest_primes([1, 2, 3, 4, 5]) == [2,... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Find the nearest prime number to n. If n is prime, it remains unchanged.\nIf there is a tie between two prime numbers, return the ... | [
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 sieve(n):\n \"\"\"\n Generate a list of primes up to and including `n` using the Sieve of Eratosthenes.\n \"\"\"\n is_prime = [True] * (n + 1)\n ... | trial_gpt4o_2 | {
"original_instruction": "Write a function that receives a list of integers and returns a list of integers where each element is replaced by the nearest prime number. If the element itself is a prime, it remains unchanged. If there is a tie between two prime numbers (i.e., the same distance from the number), choose ... | 0.550648 | Taco_77896 | C | [
"is_prime",
"nearest_prime",
"replace_with_nearest_primes"
] | 3 | [
[
"nearest_prime",
"is_prime"
],
[
"replace_with_nearest_primes",
"nearest_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 5918831f9e6ae29cc4cf5751455ee649ed1f6718 | 721590d67fddc3f4ed5c8ef2d2716c4272534910 | |||
v1.0 | complete | Taco | Taco_77461_C | def find_renovation_addresses(T: int, cases: list) -> list:
""" Finds all the addresses within a given range [a, b] that meet the criteria for renovation.
Args:
T (int): The number of test cases.
cases (list): A list of tuples where each tuple contains three integers: a, b, and P.
Returns:... | def digit_sum(n):
"""Returns the sum of digits of n"""
return sum(int(digit) for digit in str(n))
def find_renovation_addresses(T, cases):
results = []
for case in cases:
a, b, P = case
qualifying_addresses = [i for i in range(a, b+1) if digit_sum(i) == P]
if qualifying_addresse... | from solution import find_renovation_addresses
def test_single_case_no_qualifying_addresses():
T = 1
cases = [
(1, 5, 10)
]
assert find_renovation_addresses(T, cases) == ["No houses will be renovated"]
def test_single_case_with_qualifying_addresses():
T = 1
cases = [
(10, 20, 2... | [
{
"docstring": "Returns the sum of digits of n",
"function_declaration": "def digit_sum(n):",
"function_name": "digit_sum",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def find_renovation_addresses(T, cases):",
"function_name": "find_renovation_addresses"... | [
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 sum_of_digits(n):\n return sum(int(digit) for digit in str(n))\n\ndef houses_for_renovation(T, test_cases):\n results = []\n for i in range(T):\n ... | trial_gpt4o_1 | {
"original_instruction": "In a small town called Algora, every house has a unique and positive integer address. Recently, the town council has decided to renovate certain houses. They have specific criteria to decide which houses will be renovated. The council has given you a number P. A house will be considered for... | 0.546267 | Taco_77461 | C | [
"digit_sum",
"find_renovation_addresses"
] | 2 | [
[
"find_renovation_addresses",
"digit_sum"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2e11c6fa9fdc9516b26c933214bd6fc048598a7c | d7d94b6b2fccf5062b7cdf15b04be067bc9fcfa8 | |||
v1.0 | complete | Taco | Taco_77768_C | def guess_integer(y):
"""
Guesses the integer y held by a friend using a binary search strategy.
"""
low, high = 0, 2**30 - 1
while low < high:
mid = (low + high) // 2
if is_greater(y, mid):
low = mid + 1
else:
high = mid
return low
def is_g... | def guess_integer(y):
"""
Guesses the integer y held by a friend using a binary search strategy.
"""
low, high = 0, 2**30 - 1
while low < high:
mid = (low + high) // 2
if is_greater(y, mid):
low = mid + 1
else:
high = mid
return low
def is_g... | from solution import guess_integer
def test_guess_integer():
test_cases = [
(0, 0),
(1, 1),
(20, 20),
(2**30 - 1, 2**30 - 1),
(2**29, 2**29),
(123456, 123456),
]
for y, expected in test_cases:
assert guess_integer(y) == expected | [
{
"docstring": "Guesses the integer y held by a friend using a binary search strategy.",
"function_declaration": "def guess_integer(y):",
"function_name": "guess_integer",
"parameter_list": "(y)"
},
{
"docstring": "Mock response function to simulate the friend's answer.\nFor test purposes, i... | [
1,
0
] | 1 | medium | 0.5 | {
"trial_gpt4o_0": null,
"trial_gpt4o_1": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared1_results_combined.jsonl",
"solution_code": "def guess_integer(y):\n \"\"\"\n Guesses the integer y held by a friend using a binary search strategy.\n \"\"\"\n low, high =... | trial_gpt4o_1 | {
"original_instruction": "Mahmoud and his friend are playing a game! They each have an integer, and they take turns guessing the other player's integer. Mahmoud has an integer \\( x \\) and his friend has an integer \\( y \\). Both \\( x \\) and \\( y \\) are initially unknown to the other player.\n\nTo guess the va... | 0.559956 | Taco_77768 | C | [
"guess_integer",
"is_greater"
] | 2 | [
[
"guess_integer",
"is_greater"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 45b9635e266b1c1ef6d6d1b9d5f3a1aa57883de8 | 338de6fd64eb2ec2e9a79b0ef05f921c34d86f34 | |||
v1.0 | complete | Taco | Taco_77573_C | def bubble_sort(nums):
"""Sorts a list of distinct integers in non-decreasing order using Bubble Sort.
Args:
nums (List[int]): The list of distinct integers to be sorted.
Example:
>>> nums = [64, 34, 25, 12, 22]
>>> bubble_sort(nums)
>>> nums
[12, 22, 25, 34, 64]
"""
pa... | def bubble_sort(nums):
n = len(nums)
for i in range(n):
for j in range(0, n-i-1):
if nums[j] > nums[j+1]:
nums[j], nums[j+1] = nums[j+1], nums[j]
def is_sorted(nums):
return all(nums[i] <= nums[i+1] for i in range(len(nums)-1))
def sort_and_verify(n, nums):
bubble_s... | from solution import bubble_sort, is_sorted, sort_and_verify
def test_bubble_sort():
arr = [64, 34, 25, 12, 22]
bubble_sort(arr)
assert arr == [12, 22, 25, 34, 64]
def test_is_sorted_true():
assert is_sorted([1, 2, 3, 4, 5]) == True
def test_is_sorted_false():
assert is_sorted([1, 3, 2, 4, 5]) ==... | [
{
"docstring": null,
"function_declaration": "def bubble_sort(nums):",
"function_name": "bubble_sort",
"parameter_list": "(nums)"
},
{
"docstring": null,
"function_declaration": "def is_sorted(nums):",
"function_name": "is_sorted",
"parameter_list": "(nums)"
},
{
"docstri... | [
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 bubble_sort(nums):\n n = len(nums)\n for i in range(n):\n for j in range(0, n-i-1):\n if nums[j] > nums[j+1]:\n nums[j],... | trial_gpt4o_0 | {
"original_instruction": "As a software engineer, you are tasked with creating an algorithm to sort a list of distinct integers in a non-decreasing order. However, the catch is that you can only use a specific subset of sorting algorithms. The algorithms you are allowed to use are:\n\n- Selection Sort\n- Insertion S... | 0.742518 | Taco_77573 | C | [
"bubble_sort",
"is_sorted",
"sort_and_verify"
] | 3 | [
[
"sort_and_verify",
"bubble_sort"
],
[
"sort_and_verify",
"is_sorted"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 0ed98ac4c4345cc9a51ed7bb53c0e7f4542aa788 | a2c2cbc94a719b0786e6ab46e50171e10dd1524b | |||
v1.0 | complete | Taco | Taco_77492_C | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def deleteNode(root: TreeNode, key: int) -> TreeNode:
"""
Given a binary search tree root and an integer key, delete the node with the given key and
return the ne... | class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
def deleteNode(root, key):
if not root:
return None
if key < root.val:
root.left = deleteNode(root.left, key)
elif key > root.val:
root.r... | import pytest
from solution import TreeNode, deleteNode, inorderTraversal
def build_tree(values):
if not values:
return None
nodes = [TreeNode(val) if val is not None else None for val in values]
kids = nodes[::-1]
root = kids.pop()
for node in nodes:
if node:
if kids: n... | [] | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class 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... | trial_gpt4o_1 | {
"original_instruction": "We are given the root node of a binary search tree: a tree where each node follows the property that all nodes in its left subtree have values less than the node's value, and all nodes in its right subtree have values greater than the node's value.\n\nGiven a binary search tree, root, and t... | 0.611508 | Taco_77492 | C | [
"deleteNode",
"findMin",
"inorderTraversal"
] | 3 | [
[
"deleteNode",
"findMin"
]
] | 1 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | ed63ec90d1a60a8a609150b091fe03c58e5cd5ec | c14dcce9c525c090b56b9deb958ffa3c09fe02fe | |||
v1.0 | complete | Taco | Taco_78216_C | def count_islands(input_str: str) -> int:
""" Count the number of distinct islands in the given matrix.
An island is a group of adjacent lands connected horizontally or vertically.
>>> count_islands("4 5\n11110\n11010\n11000\n00000")
1
>>> count_islands("4 5\n11000\n11000\n00100\n00011")
3
... | def num_islands(matrix):
if not matrix:
return 0
R = len(matrix)
C = len(matrix[0])
visited = [[False for _ in range(C)] for _ in range(R)]
def dfs(r, c):
stack = [(r, c)]
while stack:
row, col = stack.pop()
if 0 <= row < R and 0 <= col < C and not v... | import pytest
from solution import count_islands
def test_single_island():
input_str = """4 5
11110
11010
11000
00000"""
assert count_islands(input_str) == 1
def test_multiple_islands():
input_str = """4 5
11000
11000
00100
00011"""
assert count_islands(input_str) == 3
def test_no_islands():
inpu... | [
{
"docstring": null,
"function_declaration": "def num_islands(matrix):",
"function_name": "num_islands",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def parse_input(input_str):",
"function_name": "parse_input",
"parameter_list": "(input_str)"
}... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_islands(matrix):\n \"\"\"\n Returns the number of distinct islands (connected groups of '1') in the given matrix.\n \"\"\"\n \n def dfs(ma... | trial_gpt4o_2 | {
"original_instruction": "You are given a rectangular matrix of characters where '1' represents land and '0' represents water. An island is a group of adjacent lands connected horizontally or vertically. You need to count the number of distinct islands in the matrix.\n\nInput\n\nThe first input line contains two int... | 0.595216 | Taco_78216 | C | [
"num_islands",
"parse_input",
"count_islands"
] | 3 | [
[
"count_islands",
"num_islands"
],
[
"count_islands",
"parse_input"
]
] | 2 | [
"parse_input"
] | false | [] | false | pytest | true | [] | true | 667bd5e804c75f2c9a0cd0218fa9557d7f4e6916 | f0a20be44d891c0652dd2ba0dea381699ee47359 | |||
v1.0 | complete | Taco | Taco_77678_C | from functools import cmp_to_key
from typing import List, Tuple
def compare(x: str, y: str) -> int:
"""
Comparator function to determine the order for the largest concatenated number
"""
if x + y > y + x:
return -1
elif x + y < y + x:
return 1
else:
return 0
def largest... | from functools import cmp_to_key
def compare(x, y):
"""
Comparator function to determine the order for the largest concatenated number
"""
if x + y > y + x:
return -1
elif x + y < y + x:
return 1
else:
return 0
def largest_number(blocks):
"""
Forms the large... | def test_largest_number():
# Simple case
test_cases = [(3, [10, 2, 9]), (4, [62, 32, 21, 9])]
assert process_input(test_cases) == ["9210", "9623221"]
# Case with leading zeros
test_cases = [(3, [0, 0, 0])]
assert process_input(test_cases) == ["0"]
# Larger numbers
test_cases = ... | [
{
"docstring": "Comparator function to determine the order for the largest concatenated number",
"function_declaration": "def compare(x, y):",
"function_name": "compare",
"parameter_list": "(x, y)"
},
{
"docstring": "Forms the largest number possible with given blocks",
"function_declara... | [
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 functools import cmp_to_key\n\ndef compare(x, y):\n \"\"\"\n Comparator function to determine the order for the largest concatenated number\n \"\"\"\... | trial_gpt4o_0 | {
"original_instruction": "Wooden Blocks are fun to play with! John has a collection of wooden blocks, each with a number written on it. He loves to rearrange these blocks in different ways. Today, he decided to challenge himself by forming the largest possible number using all the blocks he has.\n\nEvery block can o... | 0.613601 | Taco_77678 | C | [
"compare",
"largest_number",
"process_input"
] | 3 | [
[
"largest_number",
"compare"
],
[
"process_input",
"largest_number"
]
] | 2 | [
"process_input"
] | false | [] | false | pytest | false | [] | true | 4e7235bf50a061ef7bf89a6dc5e07ae5d73714f4 | 33b001496185f3f1c166f251a70545aff6d20a69 | |||
v1.0 | complete | Taco | Taco_78153_C | import math
from itertools import permutations
def is_special_number(n: int) -> str:
"""
Determine if the digits of the given number can be rearranged to form a square number.
>>> is_special_number(1) == "YES"
>>> is_special_number(10) == "YES"
>>> is_special_number(35) == "NO"
>>> is_special_n... | import math
from itertools import permutations
def is_special_number(n: int) -> str:
"""
Determine if the digits of the given number can be rearranged to form a square number.
"""
digits = str(n)
seen_permutations = set()
for perm in permutations(digits):
perm_number = int(''.join(... | from solution import is_special_number, process_test_cases
def test_is_special_number():
assert is_special_number(1) == "YES"
assert is_special_number(10) == "YES"
assert is_special_number(35) == "NO"
assert is_special_number(4) == "YES"
assert is_special_number(13) == "NO"
assert is_special_nu... | [
{
"docstring": "Determine if the digits of the given number can be rearranged to form a square number.",
"function_declaration": "def is_special_number(n):",
"function_name": "is_special_number",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def process_test_ca... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from itertools import permutations\nimport math\n\ndef is_special_number(N):\n \"\"\"\n Determines if the given number N is a Special Number.\n \n A Sp... | trial_gpt4o_8 | {
"original_instruction": "Consider that you are working with a method where you have to determine if a given number is a \"Special Number.\" A \"Special Number\" is defined as a number whose digits can be rearranged to form at least one square number. \n\nInput\n\nT, the number of test cases.\n\nN, the number for wh... | 0.620646 | Taco_78153 | C | [
"is_special_number",
"process_test_cases",
"run"
] | 3 | [
[
"process_test_cases",
"is_special_number"
],
[
"run",
"process_test_cases"
]
] | 2 | [
"process_test_cases"
] | false | [] | false | pytest | true | [] | true | 5777026b8148a3b48883fd629d1d52debefeea90 | 326fa325e47b3f1a4981fc50a07b3a3bb862d6d6 | |||
v1.0 | complete | Taco | Taco_78047_C | def game_result(nextMove, lastMove):
"""
Determines the result of the game based on nextMove and lastMove.
If nextMove is greater than or equal to 8, or if nextMove is greater than lastMove, Second player wins ("Second").
If both players have the same move, it's a draw ("Draw").
Otherwise, the First... | def game_result(nextMove, lastMove):
"""
Determines the result of the game based on nextMove and lastMove.
If nextMove is greater than or equal to 8, or if nextMove is greater than lastMove, Second player wins ("Second").
If both players have the same move, it's a draw ("Draw").
Otherwise, the First... | from solution import game_series
def test_game_series():
moves = [(6, 4), (5, 3), (2, 1), (0, 0)]
expected_results = ["Second", "Second", "Second"]
assert game_series(moves) == expected_results
def test_game_series_with_draw():
moves = [(6, 4), (5, 3), (2, 2), (0, 0)]
expected_results = ["Second",... | [
{
"docstring": "Determines the result of the game based on nextMove and lastMove.\nIf nextMove is greater than or equal to 8, or if nextMove is greater than lastMove, Second player wins (\"Second\").\nIf both players have the same move, it's a draw (\"Draw\").\nOtherwise, the First player wins (\"First\").",
... | [
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 simulate_moves(nextMove, lastMove):\n \"\"\"\n Determines the winner of the game based on the given moves.\n \n The goal is to reach a score of at ... | trial_gpt4o_4 | {
"original_instruction": "Write a function that takes two integers `nextMove` and `lastMove` to simulate moves in a two-player turn-based game. The function should determine if the second player can win with their next move based on the initial moves of the game provided by `nextMove` and `lastMove`. The goal is to ... | 0.623078 | Taco_78047 | C | [
"game_result",
"game_series"
] | 2 | [
[
"game_series",
"game_result"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | cc5ff62cec3ff01d59affd029b44a30bcf508037 | 1df84121c7078128a6dbd71b2a1da9fe355571c5 | |||
v1.0 | complete | Taco | Taco_78135_C | def fibonacci_sequence_upto(m):
""" Generate Fibonacci numbers up to `m`.
>>> fibonacci_sequence_upto(10) == [1, 1, 2, 3, 5, 8]
>>> fibonacci_sequence_upto(1000) == [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]
"""
def count_fibonacci_tables(M):
""" Return the count of Fibonac... | MOD = 1000000007
def fibonacci_sequence_upto(m):
"""Generate Fibonacci numbers up to `m`."""
fibs = [1, 1]
while True:
next_fib = fibs[-1] + fibs[-2]
if next_fib > m:
break
fibs.append(next_fib)
return fibs
def count_fibonacci_tables(M):
fibonacci_numbers = fibo... | def test_fibonacci_sequence_upto():
assert fibonacci_sequence_upto(10) == [1, 1, 2, 3, 5, 8]
assert fibonacci_sequence_upto(1000) == [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]
def test_count_fibonacci_tables():
assert count_fibonacci_tables(10) == 6
assert count_fibonacci_tables(10... | [
{
"docstring": "Generate Fibonacci numbers up to `m`.",
"function_declaration": "def fibonacci_sequence_upto(m):",
"function_name": "fibonacci_sequence_upto",
"parameter_list": "(m)"
},
{
"docstring": null,
"function_declaration": "def count_fibonacci_tables(M):",
"function_name": "c... | [
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 count_fibonacci_tables(T, Ms):\n MOD = 1000000007\n \n def fibonacci_up_to(n):\n fibs = [1, 2]\n while True:\n next_fib = fib... | trial_gpt4o_4 | {
"original_instruction": "Bob is a skilled carpenter and has just received an unusual order. He needs to craft rectangular tables using wooden planks. Each plank has a positive integer length, but since Bob wants the tables to look aesthetically pleasing, the lengths of the planks of a single table must follow the F... | 0.68414 | Taco_78135 | C | [
"fibonacci_sequence_upto",
"count_fibonacci_tables",
"find_all_unique_tables"
] | 3 | [
[
"count_fibonacci_tables",
"fibonacci_sequence_upto"
],
[
"find_all_unique_tables",
"count_fibonacci_tables"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 0dd352ce204cc6bc39e7ee0bad8708434a55f2a4 | fa741a735bd9b9db7fcb3ebcb928839d4978deb8 | |||
v1.0 | complete | Taco | Taco_77628_C | def process_transactions_input(T: int, transaction_list: List[str]) -> Dict[str, int]:
""" You have been given a list of transaction records. Each record contains an identifier of the account holder, the transaction type (either deposit or withdrawal), and the amount involved in the transaction.
Your task is t... | def calculate_final_balances(transactions):
from collections import defaultdict
balances = defaultdict(int)
invalid_accounts = set()
for account, trans_type, amount in transactions:
if account in invalid_accounts:
continue # Skip processing if the account is already invalid
... | from solution import process_transactions_input
def test_single_valid_deposit():
T = 1
transactions = ["alice deposit 1000"]
result = process_transactions_input(T, transactions)
assert result == {"alice": 1000}
def test_single_invalid_withdrawal():
T = 1
transactions = ["alice withdrawal 1000"... | [
{
"docstring": null,
"function_declaration": "def calculate_final_balances(transactions):",
"function_name": "calculate_final_balances",
"parameter_list": "(transactions)"
},
{
"docstring": null,
"function_declaration": "def process_transactions_input(T, transaction_list):",
"functio... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_final_balances(transactions):\n accounts = {}\n \n for account_id, trans_type, amount in transactions:\n if account_id not in account... | trial_gpt4o_1 | {
"original_instruction": "You have been given a list of transaction records. Each record contains an identifier of the account holder, the transaction type (either deposit or withdrawal), and the amount involved in the transaction.\n\nYour task is to write a program to determine the final balance of each account hol... | 0.623546 | Taco_77628 | C | [
"calculate_final_balances",
"process_transactions_input"
] | 2 | [
[
"process_transactions_input",
"calculate_final_balances"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | cb207662a608c0727531f6669ef0f7f5ea11d808 | 3df4077cdb8be5c121a1376bd317e239dd6e9fd5 | |||
v1.0 | complete | Taco | Taco_78446_C | def validate_cargo_records(test_cases):
"""
Validates the cargo records against the Fibonacci numbers.
>>> validate_cargo_records([(2, 1, 1), (3, 2, 3, 4), (4, 0, 1, 1, 2)])
['YES', 'NO', 'YES']
>>> validate_cargo_records([(2, 1, 2), (3, 4, 5, 6)])
['YES', 'NO']
>>> validate_cargo_records([(... | def is_fibonacci(n, fib_set):
"""
Check if a number is in the precomputed set of Fibonacci numbers.
"""
return n in fib_set
def generate_fibonacci_up_to(max_val):
"""
Generate all Fibonacci numbers up to a maximum value and return as a set.
"""
fib_set = set()
a, b = 0, 1
while ... | import pytest
from solution import validate_cargo_records
def test_validate_cargo_records_all_valid():
assert validate_cargo_records([(2, 1, 1), (4, 0, 1, 1, 2)]) == ['YES', 'YES']
def test_validate_cargo_records_some_invalid():
assert validate_cargo_records([(3, 2, 3, 4)]) == ['NO']
assert validate_cargo... | [
{
"docstring": "Check if a number is in the precomputed set of Fibonacci numbers.",
"function_declaration": "def is_fibonacci(n, fib_set):",
"function_name": "is_fibonacci",
"parameter_list": "(n, fib_set)"
},
{
"docstring": "Generate all Fibonacci numbers up to a maximum value and return as... | [
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_fibonacci(n, fib_set):\n \"\"\"\n Check if a number is in the precomputed set of Fibonacci numbers.\n \"\"\"\n return n in fib_set\n\ndef genera... | trial_gpt4o_0 | {
"original_instruction": "You are working on a system that monitors spaceship cargo. Each spaceship can carry a certain number of distinct cargo items, each identified by a unique ID number. The cargo system monitors both incoming and outgoing ships, tracking several cargo parameters.\n\nIn tracking the cargo, every... | 0.509913 | Taco_78446 | C | [
"is_fibonacci",
"generate_fibonacci_up_to",
"validate_cargo_records"
] | 3 | [
[
"validate_cargo_records",
"generate_fibonacci_up_to"
],
[
"validate_cargo_records",
"is_fibonacci"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 1c0ef9bc80e9e770df8d3ea7fe33820eba89f407 | bb19c4dd985c8dd4c6d4ba2ad94cf1100de208ee | |||
v1.0 | complete | Taco | Taco_78075_C | def update_range(arr, i, k, d):
""" Increment the values in the range [i, k] by d.
>>> arr = [10, 20, 30, 40, 50]
>>> update_range(arr, 2, 4, 10)
>>> arr
[10, 30, 40, 50, 50]
"""
def query_sum(arr, i, k):
""" Calculate the sum of values in the range [i, k].
>>> arr = [10, 30, 40, 50, 50... | def update_range(arr, i, k, d):
"""
Increment the values in the range [i, k] by d.
"""
for idx in range(i-1, k):
arr[idx] += d
def query_sum(arr, i, k):
"""
Calculate the sum of values in the range [i, k].
"""
return sum(arr[i-1:k])
def process_operations(n, q, a, operations):
... | def test_update_range():
arr = [10, 20, 30, 40, 50]
update_range(arr, 2, 4, 10)
assert arr == [10, 30, 40, 50, 50]
def test_query_sum():
arr = [10, 30, 40, 50, 50]
result = query_sum(arr, 1, 3)
assert result == 80
def test_process_operations():
n = 5
q = 4
a = [10, 20, 30, 40, 50]
... | [
{
"docstring": "Increment the values in the range [i, k] by d.",
"function_declaration": "def update_range(arr, i, k, d):",
"function_name": "update_range",
"parameter_list": "(arr, i, k, d)"
},
{
"docstring": "Calculate the sum of values in the range [i, k].",
"function_declaration": "d... | [
1,
0
] | 1 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def update_range(arr, i, k, d):\n \"\"\"\n Increment the values in the range [i, k] by d.\n \"\"\"\n for idx in range(i-1, k):\n arr[idx] += d\n... | trial_gpt4o_0 | {
"original_instruction": "You are given a list of n integers representing the scores of n players in a game. The game, however, has a peculiar rule: players' scores can be changed when specific events occur, and some queries need to be answered about the scores in specific ranges. You must handle two types of operat... | 0.590685 | Taco_78075 | C | [
"update_range",
"query_sum",
"process_operations"
] | 3 | [
[
"process_operations",
"query_sum"
],
[
"process_operations",
"update_range"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | 1cd5d337a324bc4e43e0f415668bfa57938c28ca | 5786db62bb166754fba2b0057c8036557fef7a24 | |||
v1.0 | complete | Taco | Taco_78247_C | def min_construction_cost(N: int, M: int, lines: List[Tuple[int, int, int]]) -> int:
""" Compute the minimum construction cost to connect all stations with given number of stations and direct rail lines.
>>> min_construction_cost(4, 5, [(1, 2, 5), (1, 3, 10), (2, 3, 2), (3, 4, 1), (2, 4, 8)])
8
>>> min_... | def find(parent, i):
if parent[i] == i:
return i
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] = xroot
... | from solution import min_construction_cost
def test_sample_input_1():
assert min_construction_cost(4, 5, [(1, 2, 5), (1, 3, 10), (2, 3, 2), (3, 4, 1), (2, 4, 8)]) == 8
def test_sample_input_2():
assert min_construction_cost(3, 3, [(1, 2, 1), (1, 3, 4), (2, 3, 2)]) == 3
def test_min_construction_cost_single_s... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
0,
0,
0,
0,
1
] | 1 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\... | trial_gpt4o_4 | {
"original_instruction": "The National Railway Company is planning to construct a new rail network. The network will consist of stations connected by direct rail lines. Each rail line has a specific construction cost.\n\nThe goal is to connect all the stations with the minimum possible construction cost. The network... | 0.657851 | Taco_78247 | C | [
"find",
"union",
"kruskal",
"min_construction_cost"
] | 4 | [
[
"kruskal",
"find"
],
[
"kruskal",
"union"
],
[
"min_construction_cost",
"kruskal"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | ec3865e85728826d7a842cca3666e55826d46116 | 62bdde79a503c58b951648062a074f78a8f5e686 | |||
v1.0 | complete | Taco | Taco_78021_C | from typing import List
def min_trips(n: int, weights: List[int], capacity: int) -> int:
""" Calculate the minimum number of trips needed for each vehicle to deliver all packages.
Args:
n (int): The number of packages.
weights (List[int]): The weights of the packages.
capacity (int... | def calculate_trips(packages, capacity):
trips = 0
current_weight = 0
for weight in packages:
if current_weight + weight <= capacity:
current_weight += weight
else:
trips += 1
current_weight = weight
if current_weight > 0:
trips += 1
... | from solution import min_trips
def test_basic_example1():
assert min_trips(5, [2, 3, 4, 5, 6], 10) == 3
def test_basic_example2():
assert min_trips(7, [1, 2, 3, 4, 5, 6, 7], 7) == 5
def test_single_package():
assert min_trips(1, [5], 10) == 1
def test_exact_capacity():
assert min_trips(3, [3, 3,... | [
{
"docstring": null,
"function_declaration": "def calculate_trips(packages, capacity):",
"function_name": "calculate_trips",
"parameter_list": "(packages, capacity)"
},
{
"docstring": null,
"function_declaration": "def min_trips(n, weights, capacity):",
"function_name": "min_trips",
... | [
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 minimum_trips(packages, capacity):\n \"\"\"\n Returns the minimum number of trips needed to deliver all packages\n given the weight capacity of each v... | trial_gpt4o_3 | {
"original_instruction": "A transportation company is planning the most efficient way to deliver packages from a central hub to several delivery points. Each package has a weight, and each delivery vehicle has a maximum weight capacity. Your task is to determine how many trips each vehicle will need to make in order... | 0.627505 | Taco_78021 | C | [
"calculate_trips",
"min_trips"
] | 2 | [
[
"min_trips",
"calculate_trips"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 110e54ec4db6bfeedf2903520891a810ad209899 | e18848e4346ad7f7511b57c385a73b14e647f0e4 | |||
v1.0 | complete | Taco | Taco_78554_C | def is_prime(num: int) -> bool:
""" Check if the given number is prime.
>>> is_prime(2) == True
>>> is_prime(4) == False
"""
def smallest_prime_ge(n: int) -> int:
""" Returns the smallest prime number p such that p is greater than or equal to n.
>>> smallest_prime_ge(10) == 11
>>> smallest_... | def is_prime(num):
"""
Check if the given 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
... | from solution import is_prime, smallest_prime_ge
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(20) == False
assert is_prime(23) == True
assert is_prime(1) == False
def test_smallest_prime_g... | [
{
"docstring": "Check if the given number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Returns the smallest prime number p such that p is greater than or equal to n.",
"function_declaration": "def smal... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Check if the given number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\... | trial_gpt4o_0 | {
"original_instruction": "Johnny has recently started learning about number theory and is fascinated by the concept of prime numbers. He came up with a problem for himself and asked you to help him solve it.\n\nGiven an integer `n`, return the smallest prime number `p` such that `p` is greater than or equal to `n`.\... | 0.7463 | Taco_78554 | C | [
"is_prime",
"smallest_prime_ge"
] | 2 | [
[
"smallest_prime_ge",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e70b0a06befebaa14db679ced967dd154c01a4c2 | 00dce7923be07e1b8118117d0298b44d6b1bec75 | |||
v1.0 | complete | Taco | Taco_78129_C | def largestRotatedRectangle(M: int, N: int, matrix: List[List[str]]) -> int:
""" Write a function that accepts two integers M and N representing the dimensions of a 2D grid
and a 2D list matrix of size MxN, consisting of only '0's and '1's.
The function should return the area of the largest rectangle cont... | def maximalRectangle(matrix):
if not matrix or not matrix[0]:
return 0
max_area = 0
heights = [0] * len(matrix[0])
for row in matrix:
for i in range(len(row)):
if row[i] == '1':
heights[i] += 1
else:
heights[i] = 0
max_ar... | def test_largestRotatedRectangle():
matrix1 = [
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 0, 0, 1, 0]
]
assert largestRotatedRectangle(4, 5, [[str(x) for x in row] for row in matrix1]) == 6
matrix2 = [
[0, 1],
[1, 0]
]
assert larg... | [
{
"docstring": null,
"function_declaration": "def maximalRectangle(matrix):",
"function_name": "maximalRectangle",
"parameter_list": "(matrix)"
},
{
"docstring": null,
"function_declaration": "def largestRectangleArea(heights):",
"function_name": "largestRectangleArea",
"paramete... | [
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 largest_rectangle_area(histogram):\n stack = []\n max_area = 0\n index = 0\n \n while index < len(histogram):\n if not stack or histogram... | trial_gpt4o_2 | {
"original_instruction": "Write a function `largestRotatedRectangle` that accepts two integers `M` and `N` representing the dimensions of a 2D grid and a 2D list `matrix` of size MxN, consisting of only '0's and '1's. The function should return the area of the largest rectangle containing only 1's that can be obtain... | 0.676718 | Taco_78129 | C | [
"maximalRectangle",
"largestRectangleArea",
"rotate90",
"largestRotatedRectangle"
] | 4 | [
[
"largestRotatedRectangle",
"maximalRectangle"
],
[
"largestRotatedRectangle",
"rotate90"
],
[
"maximalRectangle",
"largestRectangleArea"
]
] | 3 | [] | false | [] | false | pytest | false | [] | true | 3b59d07ec7d9f18957d804bb00c7a1279921d4f0 | d32a3dc4e2102e6b00cd6de612da21854d0e4e85 | |||
v1.0 | complete | Taco | Taco_78348_C | def minimum_round_trip_delay(n, m, s, edges):
""" Find the minimum round-trip delay starting and ending at server `s`.
Args:
n (int): Number of nodes in the graph.
m (int): Number of edges in the graph.
s (int): The starting server.
edges (List[Tuple[int, int, int]]): List of edges represen... | import heapq
def dijkstra(graph, start):
"""
Apply Dijkstra's algorithm to find the shortest paths from start node to all other nodes.
"""
n = len(graph)
distances = [float('inf')] * n
distances[start] = 0
priority_queue = [(0, start)]
while priority_queue:
current_distance, cur... | from solution import minimum_round_trip_delay
def test_case_1():
n = 4
m = 4
s = 1
edges = [(1, 2, 10), (2, 3, 10), (3, 4, 10), (4, 1, 10)]
assert minimum_round_trip_delay(n, m, s, edges) == 40
def test_case_2():
n = 4
m = 3
s = 1
edges = [(1, 2, 10), (2, 3, 10), (3, 4, 10)]
as... | [
{
"docstring": "Apply Dijkstra's algorithm to find the shortest paths from start node to all other nodes.",
"function_declaration": "def dijkstra(graph, start):",
"function_name": "dijkstra",
"parameter_list": "(graph, start)"
},
{
"docstring": "Find the minimum round-trip delay starting and... | [
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 \"\"\"\n Apply Dijkstra's algorithm to find the shortest paths from start node to all other nodes.\n \"\"\"\... | trial_gpt4o_0 | {
"original_instruction": "Dr. Roboto is a researcher who loves analyzing communication networks. He’s currently studying a network of servers connected by unidirectional communication channels. The network is represented as a directed graph with N nodes and M edges. Each edge has an associated non-negative weight re... | 0.541103 | Taco_78348 | C | [
"dijkstra",
"minimum_round_trip_delay",
"main"
] | 3 | [
[
"minimum_round_trip_delay",
"dijkstra"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4e71cd516ed4aeff9af970ee771a820e6e79e932 | 1fadb9a59370fd87a7531d654a92333031de07c9 | |||
v1.0 | complete | Taco | Taco_78581_C | def digit_sum(n):
"""
Returns the sum of the digits of the given number n.
>>> digit_sum(34) 7
>>> digit_sum(65) 11
>>> digit_sum(127) 10
>>> digit_sum(89) 17
>>> digit_sum(0) 0
"""
def max_digit_sum(arr):
"""
Returns the maximum digit sum among the elements of the array a... | def digit_sum(n):
"""
Returns the sum of the digits of the given number n.
"""
return sum(int(digit) for digit in str(n))
def max_digit_sum(arr):
"""
Returns the maximum digit sum among the elements of the array arr.
"""
return max(digit_sum(num) for num in arr) | from solution import digit_sum, max_digit_sum
def test_digit_sum():
assert digit_sum(34) == 7 # 3 + 4
assert digit_sum(65) == 11 # 6 + 5
assert digit_sum(127) == 10 # 1 + 2 + 7
assert digit_sum(89) == 17 # 8 + 9
assert digit_sum(0) == 0 # 0
def test_max_digit_sum():
assert max_digit_sum([34, 6... | [
{
"docstring": "Returns the sum of the digits of the given number n.",
"function_declaration": "def digit_sum(n):",
"function_name": "digit_sum",
"parameter_list": "(n)"
},
{
"docstring": "Returns the maximum digit sum among the elements of the array arr.",
"function_declaration": "def m... | [
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 digit_sum(n):\n \"\"\"\n Returns the sum of the digits of the given number n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef max_digi... | trial_gpt4o_2 | {
"original_instruction": "Given an array of integers, your task is to calculate the \"digit sum\" of all elements in the array. The digit sum of a number is defined as the sum of its individual digits. After calculating the digit sum of each element, find and return the maximum digit sum among them.\n\nFor example:\... | 0.689018 | Taco_78581 | C | [
"digit_sum",
"max_digit_sum"
] | 2 | [
[
"max_digit_sum",
"digit_sum"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | cf48cdd939df38933f762d0968465ce0bbd696fb | b61e92762ae060a844a0352ed72e94b453d53a55 | |||
v1.0 | complete | Taco | Taco_78681_C | def max_value(W, N, item_data):
""" Determine the maximum value that can be carried in a backpack with given weight constraints.
>>> max_value(5, 4, ['2 3', '3 4', '4 5', '5 6'])
7
>>> max_value(1, 1, ['1 1'])
1
>>> max_value(10, 3, ['5 0', '4 0', '3 0'])
0
>>> max_value(10, 4, ['2 1', ... | def knapsack(W, N, items):
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
weight, value = items[i - 1]
for w in range(W + 1):
if weight <= w:
dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weight] + value)
else:
dp[i][w] ... | import pytest
from solution import max_value
def test_example_case():
W = 5
N = 4
items = ['2 3', '3 4', '4 5', '5 6']
assert max_value(W, N, items) == 7
def test_minimum_capacity():
W = 1
N = 1
items = ['1 1']
assert max_value(W, N, items) == 1
def test_zero_values():
W = 10
... | [
{
"docstring": null,
"function_declaration": "def knapsack(W, N, items):",
"function_name": "knapsack",
"parameter_list": "(W, N, items)"
},
{
"docstring": null,
"function_declaration": "def max_value(W, N, item_data):",
"function_name": "max_value",
"parameter_list": "(W, N, ite... | [
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 knapsack(W, items):\n \"\"\"\n Returns the maximum value that can be achieved with the given weight capacity W and the list of items.\n \"\"\"\n dp... | trial_gpt4o_1 | {
"original_instruction": "You are given a backpack with a limited weight capacity and a collection of items, each with a specific weight and value. Your goal is to determine the maximum value you can carry in the backpack without exceeding the weight capacity.\n\nThis is a variation of the Knapsack Problem, where yo... | 0.645635 | Taco_78681 | C | [
"knapsack",
"max_value"
] | 2 | [
[
"max_value",
"knapsack"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9633ca3947b9948022c4d8de009f9f33bc45baef | 5f24f6792dd93d9934278700eb5300936ee5ed4a | |||
v1.0 | complete | Taco | Taco_78744_C | def maximal_rectangle_area(grid: List[str]) -> int:
"""
Given an m x n grid filled with characters 'A' and 'B', determine the area of the largest rectangle containing only 'A's.
>>> maximal_rectangle_area(["AAAAA", "ABAAA", "AABAA", "AAAAA"])
8
>>> maximal_rectangle_area(["BBB", "BBB", "BBB"])... | def maximal_rectangle_area(grid):
if not grid:
return 0
m, n = len(grid), len(grid[0])
heights = [0] * n
max_area = 0
for row in grid:
for j in range(n):
if row[j] == 'A':
heights[j] += 1
else:
heights[j] = 0
... | from solution import maximal_rectangle_area
def test_example1():
grid = ["AAAAA", "ABAAA", "AABAA", "AAAAA"]
assert maximal_rectangle_area(grid) == 8
def test_example2():
grid = ["BBB", "BBB", "BBB"]
assert maximal_rectangle_area(grid) == 0
def test_example3():
grid = ["AAABAA", "ABBBAA", "ABAABA... | [
{
"docstring": null,
"function_declaration": "def maximal_rectangle_area(grid):",
"function_name": "maximal_rectangle_area",
"parameter_list": "(grid)"
},
{
"docstring": null,
"function_declaration": "def max_histogram_area(heights):",
"function_name": "max_histogram_area",
"para... | [
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 maximal_rectangle_area(grid):\n if not grid:\n return 0\n\n m, n = len(grid), len(grid[0])\n heights = [0] * n\n max_area = 0\n \n for... | trial_gpt4o_0 | {
"original_instruction": "Alex, a software developer, is working on a project that involves processing a grid of characters. Each cell in the grid contains a single character, which can be either 'A' or 'B'. Alex needs to find the largest rectangular area within this grid that contains only 'A's.\n\nGiven an $m \\ti... | 0.700167 | Taco_78744 | C | [
"maximal_rectangle_area",
"max_histogram_area"
] | 2 | [
[
"maximal_rectangle_area",
"max_histogram_area"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 71b498789f5677e0f1116a1a3393dd3e27ba7437 | 425b434cf61390713a902ab4be5feee966836c9b | |||
v1.0 | complete | Taco | Taco_78365_C | def road_trip_cost_minimizer(data: str) -> str:
""" Calculate the total fuel cost for each car and identify the car with the minimum fuel cost for a road trip.
>>> road_trip_cost_minimizer("3 500\\n10 5\\n15 4\\n20 3\\n0 0")
'250.00\\n133.33\\n75.00\\nCar 3'
>>> road_trip_cost_minimizer("3 500\\n10... | def calculate_fuel_cost(d, t, cars):
"""
Calculate the total fuel cost for each car and identify the car with the minimum fuel cost.
"""
min_cost = float('inf')
min_car_index = -1
costs = []
for i in range(d):
efficiency, price = cars[i]
cost = (t / efficiency) * price
... | from solution import road_trip_cost_minimizer
def test_single_dataset():
input_data = "3 500\n10 5\n15 4\n20 3\n0 0"
expected_output = "250.00\n133.33\n75.00\nCar 3"
assert road_trip_cost_minimizer(input_data) == expected_output
def test_multiple_datasets():
input_data = "3 500\n10 5\n15 4\n20 3\n2 30... | [
{
"docstring": "Calculate the total fuel cost for each car and identify the car with the minimum fuel cost.",
"function_declaration": "def calculate_fuel_cost(d, t, cars):",
"function_name": "calculate_fuel_cost",
"parameter_list": "(d, t, cars)"
},
{
"docstring": null,
"function_declara... | [
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 calculate_fuel_costs(d, t, car_specs):\n \"\"\"\n Calculates the total fuel cost for each car and identifies the car with the minimum fuel cost.\n \n ... | trial_gpt4o_1 | {
"original_instruction": "A group of friends is planning a road trip, and they want to minimize the cost of fuel. They have multiple car options, each with a different fuel efficiency and fuel cost. Given the duration of the trip, the fuel efficiency of each car, and the price of fuel per unit distance for each car,... | 0.59078 | Taco_78365 | C | [
"calculate_fuel_cost",
"process_input",
"format_output",
"road_trip_cost_minimizer"
] | 4 | [
[
"process_input",
"calculate_fuel_cost"
],
[
"road_trip_cost_minimizer",
"format_output"
],
[
"road_trip_cost_minimizer",
"process_input"
]
] | 3 | [
"process_input",
"format_output"
] | false | [] | false | pytest | true | [] | true | 2de1db4e3374887780528906ff6e07169ec1518b | 08055b066e0976c944e3d890b67b1f8500a4d2df | |||
v1.0 | complete | Taco | Taco_78319_C | def canMeasureWater(x: int, y: int, z: int) -> bool:
"""
You are given two jugs with capacities x and y litres.
There is an infinite amount of water supply available.
You need to determine whether it is possible to measure exactly z litres using these two jugs.
If z liters of water is measurable,... | def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
def canMeasureWater(x: int, y: int, z: int) -> bool:
"""
Determine if it's possible to measure exactly z liters using jugs of size x and y.
"""
# If z exceeds the combined capacity of both jugs, it's impossible
if z > x + y:
... | from solution import canMeasureWater
def test_can_measure_water_example_1():
assert canMeasureWater(3, 5, 4) == True
def test_can_measure_water_example_2():
assert canMeasureWater(2, 6, 5) == False
def test_can_measure_water_example_3():
assert canMeasureWater(1, 2, 3) == True
def test_can_measure_water... | [
{
"docstring": null,
"function_declaration": "def gcd(a, b):",
"function_name": "gcd",
"parameter_list": "(a, b)"
},
{
"docstring": "Determine if it's possible to measure exactly z liters using jugs of size x and y.",
"function_declaration": "def canMeasureWater(x, y, z):",
"function... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\ndef canMeasureWater(x: int, y: int, z: int) -> bool:\n \"\"\"\n Determine if it's... | trial_gpt4o_0 | {
"original_instruction": "# Water Jug Problem\n\nYou are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two jugs.\n\nIf z liters of water is measurable, you must have z liters o... | 0.619851 | Taco_78319 | C | [
"gcd",
"canMeasureWater"
] | 2 | [
[
"canMeasureWater",
"gcd"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | cd9f0ca6921b9ef169f998c877d68684c2995ee0 | 839abe1300fd03cdfbc06d90a747a1b963602599 | |||
v1.0 | complete | Taco | Taco_78509_C | from typing import List, Tuple
def most_scenic_paths(n: int, m: int, q: int, edges: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[int]:
"""
Calculate the most scenic path between pairs of cities based on the queries.
Args:
n (int): Number of cities.
m (int): Number of roads.
... | from collections import defaultdict
import heapq
def preprocess_graph(n, edges):
"""
Preprocess the graph using the given edges and returns an adjacency list.
"""
graph = defaultdict(list)
for u, v, b in edges:
graph[u].append((v, b))
graph[v].append((u, b))
return graph
def ma... | from solution import most_scenic_paths
def test_most_scenic_paths_basic():
n, m, q = 5, 7, 3
edges = [
(1, 2, 4),
(2, 3, 8),
(1, 3, 5),
(4, 5, 1),
(3, 4, 6),
(2, 5, 10),
(3, 5, 7),
]
queries = [
(1, 5),
(2, 4),
(4, 1),
... | [
{
"docstring": "Preprocess the graph using the given edges and returns an adjacency list.",
"function_declaration": "def preprocess_graph(n, edges):",
"function_name": "preprocess_graph",
"parameter_list": "(n, edges)"
},
{
"docstring": "Use Dijkstra's-like algorithm to find the maximum scen... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef find_most_scenic_path(n, m, q, roads, queries):\n def dikjstra_max_min_heap(graph, start, end):\n # distance now stores the max of mi... | trial_gpt4o_2 | {
"original_instruction": "Dana loves exploring new places, and she has recently taken an interest in a series of ancient cities laid out in a line. The cities are numbered from 1 to n and there are m roads connecting pairs of cities. Each road has a certain beauty index, which represents how scenic the road is.\n\nD... | 0.673223 | Taco_78509 | C | [
"preprocess_graph",
"max_scenic_path",
"most_scenic_paths"
] | 3 | [
[
"most_scenic_paths",
"max_scenic_path"
],
[
"most_scenic_paths",
"preprocess_graph"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 9a159bc7f5e1edc36eab9487f469ea42759d4ace | acfddc7e7937f022ae1a9736b6f0bd16317eace0 | |||
v1.0 | complete | Taco | Taco_78909_C | def weakest_security_level(codes: List[str]) -> int:
"""
Returns the security level of the weakest code among the given set
of cryptographic codes. The security level is determined by the number
of distinct substrings a code can generate and the weakest code has
the fewest number of distinct subs... | def distinct_substring_count(s):
"""
Returns the number of distinct substrings in a string s.
"""
substrings = set()
n = len(s)
for i in range(n):
for j in range(i + 1, n + 1):
substrings.add(s[i:j])
return len(substrings)
def weakest_security_level(codes):
... | from solution import weakest_security_level
def test_single_code():
assert weakest_security_level(["abcde"]) == 15
def test_multiple_codes():
assert weakest_security_level(["abcde", "zzz"]) == 3 # correct minimal substrings count for "zzz" is 3
def test_minimal_case():
assert weakest_security_level(["a"... | [
{
"docstring": "Returns the number of distinct substrings in a string s.",
"function_declaration": "def distinct_substring_count(s):",
"function_name": "distinct_substring_count",
"parameter_list": "(s)"
},
{
"docstring": "Returns the security level of the weakest code.",
"function_decla... | [
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 distinct_substrings_count(s):\n \"\"\"\n Helper function to calculate the number of distinct substrings of a given string `s`.\n \"\"\"\n substring... | trial_gpt4o_2 | {
"original_instruction": "You are given several cryptographic codes, each represented as a string consisting of lowercase English alphabet characters. The security level of each code is determined by the number of distinct substrings it can generate. Your task is to find the security level of the weakest code among ... | 0.481567 | Taco_78909 | C | [
"distinct_substring_count",
"weakest_security_level"
] | 2 | [
[
"weakest_security_level",
"distinct_substring_count"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2af6f211f9c64412652f7e045773532340298c65 | d8d4d0f8b07f6d5b600b7f456ad34f4f2b5fd97e | |||
v1.0 | complete | Taco | Taco_78309_C | import itertools
import math
from typing import List, Dict
def tsp(locations: List[Dict[str, int]]) -> str:
""" Compute the shortest route that visits each delivery location once and returns to the starting point (warehouse).
Args:
locations (List[Dict[str, int]]): A list of dictionaries representing ... | import itertools
import math
def calculate_distance(loc1, loc2):
"""
Calculate the Euclidean distance between two points represented as dictionaries with 'x' and 'y' coordinates.
"""
return math.sqrt((loc1['x'] - loc2['x'])**2 + (loc1['y'] - loc2['y'])**2)
def tsp(locations):
"""
Solve the Tra... | from solution import tsp
def test_tsp_simple_case():
locations = [
{"id": 0, "x": 0, "y": 0},
{"id": 1, "x": 2, "y": 3},
{"id": 2, "x": 5, "y": 4},
]
result = tsp(locations)
assert "The best route is: 0 -> " in result
assert " -> 0 with a total distance of " in result
def t... | [
{
"docstring": "Calculate the Euclidean distance between two points represented as dictionaries with 'x' and 'y' coordinates.",
"function_declaration": "def calculate_distance(loc1, loc2):",
"function_name": "calculate_distance",
"parameter_list": "(loc1, loc2)"
},
{
"docstring": "Solve the ... | [
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 permutations\nimport math\n\ndef total_route_distance(route, locations):\n \"\"\"\n Calculate the total distance of the given route.\n ... | trial_gpt4o_3 | {
"original_instruction": "### Preface\nYou have been hired by a logistics company to optimize the delivery routes for their delivery trucks. The goal is to find the shortest possible route that allows each truck to deliver all packages and return to the warehouse.\n\n### Problem\nGiven is a set of delivery locations... | 0.641766 | Taco_78309 | C | [
"calculate_distance",
"tsp"
] | 2 | [
[
"tsp",
"calculate_distance"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4a07cd98d3ad0797a899ed6af1763048b6592616 | 2484372811d60a292bc3a5b79bf79e97c4e04020 | |||
v1.0 | complete | Taco | Taco_78712_C | from typing import List
def min_elevation_change(grid: List[List[int]]) -> int:
"""Calculate the minimum total elevation change required to traverse from the top-left corner to the bottom-right corner of the grid.
Each cell in the grid has a certain elevation given, and the expedition can only move right ... | def min_elevation_change(grid):
"""
This function computes the minimum possible total elevation change to traverse from
the top-left corner to the bottom-right corner of the grid.
"""
N = len(grid)
M = len(grid[0])
# Create a dp table to store the minimum elevation change for each cell
... | from solution import min_elevation_change, solve
def test_min_elevation_change():
grid = [
[1, 3, 5],
[2, 8, 4],
[3, 2, 1]
]
assert min_elevation_change(grid) == 4
def test_solve_example_1():
input_string = "3 3\n1 3 5\n2 8 4\n3 2 1\n"
assert solve(input_string) == 4
def t... | [
{
"docstring": "This function computes the minimum possible total elevation change to traverse from\nthe top-left corner to the bottom-right corner of the grid.",
"function_declaration": "def min_elevation_change(grid):",
"function_name": "min_elevation_change",
"parameter_list": "(grid)"
},
{
... | [
0,
0,
0,
0,
0,
0,
1,
0,
1,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def min_elevation_change(grid):\n import heapq\n \n N = len(grid)\n M = len(grid[0])\n \n if N == 0 or M == 0:\n return 0\n \n direc... | trial_gpt4o_6 | {
"original_instruction": "Consider a land surveying expedition on a field represented as a grid of N x M dimensions. The expedition team is to traverse from the top-left corner of the grid to the bottom-right corner. Each cell in the grid has a certain elevation given, and the challenge is to find a path that minimi... | 0.558875 | Taco_78712 | C | [
"min_elevation_change",
"solve"
] | 2 | [
[
"solve",
"min_elevation_change"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5943643159c4ba72c65962cf323706509f62388f | 98bf2d10801c84b14251f2ef1a1c9189b4846aba | |||
v1.0 | complete | Taco | Taco_78717_C | def min_cut_edge_width(n: int, m: int, edges_list: List[Tuple[int, int, int]]) -> int:
"""
Find the minimum width of a cutting edge that, if removed, would maximize the connectivity
capacity between every pair of cities.
Parameters:
n (int): Number of cities
m (int): Number of roads
e... | 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 test_min_cut_edge_width_example():
n = 5
m = 6
edges_list = [
(1, 2, 4),
(1, 3, 2),
(2, 3, 1),
(2, 4, 3),
(3, 5, 5),
(4, 5, 6)
]
assert min_cut_edge_width(n, m, edges_list) == 3
def test_min_cut_edge_width_single_edge():
n = 2
m = 1
ed... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi... | trial_gpt4o_0 | {
"original_instruction": "The kingdom of Graphland has n cities connected by m bidirectional roads. Each road can have different widths. The width of a road is defined in terms of the maximum number of vehicles that can travel simultaneously on that road. A trade route between two cities is a path that allows mercha... | 0.611391 | Taco_78717 | C | [
"find",
"union",
"kruskal",
"min_cut_edge_width"
] | 4 | [
[
"kruskal",
"find"
],
[
"kruskal",
"union"
],
[
"min_cut_edge_width",
"kruskal"
],
[
"union",
"find"
]
] | 4 | [] | false | [] | false | pytest | false | [] | true | aff55a502d1747be515ab9f2e232dbb5d736c61d | 963e6406d8135b72e7602d5665c35c9ea31349a8 | |||
v1.0 | complete | Taco | Taco_79031_C | from typing import List
def is_prime(n: int) -> bool:
"""Helper function to check if a number is prime."""
if n <= 1:
return False
if n <= 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:
... | 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 smallest_prime_greater_than(N):
candid... | from solution import smallest_prime_greater_than
def test_example_1():
assert smallest_prime_greater_than(10) == 11
def test_example_2():
assert smallest_prime_greater_than(14) == 17
def test_on_prime_input():
assert smallest_prime_greater_than(17) == 19
def test_large_input():
assert smallest_prime... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def smallest_prime_greater_than(N):",
"function_name": "smallest_prime_greater_than",
"parameter_list": "(N)"
}... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def 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_0 | {
"original_instruction": "Amelia loves prime numbers and enjoys finding interesting properties about them. One day, her friend challenged her to find the smallest prime number larger than a given integer. Amelia finds this an intriguing problem and decides to write a program to solve it quickly.\n\n-----Task-----\nY... | 0.828973 | Taco_79031 | C | [
"is_prime",
"smallest_prime_greater_than"
] | 2 | [
[
"smallest_prime_greater_than",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 52125d733e0dfdc42fa44ab95b90efb607e3ebfc | 61e4a683c00bc5c50c386fe31b8b2ffee6c6189b | |||
v1.0 | complete | Taco | Taco_78265_C | from typing import List, Tuple, Union
def minimum_moves_to_charging(N: int, W: int, H: int, drones: List[Tuple[int, int, int]], stations: List[Tuple[int, int]]) -> Union[int, str]:
""" Calculate the minimum number of moves required for all drones to reach a charging station.
If it is impossible for some dr... | from collections import deque
def bfs_shortest_distance(w, h, stations):
directions = [(1, 0), (-1, 0), (0, 1), (0, -1)]
# Initialize distances with -1 (unreachable)
distances = [[-1] * w for _ in range(h)]
queue = deque()
for x, y in stations:
queue.append((x, y))
distances[y-... | from solution import minimum_moves_to_charging
def test_example_1():
drones = [(1, 1, 3), (4, 4, 2), (5, 5, 10)]
stations = [(2, 2), (4, 3)]
assert minimum_moves_to_charging(3, 5, 5, drones, stations) == 3
def test_example_2():
drones = [(1, 1, 1), (3, 3, 5)]
stations = [(2, 2)]
assert minimum... | [
{
"docstring": null,
"function_declaration": "def bfs_shortest_distance(w, h, stations):",
"function_name": "bfs_shortest_distance",
"parameter_list": "(w, h, stations)"
},
{
"docstring": null,
"function_declaration": "def minimum_moves_to_charging(N, W, H, drones, stations):",
"func... | [
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\nimport sys\n\ndef minimum_moves(drones, stations, W, H):\n def bfs(visited, queue):\n while queue:\n x, y, dist... | trial_gpt4o_3 | {
"original_instruction": "A fleet of drones needs to be recharged using charging stations. Each drone has a specific amount of initial battery life. A drone can move to a neighboring cell (east, west, north, or south), consuming 1 unit of battery for each move. If a drone runs out of battery, it cannot move anymore.... | 0.580355 | Taco_78265 | C | [
"bfs_shortest_distance",
"minimum_moves_to_charging"
] | 2 | [
[
"minimum_moves_to_charging",
"bfs_shortest_distance"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 410af6bc08b7b6b04e45fe03fe63d7145dbdb5ec | 61ccde9dfd4eb990682d962e0c627ccd910db293 | |||
v1.0 | complete | Taco | Taco_77763_C | from typing import List, Tuple
def minimum_cost_to_connect_all_cities(n: int, m: int, roads: List[Tuple[int, int, int]]) -> int:
""" Find the minimum possible cost to connect all cities in the given kingdom.
If it is impossible to connect all cities, return "IMPOSSIBLE".
Args:
n (int):... | def find(parent, i):
if parent[i] == i:
return i
return find(parent, parent[i])
def union(parent, rank, x, y):
root_x = find(parent, x)
root_y = find(parent, y)
if rank[root_x] < rank[root_y]:
parent[root_x] = root_y
elif rank[root_x] > rank[root_y]:
parent[root_y]... | def test_sample1():
n = 4
m = 5
roads = [
(1, 2, 1),
(1, 3, 4),
(1, 4, 3),
(2, 3, 2),
(3, 4, 5)
]
assert minimum_cost_to_connect_all_cities(n, m, roads) == 6
def test_sample2():
n = 3
m = 1
roads = [
(1, 2, 5)
]
assert minimum_cost... | [
{
"docstring": null,
"function_declaration": "def find(parent, i):",
"function_name": "find",
"parameter_list": "(parent, i)"
},
{
"docstring": null,
"function_declaration": "def union(parent, rank, x, y):",
"function_name": "union",
"parameter_list": "(parent, rank, x, y)"
},
... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_min_cost_to_connect_all_cities(n, m, roads):\n \"\"\"\n Finds the minimum cost to connect all cities or returns \"IMPOSSIBLE\" if not possible.\n ... | trial_gpt4o_1 | {
"original_instruction": "In a certain kingdom, there are n cities connected by m bidirectional roads. Each road connects two different cities and has a travel cost associated with it. The king wants to select a subset of these roads to build a special infrastructure project that satisfies the following conditions:\... | 0.683662 | Taco_77763 | C | [
"find",
"union",
"minimum_cost_to_connect_all_cities"
] | 3 | [
[
"minimum_cost_to_connect_all_cities",
"find"
],
[
"minimum_cost_to_connect_all_cities",
"union"
],
[
"union",
"find"
]
] | 3 | [] | false | [] | false | pytest | false | [] | true | 476533fae306fc4ce83d973134a71d263aa4aa6d | 6d2c17579955d16630e9d443298d0cee1b100f9c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.