version
stringclasses
1 value
style
stringclasses
2 values
subset
stringclasses
12 values
question_id
stringlengths
9
23
question
stringlengths
27
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.45k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
7
21
variant
stringclasses
2 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
harness_functions
listlengths
0
3
structural_wrapper
bool
1 class
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
1 value
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
instruct
Taco
Taco_90327_I
A music streaming service has implemented a system to create custom playlists based on user preferences. The service collects multiple songs the user is interested in, determined by their recent listens. Each song is represented as a string of lowercase letters, and all songs have the same length. The service allows cr...
import itertools def factorial(n): if n == 0 or n == 1: return 1 return n * factorial(n-1) def calculate_playlists_count(song): k = len(song) all_permutations = set([''.join(p) for p in itertools.permutations(song)]) return len(all_permutations) def custom_playlists(n, k, songs): resu...
from solution import custom_playlists def test_single_song(): assert custom_playlists(1, 4, ['abcd']) == [24] # 4! = 24 def test_multiple_songs(): assert custom_playlists(3, 4, ['abcd', 'aabb', 'wxyz']) == [24, 6, 24] def test_repeated_chars(): assert custom_playlists(1, 3, ['aaa']) == [1] # Only one c...
[ { "docstring": null, "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def calculate_playlists_count(song):", "function_name": "calculate_playlists_count", "parameter_list": "(song)"...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef distinct_playlists(songs):\n \"\"\"\n Given a list of songs, returns the number of distinct playlists that can be c...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00090327", "row_id": 90327, "seed_ids": "[18363]" }
0.6478
Taco_90327
I
[ "factorial", "calculate_playlists_count", "custom_playlists", "main" ]
4
[ [ "custom_playlists", "calculate_playlists_count" ] ]
1
[]
false
[]
false
pytest
true
[]
true
65ae8ebb18bf9f29d57f21dc3116a7a70cc68de8
0ca1ca3c139e74d0c29420df33a8fa4c2a244a07
v1.0
instruct
Taco
Taco_90343_I
Snuke is participating in a programming competition where he needs to solve the "Optimal Path in Grid" problem. The problem involves an N x M grid, where each cell contains a positive integer indicating the cost of stepping into that cell. Snuke starts at the top-left corner of the grid (1,1) and needs to reach the bo...
def min_path_cost(grid): """ Returns the minimum cost required to travel from the top-left to the bottom-right corner of the grid. """ n = len(grid) m = len(grid[0]) # Create a dp table to store the minimum cost to each cell dp = [[0] * m for _ in range(n)] # Initialize the top...
from solution import min_path_cost def test_min_path_cost_3x3(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ] assert min_path_cost(grid) == 21 def test_min_path_cost_4x4(): grid = [ [1, 3, 1, 2], [3, 4, 2, 1], [1, 2, 3, 1], [3, 1, 2, 1], ] ...
[ { "docstring": "Returns the minimum cost required to travel from the top-left to the bottom-right corner of the grid.", "function_declaration": "def min_path_cost(grid):", "function_name": "min_path_cost", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def re...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_path_cost(grid):\n \"\"\"\n Returns the minimum cost required to travel from the top-left to the bottom-right corner of the grid.\n \"\"\"\n n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00090343", "row_id": 90343, "seed_ids": "[1755]" }
0.693376
Taco_90343
I
[ "min_path_cost", "read_input", "solve" ]
3
[ [ "solve", "min_path_cost" ], [ "solve", "read_input" ] ]
2
[ "read_input" ]
false
[]
false
pytest
true
[]
true
d77202b4077ac102525bf2d8e366499973de1cf4
87d7b28399f6c8f103a5e63a18296b105feb5b06
v1.0
instruct
Taco
Taco_90351_I
Petya is enthusiastic about prime numbers and has recently been pondering over rectangular grids. He stumbled upon a puzzle involving a grid filled with prime numbers and became intrigued. Given an n x m grid filled with integers, write a program that finds the largest prime number within each row. If a row does not ...
def is_prime(num): """ Check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def largest_prime_in_r...
from solution import process_grid def test_example_case(): grid = [ [10, 15, 3, 7], [5, 6, 8, 13], [1, 4, 8, 6], ] assert process_grid(3, 4, grid) == [7, 13, -1] def test_single_row_with_primes(): grid = [ [10, 11, 2, 7], ] assert process_grid(1, 4, grid) == [11...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds the largest prime number within each row of the grid.\nIf a row does not contain any prime number, return -1 for that ro...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090351", "row_id": 90351, "seed_ids": "[14302]" }
0.59054
Taco_90351
I
[ "is_prime", "largest_prime_in_rows", "process_grid" ]
3
[ [ "largest_prime_in_rows", "is_prime" ], [ "process_grid", "largest_prime_in_rows" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f3c4457d70fcc29f04f229317f51ba3bea459aca
930b90de8dc3e32ad5e7d9dd3f239a2acabf874b
v1.0
instruct
Taco
Taco_90356_I
# Task Write a function that takes an integer as input and returns a list of strings representing the Roman numeral representation of all numbers from 1 to that integer (inclusive). Roman numerals are represented by the following symbols: - I -> 1 - V -> 5 - X -> 10 - L -> 50 - C -> 100 - D -> 500 - M -> 1000 ...
def int_to_roman(num): """ Convert an integer to a Roman numeral. """ val = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ] syms = [ "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" ...
from solution import to_roman def test_to_roman(): assert to_roman(1) == ["I"] assert to_roman(3) == ["I", "II", "III"] assert to_roman(5) == ["I", "II", "III", "IV", "V"] assert to_roman(10) == ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"] def test_to_roman_edge_cases(): assert to...
[ { "docstring": "Convert an integer to a Roman numeral.", "function_declaration": "def int_to_roman(num):", "function_name": "int_to_roman", "parameter_list": "(num)" }, { "docstring": "Returns a list of strings representing the Roman numeral representation\nof all numbers from 1 to n (inclus...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def to_roman(n):\n \"\"\"\n Returns a list of Roman numeral representations for all numbers from 1 to n (inclusive).\n \"\"\"\n def int_to_roman(num):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090356", "row_id": 90356, "seed_ids": "[14803]" }
0.692095
Taco_90356
I
[ "int_to_roman", "to_roman" ]
2
[ [ "to_roman", "int_to_roman" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0751af16bbd9f1f7c25c29d7417828cd2a308f61
1b605d6133ad006c955b08016e7853f1fe2b6ed7
v1.0
instruct
Taco
Taco_90364_I
You are given an array of integers. Your task is to find the largest number that can be constructed by concatenating all the integers in the array. Your function should return this largest number as a string. Note: - Each integer in the array is non-negative. - The array may contain integers with different numbers of...
def compare(x, y): if x + y > y + x: return -1 else: return 1 def largest_number(nums): nums = list(map(str, nums)) for i in range(len(nums)): for j in range(len(nums) - 1, i, -1): if compare(nums[j-1], nums[j]) > 0: nums[j], nums[j-1] = nums[j-1...
from solution import largest_number def test_example_cases(): assert largest_number([10, 2]) == "210" assert largest_number([3, 30, 34, 5, 9]) == "9534330" def test_single_element(): assert largest_number([1]) == "1" assert largest_number([0]) == "0" def test_leading_zeros(): assert largest_numbe...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_number(nums):", "function_name": "largest_number", "parameter_list": "(nums)" } ]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compare(x, y):\n \"\"\"\n Compares two numbers x and y for sorting in a way that constructs the largest possible number.\n \"\"\"\n return (x + y) ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090364", "row_id": 90364, "seed_ids": "[15819]" }
0.727998
Taco_90364
I
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
465b9ec5eeb2a6972df0cecd84eabc07963b8e52
78566965e0936c9dcdc926b9844e064b6053de55
v1.0
instruct
Taco
Taco_90376_I
Chef is organizing a marathon where $T$ teams participate. Each team has $N$ members. At the end of the marathon, each team receives a score based on the performance of its members. The score of a team is calculated as follows: - Consider the performance scores of all members of the team. - Find the median score among ...
def find_median(scores): scores.sort() n = len(scores) mid = n // 2 if n % 2 == 0: # Even number of elements return (scores[mid - 1] + scores[mid]) / 2 else: # Odd number of elements return scores[mid] def sort_teams_by_median(T, N, teams_scores): teams_with_medians = [] f...
from solution import find_median, sort_teams_by_median def test_find_median(): assert find_median([50, 80, 90, 70]) == 75.0 assert find_median([60, 40, 100, 50]) == 55.0 assert find_median([30, 20, 60, 10]) == 25.0 assert find_median([1, 2, 3]) == 2 assert find_median([5, 7, 9, 3, 1]) == 5 asse...
[ { "docstring": null, "function_declaration": "def find_median(scores):", "function_name": "find_median", "parameter_list": "(scores)" }, { "docstring": null, "function_declaration": "def sort_teams_by_median(T, N, teams_scores):", "function_name": "sort_teams_by_median", "paramet...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_median(scores):\n scores.sort()\n n = len(scores)\n mid = n // 2\n if n % 2 == 0: # Even number of elements\n return (scores[mid - 1] ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00090376", "row_id": 90376, "seed_ids": "[1583]" }
0.653813
Taco_90376
I
[ "find_median", "sort_teams_by_median", "marathon" ]
3
[ [ "marathon", "sort_teams_by_median" ], [ "sort_teams_by_median", "find_median" ] ]
2
[]
false
[]
false
pytest
true
[]
true
15e2a25f5d5f920dca618f3786e0d9f745ec2f3b
4e15217dffcf293f3f4b35ddcee5a3c9edc19a98
v1.0
instruct
Taco
Taco_90453_I
Given a large array of integers, implement a program to efficiently compute the number of distinct prime factors for each element in the array and print the maximum number of distinct prime factors present in any single element. ### Input Format - The first line contains an integer, $n$, denoting the number of element...
from collections import defaultdict def sieve_of_eratosthenes(limit): primes = [True] * (limit + 1) p = 2 while p * p <= limit: if primes[p] == True: for i in range(p * p, limit + 1, p): primes[i] = False p += 1 prime_numbers = [p for p in range(2, limit + 1)...
def test_sieve_of_eratosthenes(): from solution import sieve_of_eratosthenes assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_get_prime_factors_count(): from solution import get_prime_factors_count, sieve_of_eratosthenes prim...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def get_prime_factors_count(num, primes):", "function_name": "get_prime_factors_cou...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve(n):\n \"\"\"\n Returns a list `prime` where prime[i] is True if i is a prime number, False otherwise.\n \"\"\"\n prime = [True] * (n + 1)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090453", "row_id": 90453, "seed_ids": "[3850]" }
0.646735
Taco_90453
I
[ "sieve_of_eratosthenes", "get_prime_factors_count", "max_distinct_prime_factors", "main" ]
4
[ [ "max_distinct_prime_factors", "get_prime_factors_count" ], [ "max_distinct_prime_factors", "sieve_of_eratosthenes" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c81fc09beba439f1a31d32be318446f833b7c91e
e1d86341656c04462a435440c4010f1fd9dc4aee
v1.0
instruct
Taco
Taco_90489_I
You are given a list of integers. For each integer in the list, determine the smallest positive integer that cannot be represented as the subset sum of some of its prefixes. INPUT: First line contains an integer t, the number of test cases. The next t lines each contain a single integer n, the length of the list, fol...
def smallest_nonrepresentable_prefix_sum(arr): arr.sort() smallest_missing_sum = 1 for num in arr: if num > smallest_missing_sum: break smallest_missing_sum += num return smallest_missing_sum def solve(t, cases): results = [] for case in cases: n, a...
from solution import smallest_nonrepresentable_prefix_sum, solve, parse_input def test_smallest_nonrepresentable_prefix_sum(): assert smallest_nonrepresentable_prefix_sum([1, 2, 3, 10, 20]) == 7 assert smallest_nonrepresentable_prefix_sum([1, 1, 1, 1]) == 5 assert smallest_nonrepresentable_prefix_sum([1, 2...
[ { "docstring": null, "function_declaration": "def smallest_nonrepresentable_prefix_sum(arr):", "function_name": "smallest_nonrepresentable_prefix_sum", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def solve(t, cases):", "function_name": "solve", "par...
[ 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 smallest_missing_positive_integer(test_cases):\n results = []\n for test_case in test_cases:\n _, numbers = test_case[0], test_case[1:]\n n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090489", "row_id": 90489, "seed_ids": "[22979]" }
0.663955
Taco_90489
I
[ "smallest_nonrepresentable_prefix_sum", "solve", "parse_input" ]
3
[ [ "solve", "smallest_nonrepresentable_prefix_sum" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
3fc3c151169ce3d2c9f7809a3a97b9ea7e941ee3
09c1b4853719cdcba1f7c93dfaf53ed2a4eb2f4a
v1.0
instruct
Taco
Taco_90508_I
In a distant village, there is a magical well with an infinite amount of water. Every day, the villagers fetch water from the well into jars. Each villager receives a specific number of jars, and the total number of jars fetched in a day forms a sequence. Unfortunately, at the end of each day, many villagers forget ho...
def find_sequences(total, current_sequence, result): """ Helper function to find all distinct sequences of positive integers that sum up to `total`. """ if total == 0: result.append(current_sequence[:]) return start = current_sequence[-1] if current_sequence else 1 for i in rang...
from solution import find_all_sequences def test_find_all_sequences_for_5(capfd): find_all_sequences(5) out, _ = capfd.readouterr() assert out.strip() == "1 1 1 1 1\n1 1 1 2\n1 1 3\n1 2 2\n1 4\n2 3\n5" def test_find_all_sequences_for_1(capfd): find_all_sequences(1) out, _ = capfd.readouterr() ...
[ { "docstring": "Helper function to find all distinct sequences of positive integers that sum up to `total`.", "function_declaration": "def find_sequences(total, current_sequence, result):", "function_name": "find_sequences", "parameter_list": "(total, current_sequence, result)" }, { "docstri...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def partition(n):\n def helper(n, max_num, path, res):\n if n == 0:\n res.append(path)\n return\n for i in range(1, max_num ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00090508", "row_id": 90508, "seed_ids": "[22862]" }
0.650596
Taco_90508
I
[ "find_sequences", "find_all_sequences" ]
2
[ [ "find_all_sequences", "find_sequences" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a707f5e4bf4b4578e8fbe3bc4e5de3ca9a018f50
aef3a0b19ad4954a2bb175c0c7f0ed23043f62b7
v1.0
instruct
Taco
Taco_90514_I
Write a function to determine if a given date is valid or not. A valid date is in "YYYY-MM-DD" format where: - YYYY is a four-digit number representing the year. The range can be from 0000 to 9999. - MM is a two-digit number representing the month with values from 01 (January) to 12 (December). - DD is a two-digit num...
def is_valid_date(date_str): """ Determines if a given date string is valid. """ # Split the date into year, month, and day parts = date_str.split('-') if len(parts) != 3: return False year_str, month_str, day_str = parts # Check if all parts are of the correct length if le...
from solution import is_valid_date def test_valid_date(): assert is_valid_date("2020-02-29") == True # Leap year assert is_valid_date("2019-11-30") == True # Normal valid date def test_invalid_date(): assert is_valid_date("2019-02-29") == False # Not leap year assert is_valid_date("0000-00-00") == ...
[ { "docstring": "Determines if a given date string is valid.", "function_declaration": "def is_valid_date(date_str):", "function_name": "is_valid_date", "parameter_list": "(date_str)" }, { "docstring": "Determines if a given year is a leap year.", "function_declaration": "def is_leap_year...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_date(date_str):\n \"\"\"\n Determines if a given date string is valid.\n \"\"\"\n # Split the date into year, month, and day\n parts = ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00090514", "row_id": 90514, "seed_ids": "[14820]" }
0.824754
Taco_90514
I
[ "is_valid_date", "is_leap_year" ]
2
[ [ "is_valid_date", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
24a06da64b26b5435456b91de6b3fd6bc5296565
3ca83f70e46516cbbcbbf571fb927f52846f39cc
v1.0
instruct
Taco
Taco_90535_I
### The Story: Anita is a librarian who needs your help to organize a huge stack of books by their identifiers. Each book has a unique identifier number. To make her task easier, she wants you to sort a list of these book identifiers. The catch is, she wants to maintain a special order: Any number that is a perfect squ...
import math def is_perfect_square(n): """ Check if a number is a perfect square. """ root = int(math.sqrt(n)) return n == root * root def organize_books(book_ids): """ Organize the book identifiers such that perfect squares come first, followed by non-perfect squares sorted in ascendin...
from solution import organize_books def test_organize_books_all_perfect_squares(): assert organize_books([1, 4, 9, 16, 25]) == [1, 4, 9, 16, 25] def test_organize_books_no_perfect_squares(): assert organize_books([3, 5, 7, 8, 10]) == [3, 5, 7, 8, 10] def test_organize_books_mixed(): assert organize_books...
[ { "docstring": "Check if a number is a perfect square.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Organize the book identifiers such that perfect squares come first,\nfollowed by non-perfect squares ...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(n):\n \"\"\"Check if a number is a perfect square.\"\"\"\n return n == int(math.sqrt(n)) ** 2\n\ndef organize_books(book...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00090535", "row_id": 90535, "seed_ids": "[849]" }
0.60253
Taco_90535
I
[ "is_perfect_square", "organize_books" ]
2
[ [ "organize_books", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
346662a56f8ae053252e7bd21e4527bd964d85a8
7b627f55f88d2bb76e0195fc3fe658a1918a5467
v1.0
instruct
Taco
Taco_90548_I
Given an integer N, write a function to find the smallest prime number greater than N. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Example 1: Input: N = 10 Output: 11 Explanation: The prime numbers greater than 10 are 11, 13, 17, etc. Therefore, the smallest ...
def is_prime(x): """ Helper function to check if a number is prime. """ if x <= 1: return False if x <= 3: return True if x % 2 == 0 or x % 3 == 0: return False i = 5 while i * i <= x: if x % i == 0 or x % (i + 2) == 0: return False i +...
from solution import next_prime def test_next_prime_after_10(): assert next_prime(10) == 11 def test_next_prime_after_31(): assert next_prime(31) == 37 def test_next_prime_after_0(): assert next_prime(0) == 2 def test_next_prime_after_1(): assert next_prime(1) == 2 def test_next_prime_after_50(): ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(x):", "function_name": "is_prime", "parameter_list": "(x)" }, { "docstring": "Function to find the smallest prime number greater than N.", "function_declaration": "def next_prime(N):", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00090548", "row_id": 90548, "seed_ids": "[1380]" }
0.622444
Taco_90548
I
[ "is_prime", "next_prime" ]
2
[ [ "next_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02e0f95f4158f28211b7835aa051bda8d5e90f5b
886f098c4ae5db14b881f75259814acbb891ee19
v1.0
instruct
Taco
Taco_90561_I
The year is 3022 and the world is now governed by a robotic council. Communication between the robots happens through secure encrypted messages. Each robot is identified by a unique ID, represented by an alphanumeric string. Every robot can send a message to any other robot. Each message has a priority level associat...
def highest_priority_message(logs, robot_id, hour): """ Finds the highest priority message for the given robot_id within the specified hour. Parameters: logs (list): List of message logs as tuples (sender_id, receiver_id, priority_level). robot_id (str): The robot's unique identifier. hour (int...
from solution import process_logs def test_sample_input(): input_data = """2 robot007 3 5 robotA robotB 4 robotB robot007 10 robot007 robotC 8 alpha 2 2 alpha beta 5 gamma alpha 3""" expected_output = ["robotB robot007 10", "alpha beta 5"] assert process_logs(input_data) == expected_output def test_n...
[ { "docstring": "Finds the highest priority message for the given robot_id within the specified hour.\n\nParameters:\nlogs (list): List of message logs as tuples (sender_id, receiver_id, priority_level).\nrobot_id (str): The robot's unique identifier.\nhour (int): The hour during which the messages were sent.\n\...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def highest_priority_message(test_cases):\n results = []\n\n for case in test_cases:\n robot_id, n, h, messages = case\n highest_priority = -1\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00090561", "row_id": 90561, "seed_ids": "[2370]" }
0.541037
Taco_90561
I
[ "highest_priority_message", "process_test_case", "process_logs" ]
3
[ [ "process_logs", "process_test_case" ], [ "process_test_case", "highest_priority_message" ] ]
2
[ "process_test_case" ]
false
[]
false
pytest
true
[]
true
cb791aaf8f041890265d1227c154747eb4ad86d1
9e3b9eb8453aaa3a8277de271204557e7a81671a
v1.0
instruct
Taco
Taco_90573_I
You've been hired to develop a basic file handling utility that processes log files. The task is to remove duplicate entries and preserve the order of the first occurrences of each log entry. A log file contains multiple lines, each representing a log entry. The file can have duplicate log entries across different lin...
def remove_duplicate_logs(logs): """ Removes duplicate log entries from the list while maintaining the order of their first occurrence. """ seen = set() unique_logs = [] for log in logs: if log not in seen: unique_logs.append(log) seen.add(log) ...
from solution import remove_duplicate_logs, process_log_file def test_remove_duplicate_logs(): logs = [ "Started processing", "Started processing", "Completed processing", "Database connection established", "Started processing", "Database connection closed" ] ...
[ { "docstring": "Removes duplicate log entries from the list while maintaining the order of their first occurrence.", "function_declaration": "def remove_duplicate_logs(logs):", "function_name": "remove_duplicate_logs", "parameter_list": "(logs)" }, { "docstring": "Processes the log file cont...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def remove_duplicate_logs(logs):\n \"\"\"\n Removes duplicate log entries while preserving the order of their first occurrence.\n \n :param logs: List ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090573", "row_id": 90573, "seed_ids": "[6533]" }
0.499408
Taco_90573
I
[ "remove_duplicate_logs", "process_log_file" ]
2
[ [ "process_log_file", "remove_duplicate_logs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
61492630b52163f43faf17ef369dde88ddf8a36a
39a4209f8d5239fa9f9be0aacb7af32b1324ae45
v1.0
instruct
Taco
Taco_90613_I
You are part of a research team studying the behavior of molecules in a container. Each molecule is represented by a point in a 2D plane, and molecules interact with one another through a process called "magnetic bonding." Two molecules will form a magnetic bond if they are within a certain distance, d, from each other...
import math def euclidean_distance(x1, y1, x2, y2): return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) def find_bonded_molecules(n, d, molecules): bonded = [False] * n queue = [0] bonded[0] = True count = 1 while queue: current = queue.pop(0) for i in range(n): if n...
from solution import process_input def test_dataset_1(): input_str = "3 10\n1.000 1.000\n2.000 2.000\n15.000 15.000\n0 0" expected_output = [2] assert process_input(input_str) == expected_output def test_dataset_2(): input_str = "5 7\n3.000 3.000\n10.000 10.000\n3.500 4.000\n17.000 17.000\n1.000 1.500...
[ { "docstring": null, "function_declaration": "def euclidean_distance(x1, y1, x2, y2):", "function_name": "euclidean_distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": null, "function_declaration": "def find_bonded_molecules(n, d, molecules):", "function_name": "find_bo...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_bonded_molecules(data):\n from math import sqrt\n\n def distance(p1, p2):\n return sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\n \n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090613", "row_id": 90613, "seed_ids": "[23916]" }
0.622438
Taco_90613
I
[ "euclidean_distance", "find_bonded_molecules", "process_input" ]
3
[ [ "find_bonded_molecules", "euclidean_distance" ], [ "process_input", "find_bonded_molecules" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
db259929a4d275da1f46e8238c246f7b7e2e23b3
081163105fb247b2ef4c846b73c6f5bc14ba8c70
v1.0
instruct
Taco
Taco_90663_I
A drone delivery company wants to optimize their flight routes. Each route is defined by starting and ending coordinates in a 2D plane, and the company has a list of such routes they need to analyze. Two routes are considered redundant if their paths overlap completely or partially. Your task is to find the number of u...
def find_unique_routes(routes): def on_segment(p, q, r): """Check if point q lies on line segment pr""" if q[0] <= max(p[0], r[0]) and q[0] >= min(p[0], r[0]) and q[1] <= max(p[1], r[1]) and q[1] >= min(p[1], r[1]): return True return False def orientation(p, q, r): ...
def test_case_1(): assert number_of_unique_routes(5, [0, 0, 2, 2, 3, 3, 5, 5, 0, 0, 2, 2, 6, 6, 8, 8, 1, 1, 4, 4]) == 3 def test_case_2(): # Non-overlapping routes assert number_of_unique_routes(3, [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 3 def test_case_3(): # All routes are the same assert numbe...
[ { "docstring": null, "function_declaration": "def find_unique_routes(routes):", "function_name": "find_unique_routes", "parameter_list": "(routes)" }, { "docstring": null, "function_declaration": "def number_of_unique_routes(N, coordinates):", "function_name": "number_of_unique_route...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from shapely.geometry import LineString\n\ndef count_unique_routes(n, coordinates):\n \"\"\"\n Returns the number of unique, non-overlapping routes.\n \n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00090663", "row_id": 90663, "seed_ids": "[18893]" }
0.657565
Taco_90663
I
[ "find_unique_routes", "number_of_unique_routes" ]
2
[ [ "number_of_unique_routes", "find_unique_routes" ] ]
1
[]
false
[]
false
pytest
false
[]
true
121789f08ae3e7efaf4cd20e0528ec63d309d574
82d61221c0045a52a64f9848e7b06a729523593d
v1.0
instruct
Taco
Taco_90676_I
Alice is hosting a coding contest and wants to distribute a certain number of problems to the participants in a fair manner. To make it fair, she decides that no two participants should get a difference of more than one problem. She wants to determine whether it is possible to distribute all the problems according to t...
def can_distribute_problems_fairly(t, test_cases): results = [] for case in test_cases: n, p = case if (p % n == 0) or (p % n == n - 1): results.append("YES") else: results.append("NO") return results # Function to preprocess input and call function def solve...
from solution import can_distribute_problems_fairly def test_case_1(): t = 3 test_cases = [(3, 8), (2, 5), (4, 10)] assert can_distribute_problems_fairly(t, test_cases) == ["YES", "YES", "NO"] def test_case_2(): t = 2 test_cases = [(1, 1), (100, 10000)] assert can_distribute_problems_fairly(t,...
[ { "docstring": null, "function_declaration": "def can_distribute_problems_fairly(t, test_cases):", "function_name": "can_distribute_problems_fairly", "parameter_list": "(t, test_cases)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "par...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_distribute_fairly(t, test_cases):\n results = []\n for case in test_cases:\n n, p = case\n if p // n == p // n + 1 or p // n == p // n:...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00090676", "row_id": 90676, "seed_ids": "[8917]" }
0.659203
Taco_90676
I
[ "can_distribute_problems_fairly", "solve" ]
2
[ [ "solve", "can_distribute_problems_fairly" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6eec5f0bca88f78680ebcf0bf952c974de84a387
37f78722a3fe6a4a1c06410f4f972c04fc115133
v1.0
instruct
Taco
Taco_90715_I
Anna wants to design a recursive function to solve a mathematical problem. The function takes an integer $n$ and returns the sum of the digits of $n$ combined with the value of $n$ minus the sum of its digits. She denotes this function as $f(n)$, where $f(n) = n + g(n)$, and $g(n)$ is a function that computes the sum o...
def sum_of_digits(n): """ Returns the sum of the digits of the integer n. """ return sum(int(digit) for digit in str(n)) def f(n): """ Returns the sum of the digits of n combined with the value of n minus the sum of its digits. f(n) = n + g(n) """ return n + sum_of_digits(n)
from solution import sum_of_digits, f def test_sum_of_digits(): assert sum_of_digits(123) == 6 assert sum_of_digits(0) == 0 assert sum_of_digits(2021) == 5 assert sum_of_digits(1000000) == 1 assert sum_of_digits(987654) == 39 def test_f(): assert f(123) == 129 assert f(0) == 0 # should not...
[ { "docstring": "Returns the sum of the digits of the integer n.", "function_declaration": "def sum_of_digits(n):", "function_name": "sum_of_digits", "parameter_list": "(n)" }, { "docstring": "Returns the sum of the digits of n combined with the \nvalue of n minus the sum of its digits.\nf(n)...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sum_of_digits(n):\n \"\"\"\n Returns the sum of the digits of the integer n.\n \"\"\"\n return sum(int(digit) for digit in str(n))\n\ndef f(n):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00090715", "row_id": 90715, "seed_ids": "[3178]" }
0.698762
Taco_90715
I
[ "sum_of_digits", "f" ]
2
[ [ "f", "sum_of_digits" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c7441c1c63fc460b73346991077b870a34065ff4
9a24477b8b53643d63e8faf7d3684573d2c42a16
v1.0
instruct
Taco
Taco_90901_I
The city of Algoville is holding a marathon event. You have been tasked with timing the runners. During the event, you will receive a series of timestamps that indicate when a runner crosses the start line and when they finish. Write a program to compute the total time each runner took to complete the marathon. The ti...
from datetime import datetime def time_difference(start, finish): """ Calculate the difference in seconds between start and finish times. Both start and finish are strings in "HH:MM:SS" format. """ FMT = '%H:%M:%S' # Time format tdelta = datetime.strptime(finish, FMT) - datetime.strptime(start...
from solution import marathon_times def test_marathon_times(): test_cases = [ (3, [("08:00:00", "11:00:00"), ("07:30:00", "10:45:00"), ("09:15:00", "12:45:00")]) ] expected_output = [ [10800, 11700, 12600] ] assert marathon_times(test_cases) == expected_output def test_ed...
[ { "docstring": "Calculate the difference in seconds between start and finish times.\nBoth start and finish are strings in \"HH:MM:SS\" format.", "function_declaration": "def time_difference(start, finish):", "function_name": "time_difference", "parameter_list": "(start, finish)" }, { "docstr...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef time_difference(start, finish):\n \"\"\"\n Calculate the difference in seconds between start and finish times.\n Both...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00090901", "row_id": 90901, "seed_ids": "[19042]" }
0.613914
Taco_90901
I
[ "time_difference", "marathon_times", "read_input" ]
3
[ [ "marathon_times", "time_difference" ] ]
1
[ "read_input" ]
false
[]
false
pytest
true
[]
true
8cf79971f75a66930af87e98bd8a013d4bea70bb
9d1f8ff45ba881f1f3e4b00c821989959b425379
v1.0
instruct
Taco
Taco_91007_I
You are given an array which contains integers and an integer value K. Reverse the array from 0 to K-1 and then reverse the array from K to N-1. Finally, reverse the whole array of size N. Example 1: Input: N = 5, K = 3 A[] = {1, 2, 3, 4, 5} Output: 4 5 1 2 3 Example 2: Input: N = 7, K = 4 A[] = {1, 2, 3, 4, 5, 6, 7}...
def reverse(arr, start, end): while start < end: arr[start], arr[end] = arr[end], arr[start] start += 1 end -= 1 def specialReverse(N, K, A): """ Reverse the array from 0 to K-1 and then reverse the array from K to N-1. Finally, reverse the whole array of size N. """ # R...
from solution import specialReverse def test_specialReverse_example1(): N = 5 K = 3 A = [1, 2, 3, 4, 5] expected_output = [4, 5, 1, 2, 3] assert specialReverse(N, K, A) == expected_output def test_specialReverse_example2(): N = 7 K = 4 A = [1, 2, 3, 4, 5, 6, 7] expected_output = [5...
[ { "docstring": null, "function_declaration": "def reverse(arr, start, end):", "function_name": "reverse", "parameter_list": "(arr, start, end)" }, { "docstring": "Reverse the array from 0 to K-1 and then reverse the array from K to N-1.\nFinally, reverse the whole array of size N.", "fun...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def specialReverse(arr, N, K):\n \"\"\"\n Reverses the array from 0 to K-1 and then from K to N-1, finally reverses the whole array.\n \"\"\"\n if not ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00091007", "row_id": 91007, "seed_ids": "[11056]" }
0.648425
Taco_91007
I
[ "reverse", "specialReverse" ]
2
[ [ "specialReverse", "reverse" ] ]
1
[]
false
[]
false
pytest
true
[]
true
68f9268ab7c9130db4bc3e072bd5f41ca38ef9a0
11a880967b2f673e124d59b8ffe60248c999de61
v1.0
instruct
Taco
Taco_91021_I
Alex is a delivery robot who has been assigned a task to deliver packages in a warehouse organized as an m x n grid. The robot starts at the top-left corner (grid[0][0]) and needs to reach the bottom-right corner (grid[m-1][n-1]) to deliver a package. The grid has cells that are either empty (0) or have obstacles (1). ...
from collections import deque def shortest_path(grid): """ Returns the length of the shortest path from top-left corner to bottom-right corner in a grid avoiding obstacles, or -1 if no such path exists. """ m = len(grid) n = len(grid[0]) if grid[0][0] == 1 or grid[m-1][n-1] == 1: ...
def test_warehouse_delivery(): grid1 = [ [0, 0, 1], [0, 0, 1], [1, 0, 0] ] assert warehouse_delivery(3, 3, grid1) == 5 grid2 = [ [0, 0, 1], [1, 1, 1], [1, 0, 0] ] assert warehouse_delivery(3, 3, grid2) == -1 grid3 = [ [0, 0, 0], ...
[ { "docstring": "Returns the length of the shortest path from top-left corner to bottom-right corner\nin a grid avoiding obstacles, or -1 if no such path exists.", "function_declaration": "def shortest_path(grid):", "function_name": "shortest_path", "parameter_list": "(grid)" }, { "docstring"...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path(grid):\n \"\"\"\n Determines the shortest path length from the top-left corner\n to the bottom-right co...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091021", "row_id": 91021, "seed_ids": "[7831]" }
0.709642
Taco_91021
I
[ "shortest_path", "warehouse_delivery" ]
2
[ [ "warehouse_delivery", "shortest_path" ] ]
1
[]
false
[]
false
pytest
false
[]
true
e6ca409c43fda3b1d7f08ad5582f00d9b13a4c77
39ac81de43022abc3fb0b53d4906be9502ae9a1a
v1.0
instruct
Taco
Taco_91051_I
Alice loves to create new words by manipulating existing words. She has a favorite string `s` and she wants to generate a set of new words from it by following a series of operations. Each operation is described by a group of three components (op, x, y): 1. `op` - a single character operation which can be either 'R' (...
def manipulate_string(s, operations): result = s for op in operations: if op[0] == 'R': start, end = int(op[1]), int(op[2]) result = result[:start] + result[start:end + 1][::-1] + result[end + 1:] elif op[0] == 'C': concat_str = op[1] resu...
from solution import process_operations def test_process_operations_case1(): initial_string = "abcde" operations = [["R", "1", "3"], ["C", "xyz"], ["S", "xyz", "deab"]] assert process_operations(initial_string, 3, operations) == "NO" def test_process_operations_case2(): initial_string = "hello" op...
[ { "docstring": null, "function_declaration": "def manipulate_string(s, operations):", "function_name": "manipulate_string", "parameter_list": "(s, operations)" }, { "docstring": null, "function_declaration": "def process_operations(s, n, operations):", "function_name": "process_opera...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def manipulate_string(s, operations):\n for op in operations:\n if op[0] == 'R':\n _, x, y = op\n x, y = int(x), int(y)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00091051", "row_id": 91051, "seed_ids": "[14713]" }
0.693953
Taco_91051
I
[ "manipulate_string", "process_operations" ]
2
[ [ "process_operations", "manipulate_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8a2a8a8268380a80342205fb590e1e00fc98c7f3
d1088333983aba2b4e97cc159f3ab458a0194ead
v1.0
instruct
Taco
Taco_91187_I
You are given a list of integers. In one move, you can select any two adjacent integers in the list and swap them. Your task is to find the minimum number of moves required to sort the list in non-decreasing order. -----Input----- The first line of the input contains a single integer $n$ ($1 \le n \le 10^3$) — the n...
def count_inversions(arr): """ Helper function to count inversions in the list using merge sort technique. """ if len(arr) < 2: return arr, 0 mid = len(arr) // 2 left, left_inversions = count_inversions(arr[:mid]) right, right_inversions = count_inversions(arr[mid:]) me...
from solution import minimum_moves_to_sort def test_example_case(): assert minimum_moves_to_sort([4, 3, 2, 1, 5]) == 6 def test_already_sorted(): assert minimum_moves_to_sort([1, 2, 3, 4, 5]) == 0 def test_reverse_sorted(): assert minimum_moves_to_sort([5, 4, 3, 2, 1]) == 10 def test_random_case(): ...
[ { "docstring": "Helper function to count inversions in the list using merge sort technique.", "function_declaration": "def count_inversions(arr):", "function_name": "count_inversions", "parameter_list": "(arr)" }, { "docstring": "Merge two lists and count split inversions.", "function_de...
[ 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_swaps_to_sort(arr):\n \"\"\"\n Returns the minimum number of swaps required to sort the array in non-decreasing order.\n \"\"\"\n n = len(a...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00091187", "row_id": 91187, "seed_ids": "[14340]" }
0.650336
Taco_91187
I
[ "count_inversions", "merge_and_count", "minimum_moves_to_sort" ]
3
[ [ "count_inversions", "merge_and_count" ], [ "minimum_moves_to_sort", "count_inversions" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a8a2d2486e9bf50004df0bcde6c0c6353981a3e0
ae43bfb1664885cf8bf7a0ba4f385211e3ad90b6
v1.0
instruct
Taco
Taco_91203_I
Marta is planning a hiking trip and wants to pack her backpack efficiently. Her backpack has a maximum weight capacity, and she has a list of essential items she wants to bring, each with a specific weight and value. Marta wants to maximize the total value of the items she can carry without exceeding the weight limit o...
def knapsack(W, weights, values, n): """ Returns the maximum value that can be accommodated in the knapsack with given weight capacity W, weights and values of the items. """ # Initialize a DP table to store the maximum value up to capacity W dp = [0] * (W + 1) for i in range(n): ...
from solution import maximal_value_of_items def test_example1(): n = 3 W = 50 items = [(20, 40), (50, 100), (30, 60)] assert maximal_value_of_items(n, W, items) == 100 def test_example2(): n = 4 W = 10 items = [(5, 10), (4, 7), (3, 4), (2, 2)] assert maximal_value_of_items(n, W, items)...
[ { "docstring": "Returns the maximum value that can be accommodated in the knapsack\nwith given weight capacity W, weights and values of the items.", "function_declaration": "def knapsack(W, weights, values, n):", "function_name": "knapsack", "parameter_list": "(W, weights, values, n)" }, { "...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def knapsack(n, W, items):\n \"\"\"\n Solves the knapsack problem using dynamic programming.\n\n Parameters:\n n (int): Number of items.\n W (int): ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091203", "row_id": 91203, "seed_ids": "[2954]" }
0.764248
Taco_91203
I
[ "knapsack", "maximal_value_of_items" ]
2
[ [ "maximal_value_of_items", "knapsack" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc3184b953c55362aa91ebc0b95db890b958b1d0
0b0117b9b01aae24cec272c1076627824a35032a
v1.0
instruct
Taco
Taco_91216_I
In a robotics competition, a robot needs to navigate through a grid. The robot starts at the top-left corner (1, 1) and needs to reach the bottom-right corner (N, M). However, there are certain obstacles in the grid which the robot cannot traverse. The robot can only move right or down from its current position. Your ...
def number_of_paths(grid): """ Calculate the number of different paths from top-left to bottom-right of a grid. :param grid: A list of strings representing the grid. :return: The number of different paths. """ N = len(grid) M = len(grid[0]) if grid[0][0] == '#' or grid[N-1][M-1...
from solution import number_of_paths def test_number_of_paths_case_1(): grid = [ '...', '.#.', '...' ] assert number_of_paths(grid) == 2 def test_number_of_paths_case_2(): grid = [ '.#', '#.' ] assert number_of_paths(grid) == 0 def test_number_of_paths_...
[ { "docstring": "Calculate the number of different paths from top-left to bottom-right of a grid.\n\n:param grid: A list of strings representing the grid.\n:return: The number of different paths.", "function_declaration": "def number_of_paths(grid):", "function_name": "number_of_paths", "parameter_li...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_paths(grid):\n \"\"\"\n Returns the number of different paths the robot can take to reach the bottom-right corner\n from the top-left corner of ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091216", "row_id": 91216, "seed_ids": "[20638]" }
0.758984
Taco_91216
I
[ "number_of_paths", "read_input_and_solve" ]
2
[ [ "read_input_and_solve", "number_of_paths" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83b9341b8722c378ac28ed6c8823de8a95cc554c
f002cd3b4a4f412c93ecd2bef422c719683c37de
v1.0
instruct
Taco
Taco_91218_I
Ash wants to visit all the tourist attractions in his city. There are n attractions, and there are m direct roads connecting some of these attractions. Ash is currently at attraction 1, and he wants to visit all attractions at least once before returning to attraction 1. Each road has a travel time associated with it, ...
import itertools def tsp(graph, n, start=0): """ Solve the Travelling Salesman Problem using dynamic programming and bit masking. :param graph: 2D list representing the adjacency matrix of the graph. :param n: Number of vertices in the graph. :param start: The starting vertex. :return: Min...
from solution import minimum_tour_time def test_example_1(): n = 4 m = 6 roads = [ (1, 2, 10), (1, 3, 15), (1, 4, 20), (2, 3, 35), (2, 4, 25), (3, 4, 30) ] assert minimum_tour_time(n, m, roads) == 80 def test_example_2(): n = 4 m = 3 road...
[ { "docstring": "Solve the Travelling Salesman Problem using dynamic programming and bit masking.\n\n:param graph: 2D list representing the adjacency matrix of the graph.\n:param n: Number of vertices in the graph.\n:param start: The starting vertex.\n:return: Minimum travel cost to visit all vertices and return...
[ 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\n\ndef min_travel_time(n, m, roads):\n import sys\n from collections import defaultdict\n \n # Create a graph using ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00091218", "row_id": 91218, "seed_ids": "[9309]" }
0.753415
Taco_91218
I
[ "tsp", "minimum_tour_time" ]
2
[ [ "minimum_tour_time", "tsp" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eae702cfd029e89eee18780486963373b4284aae
52b478e38dd84297a3cebc6f8cc25c7568f3355e
v1.0
instruct
Taco
Taco_91308_I
Write a program that checks if the given strings are palindromic numbers when interpreted as decimal (base-10) and binary (base-2). A palindromic number is one that reads the same backward as forward. You need to verify both representations for each given number. input The input consists of multiple strings, each rep...
def is_palindromic(s): """ Helper function to check if a string s is palindromic. """ return s == s[::-1] def check_palindromic_numbers(numbers): """ For each number in numbers, check if it is palindromic in both decimal and binary representations. Args: numbers (list of str): List...
from solution import check_palindromic_numbers def test_check_palindromic_numbers(): assert check_palindromic_numbers(['585', '5', '21', '65', '217']) == ['Yes', 'Yes', 'No', 'No', 'No'] def test_single_number_yes(): assert check_palindromic_numbers(['3']) == ['Yes'] def test_single_number_no(): asse...
[ { "docstring": "Helper function to check if a string s is palindromic.", "function_declaration": "def is_palindromic(s):", "function_name": "is_palindromic", "parameter_list": "(s)" }, { "docstring": "For each number in numbers, check if it is palindromic in both decimal and binary represent...
[ 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_palindromic(s):\n \"\"\"Check if the given string is palindromic.\"\"\"\n return s == s[::-1]\n\ndef check_palindromic_numbers(numbers):\n \"\"\"\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00091308", "row_id": 91308, "seed_ids": "[22489]" }
0.696518
Taco_91308
I
[ "is_palindromic", "check_palindromic_numbers" ]
2
[ [ "check_palindromic_numbers", "is_palindromic" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6db7649d8b14b74eadb272447c52f0044a2d8d5a
dd26b1b0cb1f5dd993d15ce7393204110d99b8b9
v1.0
instruct
Taco
Taco_91403_I
An arithmetic sequence is a sequence of numbers in which the difference between consecutive terms is constant. This difference is called the "common difference". In this problem, you need to determine if a given unsorted array is an arithmetic sequence and, if not, return the minimum number of operations required to ...
def is_arithmetic_sequence(arr): """ Helper function to determine if an array is already an arithmetic sequence. """ if len(arr) <= 1: return True common_diff = arr[1] - arr[0] for i in range(1, len(arr)): if arr[i] - arr[i - 1] != common_diff: return False ...
from solution import min_operations_to_arithmetic_sequence def test_no_operations_needed(): assert min_operations_to_arithmetic_sequence([1, 3, 5, 7, 9]) == 0 def test_one_operation_needed(): assert min_operations_to_arithmetic_sequence([2, 4, 6, 8, 12]) == 1 def test_multiple_operations_needed(): assert...
[ { "docstring": "Helper function to determine if an array is already an arithmetic sequence.", "function_declaration": "def is_arithmetic_sequence(arr):", "function_name": "is_arithmetic_sequence", "parameter_list": "(arr)" }, { "docstring": "Returns the minimum number of operations needed to...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_operations_to_arithmetic_sequence(arr):\n \"\"\"\n Returns the minimum number of operations needed to make the input array an arithmetic sequence.\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00091403", "row_id": 91403, "seed_ids": "[8339]" }
0.713958
Taco_91403
I
[ "is_arithmetic_sequence", "min_operations_to_arithmetic_sequence" ]
2
[ [ "min_operations_to_arithmetic_sequence", "is_arithmetic_sequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
eb6609380530bc8622441f62c36e1e43181938c9
2ff22bebf330e9ba90e5f3830d38469d1d5ab45d
v1.0
instruct
Taco
Taco_91477_I
You are tasked with developing a simulation for a new type of traffic control system. The system aims to control the flow of cars through a series of crossroads in a city using real-time traffic sensors. Cars at each crossroad can only move in four directions: North, South, East, and West. Each car has a certain destin...
from collections import deque def min_seconds_to_reach_destination(city_map): N = len(city_map) M = len(city_map[0]) # Helper functions to find 'S' and 'E' positions def find_positions(): start, end = None, None for i in range(N): for j in range(M): if c...
def test_min_seconds_to_reach_destination_simple(): city_map = [ "S..", ".#.", "..E" ] assert min_seconds_to_reach_destination(city_map) == 4 def test_min_seconds_to_reach_destination_blocked(): city_map = [ "S#.", "###", ".#E" ] assert min_se...
[ { "docstring": null, "function_declaration": "def min_seconds_to_reach_destination(city_map):", "function_name": "min_seconds_to_reach_destination", "parameter_list": "(city_map)" }, { "docstring": null, "function_declaration": "def min_time_for_cars(test_cases):", "function_name": "...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef min_time_to_destination(T, test_cases):\n results = []\n\n for case in test_cases:\n N, M, grid = case\n s...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00091477", "row_id": 91477, "seed_ids": "[10337]" }
0.659374
Taco_91477
I
[ "min_seconds_to_reach_destination", "min_time_for_cars", "read_input" ]
3
[ [ "min_time_for_cars", "min_seconds_to_reach_destination" ] ]
1
[ "read_input" ]
false
[]
false
pytest
false
[]
true
26ce1800176e7861afae700652c09bf1c3aa9319
8f3c3ac5df4d126a6eeea85228f2655d1f5f0614
v1.0
instruct
Taco
Taco_91501_I
Write a program that reads two sequences of integers and finds their longest common subsequence. A longest common subsequence (LCS) is a subsequence that appears in both sequences in the same order but not necessarily consecutively. The program should output the length of the LCS. Note Constraints * Each sequence co...
def longest_common_subsequence(seq1, seq2): """ This function finds the length of the longest common subsequence between two sequences. """ n = len(seq1) m = len(seq2) # Create a 2D array to store lengths of longest common subsequence. dp = [[0] * (m + 1) for _ in range(n + 1)] ...
from solution import find_lcs_length def test_example_case(): input_data = "6\n1 2 3 4 1\n5\n3 4 1 2 1 3" result = find_lcs_length(input_data) assert result == 3 def test_case_no_common_subsequence(): input_data = "3\n1 2 3\n3\n4 5 6" result = find_lcs_length(input_data) assert result == 0 de...
[ { "docstring": "This function finds the length of the longest common subsequence between two sequences.", "function_declaration": "def longest_common_subsequence(seq1, seq2):", "function_name": "longest_common_subsequence", "parameter_list": "(seq1, seq2)" }, { "docstring": null, "functi...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def lcs_length(seq1, seq2):\n \"\"\"\n Computes the length of the longest common subsequence (LCS) between two sequences.\n :param seq1: First sequence of...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091501", "row_id": 91501, "seed_ids": "[5799]" }
0.747438
Taco_91501
I
[ "longest_common_subsequence", "find_lcs_length" ]
2
[ [ "find_lcs_length", "longest_common_subsequence" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9be5d2a532bf86d1a14f69b0298073dac41070f1
6d2a6703fbdb3004ba5256f9e9164faea164dcaf
v1.0
instruct
Taco
Taco_91530_I
In a distant universe, there exists a network of connected planets. Each planet is linked to certain other planets by bidirectional communication channels, allowing the exchange of resources between them. The emperor of this universe wants to know about the minimal resource distribution network that can connect all the...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] ...
def test_mst_case1(): n = 4 m = 5 edges = [(1, 2, 1), (2, 3, 4), (3, 4, 3), (1, 3, 5), (1, 4, 2)] assert minimal_communication_cost(n, m, edges) == 6 def test_mst_case2(): n = 3 m = 3 edges = [(1, 2, 2), (2, 3, 3), (1, 3, 1)] assert minimal_communication_cost(n, m, edges) == 3 def test...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 ]
3
hard
0.3
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n xroot = fi...
trial_gpt4o_8
{ "original_instruction": "", "prompt_id": "00091530", "row_id": 91530, "seed_ids": "[6416]" }
0.773093
Taco_91530
I
[ "find", "union", "kruskal_mst", "minimal_communication_cost" ]
4
[ [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimal_communication_cost", "kruskal_mst" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
false
[]
true
8be56358d99aadbdd5915db174216ff2ff1d104a
20e7251b98208bbf1b83e70a5b4fc1d3463175cc
v1.0
instruct
Taco
Taco_91585_I
You are planning a project where you need to allocate tasks to your team members. Each task has a specific start and end time, and each team member can work on at most one task at a time. Your goal is to maximize the number of tasks completed by your team. Given a list of tasks with their start and end times, determin...
def max_non_overlapping_tasks(tasks): tasks.sort(key=lambda x: x[1]) # Sort by end time count = 0 last_end_time = 0 for start, end in tasks: if start >= last_end_time: count += 1 last_end_time = end return count def read_input_and_compute_max_tasks(): ...
def test_max_non_overlapping_tasks(): tasks1 = [(1, 3), (2, 5), (4, 6), (6, 7), (5, 8)] assert max_non_overlapping_tasks(tasks1) == 3 tasks2 = [(1, 2), (2, 3), (3, 5)] assert max_non_overlapping_tasks(tasks2) == 3 tasks3 = [(1, 4), (2, 5), (3, 6)] assert max_non_overlapping_tasks(tasks3) == 1 ...
[ { "docstring": null, "function_declaration": "def max_non_overlapping_tasks(tasks):", "function_name": "max_non_overlapping_tasks", "parameter_list": "(tasks)" }, { "docstring": null, "function_declaration": "def read_input_and_compute_max_tasks():", "function_name": "read_input_and_...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_non_overlapping_tasks(tasks):\n \"\"\"\n Returns the maximum number of non-overlapping tasks that can be completed.\n \"\"\"\n # Sort the tasks...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00091585", "row_id": 91585, "seed_ids": "[14249]" }
0.664814
Taco_91585
I
[ "max_non_overlapping_tasks", "read_input_and_compute_max_tasks" ]
2
[ [ "read_input_and_compute_max_tasks", "max_non_overlapping_tasks" ] ]
1
[]
false
[]
false
pytest
false
[]
true
1aaf15ad963223369e140f720e6b5479ac7f117f
54936994362464952793df4c120d5768aa7b43d8
v1.0
instruct
Taco
Taco_91612_I
Jack loves playing with numbers. He has an integer array and wants to perform queries on it. Each query consists of two integers L and R, and for each query, Jack wants to know the count of elements in the subarray from L to R (inclusive) that are perfect squares. Write a program to help Jack with his queries. -----...
import math def is_perfect_square(x): """Check if a number x is a perfect square.""" s = int(math.isqrt(x)) return s * s == x def count_perfect_squares(arr, queries): """Count the number of perfect squares in subarrays specified by the queries.""" perfect_square_flags = [1 if is_perfect_square(x) ...
def test_is_perfect_square(): from math import isqrt def is_perfect_square(x): s = int(isqrt(x)) return s * s == x assert is_perfect_square(1) assert is_perfect_square(4) assert is_perfect_square(9) assert is_perfect_square(16) assert not is_perfect_square(2) assert not ...
[ { "docstring": "Check if a number x is a perfect square.", "function_declaration": "def is_perfect_square(x):", "function_name": "is_perfect_square", "parameter_list": "(x)" }, { "docstring": "Count the number of perfect squares in subarrays specified by the queries.", "function_declarat...
[ 0, 0, 0, 1 ]
1
hard
0.25
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(number):\n \"\"\"\n Check if a number is a perfect square.\n \"\"\"\n root = int(math.isqrt(number))\n return r...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00091612", "row_id": 91612, "seed_ids": "[2083]" }
0.712209
Taco_91612
I
[ "is_perfect_square", "count_perfect_squares", "process_input", "main" ]
4
[ [ "count_perfect_squares", "is_perfect_square" ] ]
1
[ "process_input" ]
false
[]
false
pytest
false
[]
true
a2bad5f86be4925e8bbd758381efcb66da48c9b3
bdbb04331054b1a79caf3940bb22ef5898eb868d
v1.0
instruct
Taco
Taco_91649_I
Kira is fascinated by prime numbers, and he loves to identify patterns in sequences of numbers. He has come up with a challenge where he takes a sequence of integers and tries to find the longest subsequence that consists only of prime numbers. A prime number is a natural number greater than 1 that has no positive di...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def longest_prime_subsequence(arr): prime_...
def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(1) assert not is_prime(4) assert is_prime(17) assert not is_prime(100) def test_longest_prime_subsequence(): assert longest_prime_subsequence([2, 6, 4, 7]) == 1 assert longest_prime_subsequence([1, 3, 5, 8, 9...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def longest_prime_subsequence(arr):", "function_name": "longest_prime_subsequence", "parameter_list": "(arr)" }...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00091649", "row_id": 91649, "seed_ids": "[21520]" }
0.658741
Taco_91649
I
[ "is_prime", "longest_prime_subsequence", "find_longest_prime_subsequence" ]
3
[ [ "find_longest_prime_subsequence", "longest_prime_subsequence" ], [ "longest_prime_subsequence", "is_prime" ] ]
2
[]
false
[]
false
pytest
false
[]
true
5495c4492ad99442ad5b2ec73484899d2d5c23ee
e2af14b928e9d697efb823664773cc178c48cbd0
v1.0
instruct
Taco
Taco_91702_I
In a small town, there are N houses arranged in a row and each house is either painted red or blue. You and your friend Alice decide to play a game. Alice gives you M instructions, each instruction either tells you a sequence of houses has the same color, or it tells you a specific house has a specific color. Your task...
def min_instructions_to_erase(N, M, instructions): parent = list(range(N + 1)) color = [-1] * (N + 1) def find(x): if parent[x] != x: parent[x] = find(parent[x]) return parent[x] def union(x, y): rootX = find(x) rootY = find(y) if rootX != rootY: ...
def test_min_instructions_to_erase(): assert solve_from_input("4 5\nS 1 2\nC 1 red\nS 2 3\nC 2 blue\nS 3 4\n") == 1 assert solve_from_input("4 6\nS 1 2\nS 2 3\nC 1 red\nC 3 blue\nC 2 blue\nS 1 4\n") == 2 assert solve_from_input("4 4\nS 1 2\nC 1 red\nS 2 3\nS 3 4\n") == 0 assert solve_from_input("3 4\nS ...
[ { "docstring": null, "function_declaration": "def min_instructions_to_erase(N, M, instructions):", "function_name": "min_instructions_to_erase", "parameter_list": "(N, M, instructions)" }, { "docstring": null, "function_declaration": "def solve_from_input(input_str):", "function_name...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_instructions_to_erase(n, m, instructions):\n parent = list(range(n + 1))\n color = [-1] * (n + 1) # -1 denotes unassigned color\n\n def find(x):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00091702", "row_id": 91702, "seed_ids": "[3859]" }
0.570726
Taco_91702
I
[ "min_instructions_to_erase", "solve_from_input" ]
2
[ [ "solve_from_input", "min_instructions_to_erase" ] ]
1
[]
false
[]
false
pytest
false
[]
true
a6164314661059b5101b16ea395ec207b4010a92
abb03133ac42309f359e0aa7c6127a7f3e014e4e
v1.0
instruct
Taco
Taco_91751_I
You are given an array of integers and a series of operations to perform on the array. The operations are defined as follows: 1. `K=1, Append(x)` - Append the integer `x` to the end of the array. 2. `K=2, Remove(x)` - Remove all occurrences of the integer `x` from the array. 3. `K=3, MaxSubArray(L, R)` - Find the maxi...
def perform_operations(operations): arr = [] results = [] for operation in operations: parts = operation.split() K = int(parts[0]) if K == 1: x = int(parts[1]) arr.append(x) elif K == 2: x = int(parts[1]) arr = [y ...
from solution import perform_operations def test_example_case(): operations = [ "1 1", "1 -2", "1 3", "1 2", "3 1 3", "2 -2", "3 1 3" ] result = perform_operations(operations) assert result == [3, 6] def test_empty_array(): operations = [] ...
[ { "docstring": null, "function_declaration": "def perform_operations(operations):", "function_name": "perform_operations", "parameter_list": "(operations)" }, { "docstring": null, "function_declaration": "def max_subarray_sum(arr):", "function_name": "max_subarray_sum", "paramete...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def process_operations(Q, operations):\n \"\"\"\n Process the given operations on the array and return the results of K=3 operations.\n \n :param Q: An...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091751", "row_id": 91751, "seed_ids": "[25034]" }
0.848038
Taco_91751
I
[ "perform_operations", "max_subarray_sum" ]
2
[ [ "perform_operations", "max_subarray_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
936447ca2aeeaffb09aa05334621ff15f7dfdf34
3d581fa9b2d1b64126a186a33b0b38f0058f22b1
v1.0
instruct
Taco
Taco_91784_I
In a magical land, there exists a special type of tree called a "balanced tree." A balanced tree is defined as one in which the heights of the two subtrees of any node never differ by more than one. You have recently discovered a magical spell that allows you to transform a regular binary tree into a balanced tree. Ho...
class TreeNode: def __init__(self, value): self.value = value self.left = None self.right = None def build_tree(nodes): if not nodes: return None node_dict = {v: TreeNode(v) for v, l, r in nodes} for v, l, r in nodes: node = node_dict[v] if l != 0: ...
def test_case_1(): n = 3 nodes = [(1, 2, 3), (2, 0, 0), (3, 0, 0)] assert can_transform_to_balanced_tree(n, nodes) == "YES" def test_case_2(): n = 3 nodes = [(1, 0, 2), (2, 0, 3), (3, 0, 0)] assert can_transform_to_balanced_tree(n, nodes) == "NO" def test_case_3(): n = 1 nodes = [(1, 0...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value, left=None, right=None):\n self.value = value\n self.left = left\n self.right = right\n\ndef is_...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091784", "row_id": 91784, "seed_ids": "[3780]" }
0.716723
Taco_91784
I
[ "build_tree", "is_balanced", "can_transform_to_balanced_tree" ]
3
[ [ "can_transform_to_balanced_tree", "build_tree" ], [ "can_transform_to_balanced_tree", "is_balanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
false
[]
true
25eb14a1e4877ed64905eeab9df5a9396124069d
3eff948ff9d721dff582265f5b50fc108c4fd9e6
v1.0
instruct
Taco
Taco_91801_I
The city mayor has decided to plant trees along the main road to beautify the city. The road can be represented as a straight line with n points where trees can be planted. Due to budget constraints, the mayor can only plant m trees. To ensure uniformity and maximized beauty, the mayor wants the trees to be planted suc...
def can_place_trees(positions, n, m, min_dist): """ Helper function to check if m trees can be placed with at least min_dist distance apart. """ count = 1 # Place the first tree at the first position last_position = positions[0] for i in range(1, n): if positions[i] - last_position >= ...
from solution import max_min_distance def test_example1(): n = 5 m = 3 positions = [1, 2, 8, 4, 9] assert max_min_distance(n, m, positions) == 3 def test_example2(): n = 6 m = 4 positions = [1, 2, 6, 7, 8, 11] assert max_min_distance(n, m, positions) == 2 def test_small_case(): n ...
[ { "docstring": "Helper function to check if m trees can be placed with at least min_dist distance apart.", "function_declaration": "def can_place_trees(positions, n, m, min_dist):", "function_name": "can_place_trees", "parameter_list": "(positions, n, m, min_dist)" }, { "docstring": "Returns...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_min_distance(n, m, positions):\n positions.sort()\n\n def feasible(distance):\n count, last_position = 1, positions[0]\n for i in range...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00091801", "row_id": 91801, "seed_ids": "[21274]" }
0.713423
Taco_91801
I
[ "can_place_trees", "max_min_distance" ]
2
[ [ "max_min_distance", "can_place_trees" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6d978b54ea4a5796652bbe65c8405389e67e284d
f6cf54e41be1a8f874c53cc11064d7940fead245
v1.0
instruct
Taco
Taco_91807_I
Alice has recently developed an interest in number theory and discovered a sequence of numbers called the "Fibonacci sequence." The Fibonacci sequence is defined as follows: - $\text{Fib}(0) = 0$ - $\text{Fib}(1) = 1$ - For $n \geq 2$, $\text{Fib}(n) = \text{Fib}(n-1) + \text{Fib}(n-2)$ Alice noticed that large Fibon...
def gcd(a, b): """ Helper function to calculate the GCD of two numbers using the Euclidean algorithm. """ while b: a, b = b, a % b return a def fib(n): """ Helper function to calculate the n-th Fibonacci number using matrix exponentiation. This function can effectively compute F...
from solution import gcd_fib def test_sample_case(): assert gcd_fib(10, 15) == 5 def test_same_number(): assert gcd_fib(21, 21) == 10946 # Because Fib(21) is 10946 def test_zero_case(): assert gcd_fib(0, 5) == 5 # Fib(0) is 0, Fib(5) is 5, GCD(0, 5) is 5 and Fib(5) is 5 def test_large_numbers(): a...
[ { "docstring": "Helper function to calculate the GCD of two numbers using the Euclidean algorithm.", "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": "Helper function to calculate the n-th Fibonacci number using matrix exponentiat...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gcd(a, b):\n \"\"\"\n Helper function to calculate the GCD of two numbers using the Euclidean algorithm.\n \"\"\"\n while b:\n a, b = b, a %...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00091807", "row_id": 91807, "seed_ids": "[14045]" }
0.587956
Taco_91807
I
[ "gcd", "fib", "gcd_fib" ]
3
[ [ "gcd_fib", "fib" ], [ "gcd_fib", "gcd" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ecaa975ac70c9fa3d6d8d2ee7481a4ba7b1ae9ed
13b3bc3ad8297b2be80d546a85b8e8cf37f30c5f
v1.0
instruct
Taco
Taco_91870_I
A farmer owns a rectangular field that is divided into a grid of m rows and n columns. Some cells are fertile where crops can be grown, while others are barren where no crops can be grown. The farmer wants to grow the maximum number of contiguous crops in any rectangular block of fertile cells. Your task is to determi...
def max_fertile_area(m, n, field): """ Returns the area of the largest contiguous rectangular block of fertile cells. """ # Create a height array to store the height of 'F' (fertile) cells. height = [0] * n max_area = 0 for i in range(m): for j in range(n): if field[...
from solution import max_fertile_area def test_example_1(): m, n = 4, 4 field = [ "FFFF", "FFBF", "FFFF", "FBFF" ] assert max_fertile_area(m, n, field) == 6 def test_example_2(): m, n = 5, 6 field = [ "FFFFFF", "FFFFBF", "FFBBFF", ...
[ { "docstring": "Returns the area of the largest contiguous rectangular block of fertile cells.", "function_declaration": "def max_fertile_area(m, n, field):", "function_name": "max_fertile_area", "parameter_list": "(m, n, field)" }, { "docstring": "Helper function to find the largest rectang...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_fertile_area(m, n, field):\n \"\"\"\n Returns the area of the largest contiguous rectangular block of fertile cells.\n \"\"\"\n # Create a heig...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00091870", "row_id": 91870, "seed_ids": "[16227]" }
0.643608
Taco_91870
I
[ "max_fertile_area", "largest_rectangle_area" ]
2
[ [ "max_fertile_area", "largest_rectangle_area" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a4740e2f664713b3f938f71e1aa82195853d28e
debb101762d29137937dc9c5f8b8184433796080
v1.0
instruct
Taco
Taco_91873_I
You are given three sides of a triangle a, b, and c. Determine if a triangle is valid with these side lengths and if valid, calculate the area of the triangle using Heron's formula. If the triangle is not valid, print "Invalid". -----Constraints----- - 1≤a≤100 - 1≤b≤100 - 1≤c≤100 - All input values are integers. ...
import math def is_valid_triangle(a, b, c): # Check if sum of any two sides is greater than the third side if a + b > c and a + c > b and b + c > a: return True else: return False def calculate_area(a, b, c): if is_valid_triangle(a, b, c): # Using Heron's formula to calculate t...
def test_is_valid_triangle(): assert is_valid_triangle(3, 4, 5) == True assert is_valid_triangle(1, 1, 3) == False assert is_valid_triangle(5, 5, 5) == True assert is_valid_triangle(10, 20, 30) == False assert is_valid_triangle(7, 10, 5) == True def test_calculate_area(): assert calculate_area(...
[ { "docstring": null, "function_declaration": "def is_valid_triangle(a, b, c):", "function_name": "is_valid_triangle", "parameter_list": "(a, b, c)" }, { "docstring": null, "function_declaration": "def calculate_area(a, b, c):", "function_name": "calculate_area", "parameter_list":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_valid_triangle(a, b, c):\n \"\"\"\n Returns True if a, b, c can form a valid triangle, otherwise False.\n \"\"\"\n return a + b >...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091873", "row_id": 91873, "seed_ids": "[14554]" }
0.711497
Taco_91873
I
[ "is_valid_triangle", "calculate_area" ]
2
[ [ "calculate_area", "is_valid_triangle" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b87ff363f11aa032299c5bda93053df5737d3bcc
06ceb34b0d3bfc7f6e34369fd0cf9d7cb5578e60
v1.0
instruct
Taco
Taco_91896_I
In a distant future, on an uncharted island, there is a massive grid of treasure chests. Each treasure chest is located at specific coordinates, and each can hold a varying amount of gold and items. Treasure hunters have to answer queries related to the distribution of gold and items in the grid within specified ranges...
def preprocess(grid, n, m): gold_prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] items_prefix_sum = [[0] * (m + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, m + 1): gold_prefix_sum[i][j] = gold_prefix_sum[i - 1][j] + gold_prefix_sum[i][j - 1] - gold_prefix_su...
from solution import process_treasure_queries def test_process_treasure_queries(): n, m, q = 3, 3, 2 treasure_grid = [ [(1, 5), (2, 3), (3, 7)], [(4, 2), (5, 1), (6, 4)], [(7, 3), (8, 2), (9, 5)] ] queries = [ (1, 1, 2, 2), (2, 2, 3, 3) ] expected_output ...
[ { "docstring": null, "function_declaration": "def preprocess(grid, n, m):", "function_name": "preprocess", "parameter_list": "(grid, n, m)" }, { "docstring": null, "function_declaration": "def query_sums(gold_prefix_sum, items_prefix_sum, r1, c1, r2, c2):", "function_name": "query_su...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def process_queries(n, m, q, grid, queries):\n # Initialize prefix sums for gold and items\n gold_prefix = [[0]*(m+1) for _ in range(n+1)]\n items_prefix ...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00091896", "row_id": 91896, "seed_ids": "[24223]" }
0.667166
Taco_91896
I
[ "preprocess", "query_sums", "process_treasure_queries" ]
3
[ [ "process_treasure_queries", "preprocess" ], [ "process_treasure_queries", "query_sums" ] ]
2
[]
false
[]
false
pytest
true
[]
true
236f358428b159a02b3ff7e8246c142ba03fa2f3
2c6dfec1cddac00d5f460f90480230122f30bcb1
v1.0
instruct
Taco
Taco_91928_I
Anna has a collection of beautiful necklaces, where each necklace is composed of a sequence of beads of various colors. She often wears these necklaces, and while doing so, she noticed something interesting. Each necklace forms a cyclic sequence, meaning the end of the necklace is connected to the beginning, forming a ...
def rotate_string(s): """ Returns all cyclic rotations of the string 's'. """ return [s[i:] + s[:i] for i in range(len(s))] def canonical_form(s): """ Returns the canonical form of the string 's' by finding the lexicographically smallest rotation of 's'. """ rotations = rotate_strin...
from solution import count_unique_necklaces def test_basic_example(): assert count_unique_necklaces(5, ["abc", "bca", "cab", "xyz", "yyy"]) == 3 def test_all_unique(): assert count_unique_necklaces(3, ["aaa", "bbb", "ccc"]) == 3 def test_all_identical(): assert count_unique_necklaces(4, ["abc", "abc", "a...
[ { "docstring": "Returns all cyclic rotations of the string 's'.", "function_declaration": "def rotate_string(s):", "function_name": "rotate_string", "parameter_list": "(s)" }, { "docstring": "Returns the canonical form of the string 's' by finding the lexicographically smallest\nrotation of ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_unique_necklaces(n, necklaces):\n def get_canonical_form(s):\n return min(s[i:] + s[:i] for i in range(len(s)))\n\n unique_necklaces = s...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00091928", "row_id": 91928, "seed_ids": "[6066]" }
0.596673
Taco_91928
I
[ "rotate_string", "canonical_form", "count_unique_necklaces" ]
3
[ [ "canonical_form", "rotate_string" ], [ "count_unique_necklaces", "canonical_form" ] ]
2
[]
false
[]
false
pytest
true
[]
true
349f6a1e1f8e05daa9e9277b1d8e752b6501650d
cfab094a07a745c3f21497ce23afe6b95e9930f8
v1.0
instruct
Taco
Taco_91958_I
In an ancient magical kingdom, there is a library that contains an infinite number of books, indexed sequentially by positive integers starting from 1. Each book is enchanted with a magic number, defined as follows: - The magic number of book i (considering 1-based indexing) equals the number of unique prime factors of...
def count_unique_prime_factors(n): """ Returns the number of unique prime factors of n. """ count = 0 i = 2 if n % i == 0: count += 1 while n % i == 0: n //= i for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: count += 1 ...
from solution import process_queries def test_sum_magic_numbers(): queries = [ (1, 1), (2, 4), (10, 15), (1000, 1002) ] assert process_queries(queries) == [0, 3, 10, 8] def test_sum_magic_numbers_single_range(): queries = [ (5, 5) # Single number, which is prim...
[ { "docstring": "Returns the number of unique prime factors of n.", "function_declaration": "def count_unique_prime_factors(n):", "function_name": "count_unique_prime_factors", "parameter_list": "(n)" }, { "docstring": "Preprocess and return an array of magic numbers up to the given limit.", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_prime_factors_sums(limit=10**6):\n prime_factors_count = [0] * (limit + 1)\n \n # Sieve of Eratosthenes to calculate the number of unique pri...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00091958", "row_id": 91958, "seed_ids": "[4627]" }
0.576661
Taco_91958
I
[ "count_unique_prime_factors", "preprocess_magic_numbers", "preprocess_sum_magic_numbers", "sum_magic_numbers", "process_queries" ]
5
[ [ "process_queries", "preprocess_magic_numbers" ], [ "process_queries", "preprocess_sum_magic_numbers" ], [ "process_queries", "sum_magic_numbers" ] ]
3
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
72b06da79f93c0d6bd406d26aee027477025f840
6d16f7fcc4f2bf0bda2ba31ac7fd042484afec19
v1.0
instruct
Taco
Taco_92023_I
A delivery company operates in a city structured as a grid. The city's layout consists of M streets and N avenues, forming a grid with M intersections. Each intersection can be identified by a pair of coordinates (x, y). The company needs to plan routes for its delivery trucks such that each truck starts at a specified...
def is_valid_route(M, N, x, y, movements): visited = set() visited.add((x, y)) for move in movements: if move == 'U': x -= 1 elif move == 'D': x += 1 elif move == 'L': y -= 1 elif move == 'R': y += 1 if x <...
from solution import process_input, determine_routes, is_valid_route def test_process_input(): input_data = "1\n5 5\n2\n3 3 UURRDDL\n2 2 RRUULL\n" expected_output = [(5, 5, [(2, 2, 'UURRDDL'), (1, 1, 'RRUULL')])] assert process_input(input_data) == expected_output def test_is_valid_route(): M = 5 ...
[ { "docstring": null, "function_declaration": "def is_valid_route(M, N, x, y, movements):", "function_name": "is_valid_route", "parameter_list": "(M, N, x, y, movements)" }, { "docstring": null, "function_declaration": "def determine_routes(test_cases):", "function_name": "determine_r...
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_route(grid_size, start_pos, movement):\n M, N = grid_size\n x, y = start_pos\n visited = set()\n visited.add((x, y))\n \n directions...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00092023", "row_id": 92023, "seed_ids": "[9345]" }
0.722461
Taco_92023
I
[ "is_valid_route", "determine_routes", "process_input" ]
3
[ [ "determine_routes", "is_valid_route" ] ]
1
[ "process_input" ]
false
[]
false
pytest
true
[]
true
2995ec2fb380ad4e8eac6bc80addb94a814536f3
107c01b382252e682a2ed8c60761754ec160ab93
v1.0
instruct
Taco
Taco_92097_I
Write a function to find the maximum subarray sum for a given array of integers, using the Divide and Conquer technique. The array can contain both negative and positive numbers. Example 1: Input: arr[] = {2, 3, 4, 5, 7} Output: 21 Explanation: The sum of entire array is 21, which is the maximum subarray sum. Example...
def maxCrossingSum(arr, low, mid, high): # Include elements on the left of mid. left_sum = float('-inf') sum_now = 0 for i in range(mid, low - 1, -1): sum_now += arr[i] if sum_now > left_sum: left_sum = sum_now # Include elements on the right of mid right_sum = f...
from solution import maxSubArraySum def test_max_sub_array_sum_all_positive(): assert maxSubArraySum([2, 3, 4, 5, 7], 5) == 21 def test_max_sub_array_sum_mixed(): assert maxSubArraySum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7 def test_max_sub_array_sum_single_element(): assert maxSubArraySum([1], 1) == 1 ...
[ { "docstring": null, "function_declaration": "def maxCrossingSum(arr, low, mid, high):", "function_name": "maxCrossingSum", "parameter_list": "(arr, low, mid, high)" }, { "docstring": null, "function_declaration": "def maxSubArraySumUtil(arr, low, high):", "function_name": "maxSubArr...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_crossing_sum(arr, low, mid, high):\n # Include elements on the left of mid\n sum = 0\n left_sum = float('-inf')\n for i in range(mid, low - 1, ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00092097", "row_id": 92097, "seed_ids": "[25210]" }
0.789725
Taco_92097
I
[ "maxCrossingSum", "maxSubArraySumUtil", "maxSubArraySum" ]
3
[ [ "maxSubArraySum", "maxSubArraySumUtil" ], [ "maxSubArraySumUtil", "maxCrossingSum" ] ]
2
[]
false
[]
false
pytest
true
[]
true
162aaf718608a6596d44c339d6138833194af4db
5a0899726c70d7f37857b2cf0e448f17878da21b
v1.0
instruct
Taco
Taco_92173_I
In a small town, there are M roads and N intersections, represented as a graph where intersections are nodes and roads are directed edges. Each road has a specific cost associated with it, representing the effort to move from one intersection to another. Your task is to determine the minimum cost required to travel fro...
import heapq def dijkstra(n, edges, start): graph = [[] for _ in range(n)] for u, v, w in edges: graph[u].append((w, v)) dist = [float('inf')] * n dist[start] = 0 priority_queue = [(0, start)] while priority_queue: current_dist, node = heapq.heappop(priority_queue) ...
def test_example1(): n = 5 m = 6 edges = [ (0, 1, 2), (0, 2, 4), (1, 2, 1), (1, 3, 7), (2, 4, 3), (3, 4, 1) ] start = 0 assert find_min_cost_to_all_intersections(n, m, edges, start) == [0, 2, 3, 9, 6] def test_example2(): n = 4 m = 3 e...
[ { "docstring": null, "function_declaration": "def dijkstra(n, edges, start):", "function_name": "dijkstra", "parameter_list": "(n, edges, start)" }, { "docstring": null, "function_declaration": "def find_min_cost_to_all_intersections(n, m, edges, start):", "function_name": "find_min_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef dijkstra(n, roads, start):\n graph = [[] for _ in range(n)]\n for u, v, w in roads:\n graph[u].append((w, v))\n \n distances...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00092173", "row_id": 92173, "seed_ids": "[20057]" }
0.746774
Taco_92173
I
[ "dijkstra", "find_min_cost_to_all_intersections" ]
2
[ [ "find_min_cost_to_all_intersections", "dijkstra" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c99d4deab7edb77488af3bc0502ed18473e05fd8
45ccd658a8d029551bdc0b8a067ff5df8dbb98e8
v1.0
instruct
Taco
Taco_92191_I
Given an integer N, design an algorithm to compute the sum of the first N prime numbers. Example 1: Input: N=5 Output: 28 Explanation: The first 5 prime numbers are 2, 3, 5, 7, and 11. Their sum is 2 + 3 + 5 + 7 + 11 = 28. Example 2: Input: N=7 Output: 58 Explanation: The first 7 prime numbers are 2, 3, 5, 7, 11, 1...
def is_prime(num): if num <= 1: return False if num == 2 or num == 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def sumOfPrimes(N)...
from solution import sumOfPrimes def test_sum_of_first_5_primes(): assert sumOfPrimes(5) == 28 def test_sum_of_first_1_prime(): assert sumOfPrimes(1) == 2 def test_sum_of_first_7_primes(): assert sumOfPrimes(7) == 58 def test_sum_of_first_10_primes(): assert sumOfPrimes(10) == 129 def test_lower_bo...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def sumOfPrimes(N):", "function_name": "sumOfPrimes", "parameter_list": "(N)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\" Helper function to check if a number is prime \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00092191", "row_id": 92191, "seed_ids": "[8687]" }
0.609744
Taco_92191
I
[ "is_prime", "sumOfPrimes" ]
2
[ [ "sumOfPrimes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e717e9aa9d11067a2ab5ca60461ff5843b16d48c
6ed18ad0e5d8a0333664ad3661e04dd744fff5cc
v1.0
instruct
Taco
Taco_92249_I
Katerina is preparing for her competitive programming exam. One of the important topics is understanding and working with strings, especially involving palindromes. Katerina decides to practice with a problem involving finding specific palindromes within a string. Katerina's task is to determine whether a given string...
def is_palindrome(s): """ Checks if a given string s is a palindrome. """ return s == s[::-1] def can_be_divided_into_three_palindromic_parts(s): """ Determines if a given string s can be divided into three non-empty palindromic parts. """ n = len(s) for i in range(1, n - 1): ...
from solution import is_palindrome, can_be_divided_into_three_palindromic_parts, process_test_cases def test_is_palindrome(): assert is_palindrome("abccba") == True assert is_palindrome("abc") == False assert is_palindrome("a") == True assert is_palindrome("aa") == True def test_can_be_divided_into_th...
[ { "docstring": "Checks if a given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Determines if a given string s can be divided into three non-empty \npalindromic parts.", "function_...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n return s == s[::-1]\n\ndef can_split_into_three_palindromes(s):\n n = len(s)\n for i in range(1, n-1):\n for j in range(i+1...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00092249", "row_id": 92249, "seed_ids": "[18364]" }
0.760487
Taco_92249
I
[ "is_palindrome", "can_be_divided_into_three_palindromic_parts", "process_test_cases" ]
3
[ [ "can_be_divided_into_three_palindromic_parts", "is_palindrome" ], [ "process_test_cases", "can_be_divided_into_three_palindromic_parts" ] ]
2
[ "process_test_cases" ]
false
[]
false
pytest
true
[]
true
ec7f8dc62be299699790a70bb16abf7c2dc09265
88d8a6dafc308f27c7e657267bca21a01c8ebecf
v1.0
instruct
Taco
Taco_92254_I
You are given an undirected graph with N nodes and M edges. Each edge has a weight associated with it. Your task is to find the sum of the weights of the edges that form the Minimum Spanning Tree (MST) of the graph. If the MST does not exist, output -1. -----Constraints----- - 2 ≤ N ≤ 10^5 - 1 ≤ M ≤ 2×10^5 - 1 ≤ we...
def find(parent, i): if parent[i] != i: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): rootx = find(parent, x) rooty = find(parent, y) if rootx != rooty: if rank[rootx] > rank[rooty]: parent[rooty] = rootx elif rank[rootx] < r...
def test_mst_sample(): input_data = "4 5\n1 2 3\n1 3 4\n4 2 6\n4 3 5\n2 3 2\n" expected_output = 9 from io import StringIO import sys sys.stdin = StringIO(input_data) from solution import minimum_spanning_tree minimum_spanning_tree() def test_mst_no_edges(): input_data = "4 0\n" ex...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_MST_sum(N, M, edges):\n \"\"\"\n Returns the sum of the weights of the edges that form the Minimum Spanning Tree (MST)\n of the given undirected ...
trial_gpt4o_9
{ "original_instruction": "", "prompt_id": "00092254", "row_id": 92254, "seed_ids": "[23888]" }
0.828725
Taco_92254
I
[ "find", "union", "kruskal_mst", "calculate_mst_weight", "minimum_spanning_tree" ]
5
[ [ "calculate_mst_weight", "kruskal_mst" ], [ "kruskal_mst", "find" ], [ "kruskal_mst", "union" ], [ "minimum_spanning_tree", "calculate_mst_weight" ], [ "union", "find" ] ]
5
[]
false
[]
false
pytest
true
[]
true
554a4667f80e7a6ecaf271f8d81cf452ddae45dc
bc9ca0607e51f87517c2c76b3c940cb9377c4ddd
v1.0
instruct
Taco
Taco_92255_I
Write a program that reads a list of integers and checks for each integer if it is a "digit root palindrome." The digit root of a number is obtained by an iterative process of summing digits, on each step using the result from the previous step, until a single-digit number is obtained. A number is said to be a digit ro...
def digit_root(n): """ Calculate the digit root of a number. """ while n >= 10: n = sum(int(digit) for digit in str(n)) return n def is_digit_root_palindrome(number): """ Determine if the digit root of a number is a palindrome. """ root = digit_root(number) return str(ro...
from solution import digit_root, is_digit_root_palindrome, process_input def test_digit_root(): assert digit_root(56) == 2 assert digit_root(1234) == 1 assert digit_root(98765) == 8 assert digit_root(1010101) == 4 assert digit_root(34567) == 7 assert digit_root(89) == 8 assert digit_root(12...
[ { "docstring": "Calculate the digit root of a number.", "function_declaration": "def digit_root(n):", "function_name": "digit_root", "parameter_list": "(n)" }, { "docstring": "Determine if the digit root of a number is a palindrome.", "function_declaration": "def is_digit_root_palindrome...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_root(n):\n \"\"\"\n Returns the digit root of an integer n.\n \"\"\"\n while n >= 10:\n n = sum(int(digit) for digit in str(n))\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00092255", "row_id": 92255, "seed_ids": "[3877]" }
0.685646
Taco_92255
I
[ "digit_root", "is_digit_root_palindrome", "process_input" ]
3
[ [ "is_digit_root_palindrome", "digit_root" ], [ "process_input", "is_digit_root_palindrome" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
ea5dee04ac490d4f7ed4ab4a9778943128fbc1ac
10f7753e49fde268e61d5eabf1b1b09b6639c9f5
v1.0
instruct
Taco
Taco_92301_I
A taxi company wants to improve the allocation of drivers to customers based on the locations of both. They divide the city into a grid of blocks, where each block is identified using an (x, y) coordinate. Customers and drivers provide their locations as coordinates. The company wants to assign the closest driver to ea...
def euclidean_distance(c1, c2): """ Calculate the Euclidean distance between two points c1 and c2. c1, c2 are given as (x, y) tuples. """ return ((c1[0] - c2[0]) ** 2 + (c1[1] - c2[1]) ** 2) ** 0.5 def allocate_drivers(customers, drivers): """ Finds the closest driver to each customer using...
from solution import allocate_drivers def test_allocate_drivers_example(): assert allocate_drivers([(0, 0), (2, 3), (4, 5)], [(1, 1), (3, 2), (5, 5)]) == [0, 1, 2] def test_allocate_drivers_single_customer_and_driver(): assert allocate_drivers([(3, 3)], [(1, 1)]) == [0] assert allocate_drivers([(5, 5)], [...
[ { "docstring": "Calculate the Euclidean distance between two points c1 and c2.\nc1, c2 are given as (x, y) tuples.", "function_declaration": "def euclidean_distance(c1, c2):", "function_name": "euclidean_distance", "parameter_list": "(c1, c2)" }, { "docstring": "Finds the closest driver to e...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def allocate_drivers(customers, drivers):\n def euclidean_distance(c, d):\n return (c[0] - d[0]) ** 2 + (c[1] - d[1]) ** 2\n\n closest_drivers = []\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00092301", "row_id": 92301, "seed_ids": "[8174]" }
0.640939
Taco_92301
I
[ "euclidean_distance", "allocate_drivers" ]
2
[ [ "allocate_drivers", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
285674150fd0d2b3f835673da758681f493eef97
c4b2656416524094af633260a96ca40240add999
v1.0
instruct
Taco
Taco_92461_I
## Introduction In a standard deck of playing cards, there are 52 cards divided into 4 suits: hearts, diamonds, clubs, and spades. Each suit has 13 ranks: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King. A flush is a hand where all cards have the same suit. However, the specific ranks in the flush can still di...
def card_rank_value(rank): rank_order = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14} return rank_order[rank] def is_consecutive(values): values.sort() for i in range(len(values) - 1): if values[i+1] - values[i] != 1: ...
from solution import identify_hand def test_identify_hand_straight_flush(): assert identify_hand(["2H", "3H", "4H", "5H", "6H"]) == "6SF" assert identify_hand(["10D", "JD", "QD", "KD", "AD"]) == "ASF" assert identify_hand(["9S", "10S", "JS", "QS", "KS"]) == "KSF" assert identify_hand(["4C", "5C", "6C",...
[ { "docstring": null, "function_declaration": "def card_rank_value(rank):", "function_name": "card_rank_value", "parameter_list": "(rank)" }, { "docstring": null, "function_declaration": "def is_consecutive(values):", "function_name": "is_consecutive", "parameter_list": "(values)"...
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def identify_flush(hand):\n \"\"\"\n Identify whether a given hand of cards forms a flush or a straight flush.\n \n Parameters:\n hand (list of str)...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00092461", "row_id": 92461, "seed_ids": "[15911]" }
0.581414
Taco_92461
I
[ "card_rank_value", "is_consecutive", "identify_hand" ]
3
[ [ "identify_hand", "card_rank_value" ], [ "identify_hand", "is_consecutive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1570c948c328ac566371d01326a064f829d634b4
c2ce01b78ed10d248cb282cd02a99b38f106b55a
v1.0
instruct
Taco
Taco_92488_I
The Kingdom of Monza is constructing a new highway system connecting its cities. Each city is represented as a node, and roads as edges in a weighted graph. The goal is to determine if the highway system can withstand any single road failure without disconnecting the cities. Write a program to determine whether the ne...
from collections import defaultdict def is_connected(graph, n): visited = [False] * n stack = [0] count = 0 visited[0] = True while stack: node = stack.pop() count += 1 for neighbor in graph[node]: if not visited[neighbor]: visited[neighbor] ...
from solution import is_resilient def test_example_1(): n = 5 edges = [ (0, 1, 10), (0, 2, 20), (1, 2, 30), (2, 3, 40), (3, 4, 50), (2, 4, 60) ] assert is_resilient(n, edges) == "The highway system is resilient." def test_vulnerable_example(): n = 4 ...
[ { "docstring": null, "function_declaration": "def is_connected(graph, n):", "function_name": "is_connected", "parameter_list": "(graph, n)" }, { "docstring": null, "function_declaration": "def is_resilient(n, edges):", "function_name": "is_resilient", "parameter_list": "(n, edges...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef is_connected(graph, n):\n visited = [False] * n\n stack = [0]\n count = 0\n visited[0] = True\n \n whi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00092488", "row_id": 92488, "seed_ids": "[12513]" }
0.664693
Taco_92488
I
[ "is_connected", "is_resilient", "main" ]
3
[ [ "is_resilient", "is_connected" ] ]
1
[]
false
[]
false
pytest
true
[]
true
28f207b8802f099537588f5e10408e20eb21e20f
83af0bca329d51a65b2bc1d4e8497c9cb1d8e9f0
v1.0
instruct
Taco
Taco_92514_I
David is working on a project that involves analyzing social networks. One of his tasks is to detect communities within the network. A community in a social network is a group of individuals who are more densely connected to each other than to the rest of the network. David has decided to use the concept of "cliques" t...
import itertools def is_clique(graph, vertices): for i in range(len(vertices)): for j in range(i+1, len(vertices)): if vertices[j] not in graph[vertices[i]]: return False return True def find_maximum_cliques(n, friendships): # Create adjacency list graph = {i: [] fo...
from solution import find_max_clique_in_network def test_sample_input_1(): n = 5 m = 6 friendships = [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)] size, clique = find_max_clique_in_network(n, m, friendships) assert size == 4 assert set(clique) == {1, 2, 3, 4} def test_sample_input_2(): ...
[ { "docstring": null, "function_declaration": "def is_clique(graph, vertices):", "function_name": "is_clique", "parameter_list": "(graph, vertices)" }, { "docstring": null, "function_declaration": "def find_maximum_cliques(n, friendships):", "function_name": "find_maximum_cliques", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\n\ndef find_maximum_cliques(n, m, friendships):\n # Create an adjacency matrix to represent the graph\n adjacency_matrix =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00092514", "row_id": 92514, "seed_ids": "[17531]" }
0.617581
Taco_92514
I
[ "is_clique", "find_maximum_cliques", "find_max_clique_in_network" ]
3
[ [ "find_max_clique_in_network", "find_maximum_cliques" ], [ "find_maximum_cliques", "is_clique" ] ]
2
[]
false
[]
false
pytest
true
[]
true
856535dc88009812586467eb464f145935ba22be
d2f4c126b22a01e0b1f42443373deb2774e0a3bf
v1.0
instruct
Taco
Taco_92545_I
In a fantasy game, there are n different types of magical stones, each with a unique magical power represented by a positive integer. A wizard can merge any two different types of stones to create a new type of stone whose magical power is the absolute difference between the powers of the two stones. Your task is to de...
def min_distinct_stones(n, powers): """ Determines the minimum number of distinct types of stones after performing any number of merge operations. Parameters: n (int): the number of different types of magical stones initially present. powers (list of int): the magical powers of the stones. Ret...
from solution import min_distinct_stones def test_single_stone(): assert min_distinct_stones(1, [7]) == 1 def test_multiple_stones_case_1(): assert min_distinct_stones(3, [5, 9, 12]) == 1 def test_multiple_stones_case_2(): assert min_distinct_stones(4, [8, 16, 24, 32]) == 1 def test_multiple_stones_case...
[ { "docstring": "Determines the minimum number of distinct types of stones after performing any number of merge operations.\n\nParameters:\nn (int): the number of different types of magical stones initially present.\npowers (list of int): the magical powers of the stones.\n\nReturns:\nint: the minimum number of ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def min_distinct_stone_types(n, stone_powers):\n \"\"\"\n Determines the minimum number of distinct types of stones after performing any number of merge oper...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00092545", "row_id": 92545, "seed_ids": "[15588]" }
0.585755
Taco_92545
I
[ "min_distinct_stones", "find_gcd" ]
2
[ [ "min_distinct_stones", "find_gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0cb6d96ca68dfd7b6fb8e88efad708f6aaa2deb
4e440911ad68e019ddf11890d44dd7a6f6978227
v1.0
instruct
Taco
Taco_92564_I
You are given a binary matrix with dimensions N x M. You need to perform Q queries on this matrix. Each query can be of two types: 1. **Switch row i**: Flip all the values in row `i` of the matrix, that is, change all 0s to 1s and all 1s to 0s. 2. **Count ones in row i**: Return the number of 1s in row `i`. Your task...
def switch_row(matrix, row): """ Switch all the values (flip 0s to 1s and 1s to 0s) in the specified row of the matrix. """ matrix[row] = [1 - x for x in matrix[row]] def count_ones_in_row(matrix, row): """ Count the number of 1s in the specified row of the matrix. """ return sum(matrix...
def test_switch_row(): matrix = [[1, 0, 1], [0, 1, 0], [1, 1, 1]] switch_row(matrix, 1) assert matrix == [[1, 0, 1], [1, 0, 1], [1, 1, 1]] def test_count_ones_in_row(): matrix = [[1, 0, 1], [0, 1, 0], [1, 1, 1]] assert count_ones_in_row(matrix, 0) == 2 assert count_ones_in_row(matrix, 1) == 1 ...
[ { "docstring": "Switch all the values (flip 0s to 1s and 1s to 0s) in the specified row of the matrix.", "function_declaration": "def switch_row(matrix, row):", "function_name": "switch_row", "parameter_list": "(matrix, row)" }, { "docstring": "Count the number of 1s in the specified row of ...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def switch_row(matrix, i):\n \"\"\"\n Switch all the values in row i of the matrix.\n \"\"\"\n matrix[i] = [1 - val for val in matrix[i]]\n\ndef count_...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00092564", "row_id": 92564, "seed_ids": "[19212]" }
0.61951
Taco_92564
I
[ "switch_row", "count_ones_in_row", "process_queries" ]
3
[ [ "process_queries", "count_ones_in_row" ], [ "process_queries", "switch_row" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
false
[]
true
9663f6fd8cb29ee9c288d7c1a0078e140796b337
f49713116f4420fa329891244912b1688feca201
v1.0
instruct
Taco
Taco_92575_I
Lucas is fascinated by numbers and their properties. Recently, he learned about digit sums and is particularly interested in finding numbers with special digit sum properties. For any positive integer \( x \), its digit sum is defined as the sum of all its digits. For example, the digit sum of 123 is \( 1 + 2 + 3 = 6 \...
def digit_sum(x): """ Returns the sum of the digits of the number x. """ return sum(int(digit) for digit in str(x)) def max_digit_sum(L, R): """ Returns the number within the range [L, R] with the maximum digit sum. If multiple numbers have the same digit sum, returns the smallest one. ...
from solution import digit_sum, max_digit_sum def test_digit_sum(): assert digit_sum(123) == 6 assert digit_sum(0) == 0 assert digit_sum(999) == 27 def test_max_digit_sum(): assert max_digit_sum(10, 20) == 19 assert max_digit_sum(1, 100) == 99 assert max_digit_sum(50, 60) == 59 assert max_...
[ { "docstring": "Returns the sum of the digits of the number x.", "function_declaration": "def digit_sum(x):", "function_name": "digit_sum", "parameter_list": "(x)" }, { "docstring": "Returns the number within the range [L, R] with the maximum digit sum.\nIf multiple numbers have the same dig...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def digit_sum(x):\n \"\"\"\n Returns the sum of the digits of the number x.\n \"\"\"\n return sum(int(digit) for digit in str(x))\n\ndef max_digit_sum(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00092575", "row_id": 92575, "seed_ids": "[21285]" }
0.719862
Taco_92575
I
[ "digit_sum", "max_digit_sum" ]
2
[ [ "max_digit_sum", "digit_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6513bf44f59197a72a1d04a8c35079595d0b8c3a
db466d4f65b2f6395dbf5dd836667bebc16dbcd1
v1.0
instruct
Taco
Taco_92580_I
Mike is working on a problem involving composite numbers. A composite number is a positive integer greater than 1 that is not prime. In other words, it has at least one divisor other than 1 and itself. Mike has an array of integers and needs to find the longest contiguous subarray where each number is a composite numb...
def is_composite(x): """ Determine if x is a composite number. """ if x <= 1: return False for i in range(2, int(x**0.5) + 1): if x % i == 0: return True return False def longest_composite_subarray(arr): """ Find the length of the longest contiguous subarray ...
from solution import is_composite, longest_composite_subarray def test_is_composite(): assert is_composite(4) == True assert is_composite(6) == True assert is_composite(7) == False assert is_composite(15) == True assert is_composite(97) == False assert is_composite(1) == False def test_lon...
[ { "docstring": "Determine if x is a composite number.", "function_declaration": "def is_composite(x):", "function_name": "is_composite", "parameter_list": "(x)" }, { "docstring": "Find the length of the longest contiguous subarray consisting of only composite numbers.", "function_declara...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_composite(n):\n \"\"\"\n Returns True if n is a composite number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00092580", "row_id": 92580, "seed_ids": "[1874]" }
0.638666
Taco_92580
I
[ "is_composite", "longest_composite_subarray" ]
2
[ [ "longest_composite_subarray", "is_composite" ] ]
1
[]
false
[]
false
pytest
true
[]
true
48ac78427a6ad7725fac8b6f698c97329385cb78
d83734dae4190ab99b31a805716e3586cf95fab9
v1.0
instruct
Taco
Taco_92615_I
Given a string S consisting of only lowercase alphabetic characters, you need to determine how many vowels and consonants are present in the string. For the purpose of this question, vowels are 'a', 'e', 'i', 'o', and 'u', and all other alphabetic characters are consonants. ------ Input Format ------ - A single line ...
def count_vowels_and_consonants(s): """ Returns the count of vowels and consonants in the given string s. """ vowels = 'aeiou' n_vowels = sum(1 for char in s if char in vowels) n_consonants = sum(1 for char in s if char not in vowels) return n_vowels, n_consonants def count_vowels_...
from solution import count_vowels_and_consonants_output def test_hello(): assert count_vowels_and_consonants_output("hello") == "2 3" def test_programming(): assert count_vowels_and_consonants_output("programming") == "3 8" def test_minimum_length_string(): assert count_vowels_and_consonants_output("a") ...
[ { "docstring": "Returns the count of vowels and consonants in the given string s.", "function_declaration": "def count_vowels_and_consonants(s):", "function_name": "count_vowels_and_consonants", "parameter_list": "(s)" }, { "docstring": "Returns the count of vowels and consonants in the give...
[ 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_vowels_and_consonants(s):\n \"\"\"\n Returns the count of vowels and consonants in the string.\n \"\"\"\n vowels = 'aeiou'\n vowel_count =...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00092615", "row_id": 92615, "seed_ids": "[7158]" }
0.751183
Taco_92615
I
[ "count_vowels_and_consonants", "count_vowels_and_consonants_output" ]
2
[ [ "count_vowels_and_consonants_output", "count_vowels_and_consonants" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb7d07c014fdeeff22948dffc9ba60d61ac9fa79
9a38f7ef5994f879e0541ae6eafbcc69b1174968
v1.0
instruct
Taco
Taco_92671_I
Maggu has started to learn numbers and their properties. This time, he is fascinated by prime numbers. His teacher gave him some tasks related to prime numbers, and he has come to you for help. You need to find all unique prime numbers in a given list and then compute their sum. INPUT: The first line of input contai...
def is_prime(num): """Check if a number is prime.""" if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 retur...
from solution import process_input, is_prime, sum_of_unique_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False def test_sum_of_unique_primes(): assert sum_of_unique_primes([(5, [...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Calculate the sum of unique prime numbers in each list of test cases.", "function_declaration": "def sum_of_unique_primes(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Check if a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00092671", "row_id": 92671, "seed_ids": "[12694]" }
0.569241
Taco_92671
I
[ "is_prime", "sum_of_unique_primes", "process_input" ]
3
[ [ "process_input", "sum_of_unique_primes" ], [ "sum_of_unique_primes", "is_prime" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
1f2fa69c4df4f6c6ee1a368d744415a94356a134
e8a89ea8410f58e926b710cb0945f07f9285b285
v1.0
instruct
Taco
Taco_92819_I
Given an integer `n`, find the `nth` Smith Number. A Smith number is a composite number for which the sum of its digits is equal to the sum of the digits in its prime factorization (excluding 1). Example 1: Input: n = 1 Output: 4 Explanation: The first Smith Number is 4 whose prime factors are 2 and 2. Sum of digits ...
def prime_factors(n): """ Helper function to return prime factors of a number """ i = 2 factors = [] while i * i <= n: while n % i == 0: factors.append(i) n //= i i += 1 if n > 1: factors.append(n) return factors def sum_of_digits(n): ...
from solution import nthSmithNumber def test_nthSmithNumber_case1(): assert nthSmithNumber(1) == 4 def test_nthSmithNumber_case2(): assert nthSmithNumber(2) == 22 def test_nthSmithNumber_case3(): assert nthSmithNumber(3) == 27 def test_nthSmithNumber_case4(): assert nthSmithNumber(4) == 58 def test...
[ { "docstring": "Helper function to return prime factors of a number ", "function_declaration": "def prime_factors(n):", "function_name": "prime_factors", "parameter_list": "(n)" }, { "docstring": "Helper function to return sum of digits of a number ", "function_declaration": "def sum_of_...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def prime_factors(n):\n \"\"\" \n Helper function to return prime factors of a number \n \"\"\"\n i = 2\n factors = []\n while i * i <= n:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00092819", "row_id": 92819, "seed_ids": "[11336]" }
0.522616
Taco_92819
I
[ "prime_factors", "sum_of_digits", "is_smith_number", "nthSmithNumber" ]
4
[ [ "is_smith_number", "prime_factors" ], [ "is_smith_number", "sum_of_digits" ], [ "nthSmithNumber", "is_smith_number" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e60d09fe6075b35f788027a1acd3473ce447124c
8f500dffe140e44ff5cc77ccdd5d7b5312a8d433
v1.0
instruct
Taco
Taco_92852_I
Gabriella is learning about numerical palindromes, which are numbers that read the same forwards and backwards. She wants to write a program to find the largest numerical palindrome that can be obtained by multiplying two n-digit numbers. Write a program to help Gabriella by taking in a single integer n and outputting ...
def is_palindrome(num): """ Check if a number is a palindrome. """ return str(num) == str(num)[::-1] def largest_palindrome_product(n): """ Find the largest palindrome product of two n-digit numbers. """ max_num = 10**n - 1 min_num = 10**(n-1) max_palindrome = 0 for i i...
from solution import largest_palindrome_product def test_largest_palindrome_product_1_digit(): assert largest_palindrome_product(1) == 9 def test_largest_palindrome_product_2_digits(): assert largest_palindrome_product(2) == 9009 def test_largest_palindrome_product_3_digits(): assert largest_palindrome_p...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Find the largest palindrome product of two n-digit numbers.", "function_declaration": "def largest_palind...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(num):\n \"\"\"\n Check if a given number is a palindrome.\n \"\"\"\n return str(num) == str(num)[::-1]\n\ndef largest_palindrome_prod...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00092852", "row_id": 92852, "seed_ids": "[6755]" }
0.772632
Taco_92852
I
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
431ddb7744d6fca9a6ee78026a9c4a1c75140d66
6bb0bee99f7a35dea936f1d0fb3300f7c7f20859
v1.0
instruct
Taco
Taco_92877_I
Problem statement Yuki is fascinated by binary trees, and she has recently learned about a special kind of binary tree called "Balanced Binary Tree". A binary tree is considered balanced if, for every node in the tree, the difference in height between its left and right subtrees is at most 1. Yuki has challenged you ...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(index, tree): if index >= len(tree) or tree[index] is None: return None node = TreeNode(tree[index]) node.left = build_tree(2 * index + 1, ...
from solution import is_balanced_binary_tree def test_balanced_tree(): assert is_balanced_binary_tree([3, 9, 20, None, None, 15, 7]) == True def test_unbalanced_tree(): assert is_balanced_binary_tree([1, 2, 2, 3, 3, None, None, 4, 4]) == False def test_empty_tree(): assert is_balanced_binary_tree([]) == ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef is_balanced(tree):\n if not tree:\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00092877", "row_id": 92877, "seed_ids": "[8700]" }
0.800744
Taco_92877
I
[ "build_tree", "isBalanced", "is_balanced_binary_tree" ]
3
[ [ "is_balanced_binary_tree", "build_tree" ], [ "is_balanced_binary_tree", "isBalanced" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
ce7c5487272045b695d14ce1cc8c227aa416d004
bb74f7ffdb75e9490c0d7236827a6cc138741ad2
v1.0
instruct
Taco
Taco_92954_I
Alex is organizing a marathon in his city. The marathon route must be designed such that it visits several key locations and the total distance covered is as minimal as possible. Alex has a list of all the locations and the distances between each pair of locations. Unfortunately, due to city regulations, runners are on...
from collections import defaultdict, deque def find_min_distance(n, paths): # Create a graph adjacency list graph = defaultdict(list) for u, v, d in paths: graph[u].append((v, d)) # Kahn's algorithm for topological sorting in_degree = [0] * n for u in graph: for v, _ in gra...
def test_minimal_marathon_distance_case_1(): n = 3 paths = [ (0, 1, 2), (1, 2, 3) ] assert minimal_marathon_distance(n, paths) == 5 def test_minimal_marathon_distance_case_2(): n = 4 paths = [ (0, 1, 1), (0, 2, 4), (1, 2, 2), (2, 3, 5) ] a...
[ { "docstring": null, "function_declaration": "def find_min_distance(n, paths):", "function_name": "find_min_distance", "parameter_list": "(n, paths)" }, { "docstring": null, "function_declaration": "def minimal_marathon_distance(n, path_info):", "function_name": "minimal_marathon_dis...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict, deque\n\ndef find_min_distance(n, paths):\n # Create a graph adjacency list\n graph = defaultdict(list)\n for u, v, d...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00092954", "row_id": 92954, "seed_ids": "[8730]" }
0.773207
Taco_92954
I
[ "find_min_distance", "minimal_marathon_distance" ]
2
[ [ "minimal_marathon_distance", "find_min_distance" ] ]
1
[]
false
[]
false
pytest
false
[]
true
217d1ae813a4fe5aaa66b253db8a8e1de4bc08ea
2e02ab1fd50aa619e1822d4b990a51981499c3da
v1.0
instruct
Taco
Taco_93015_I
Given an integer N, calculate the product of all prime numbers less than or equal to N. Print the answer as a single integer. Constraints * 1 \leq N \leq 50 Input Input is given from Standard Input in the following format: N Output Print the product of all prime numbers less than or equal to N. Print 1 if no pr...
def is_prime(num): """Returns whether a number is prime.""" if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, product_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(17) == True def test_product_of_primes(): assert product_of_primes...
[ { "docstring": "Returns whether a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the product of all prime numbers less than or equal to N.", "function_declaration": "def product_of_primes(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"Returns whether a number is prime.\"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num %...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00093015", "row_id": 93015, "seed_ids": "[9791]" }
0.613471
Taco_93015
I
[ "is_prime", "product_of_primes" ]
2
[ [ "product_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c2687c66a69dd5672307e3fcdbe8a7a6394b4675
bd107c166d3a50367ca060802db05a988f5bd750
v1.0
instruct
Taco
Taco_93028_I
Given a positive integer K, determine if it's possible to express K as a sum of exactly T prime numbers (not necessarily distinct). -----Constraints----- - All values in input are integers. - 1 \leq K \leq 10^6 - 1 \leq T \leq 100 -----Input----- Input is given from Standard Input in the following format: K T ---...
def is_prime(n): if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while (i * i) <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True def is_sum_of_t_primes(k, t): if t == 1:...
from solution import is_prime, is_sum_of_t_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(30) == False def test_is_sum_of_t_primes(): assert is_sum_of_t_pri...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def is_sum_of_t_primes(k, t):", "function_name": "is_sum_of_t_primes", "parameter_list": "(k, t)" }, { "d...
[ 0, 0, 0, 0, 1 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Returns True if n is a prime number, else False.\"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n ...
trial_gpt4o_4
{ "original_instruction": "", "prompt_id": "00093028", "row_id": 93028, "seed_ids": "[17720]" }
0.544054
Taco_93028
I
[ "is_prime", "is_sum_of_t_primes", "main" ]
3
[ [ "is_sum_of_t_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4a3e6372d0d27cd9b21856d5e3469b998fccf51
0bb9d200e58576f865bf72f1dabff132f63ae40a
v1.0
instruct
Taco
Taco_93084_I
You are given a grid representing a field with obstacles, empty cells, and a single destination cell. Your task is to navigate through the field from a given starting point to the destination using the shortest possible path. The grid has the following characters: * '.' - an empty cell through which you can move. * '#...
from collections import deque def find_shortest_path(grid, start, end): directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] rows, cols = len(grid), len(grid[0]) visited = [[False for _ in range(cols)] for _ in range(rows)] queue = deque([(start[0], start[1], 0)]) # (row, col, distance) while queu...
def test_sample_input1(): input_data = "5 5\nS....\n.....\n..#..\n.#.#.\n....D\n-1" assert main(input_data) == [8] def test_sample_input2(): input_data = "4 5\nS....\n#####\n#...#\n....D\n-1" assert main(input_data) == ["Unreachable"] def test_single_row(): input_data = "1 5\nS...D\n-1" assert...
[ { "docstring": null, "function_declaration": "def find_shortest_path(grid, start, end):", "function_name": "find_shortest_path", "parameter_list": "(grid, start, end)" }, { "docstring": null, "function_declaration": "def find_start_end(grid):", "function_name": "find_start_end", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef shortest_path_in_grid(grid):\n def bfs(start, destination, n, m):\n directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093084", "row_id": 93084, "seed_ids": "[23654]" }
0.764438
Taco_93084
I
[ "find_shortest_path", "find_start_end", "solve_datasets", "parse_input", "main" ]
5
[ [ "solve_datasets", "find_shortest_path" ], [ "solve_datasets", "find_start_end" ] ]
2
[ "solve_datasets", "parse_input" ]
false
[]
false
pytest
false
[]
true
531fa8e2ec3914ed5deb7570b7e0567fd866042f
91e1f2a376faf544796df094e34aabbabe5d3e10
v1.0
instruct
Taco
Taco_93159_I
You are given a list of positive integers. For each integer, determine if the digits of the number form a palindrome (read the same forwards and backwards). If the number is a palindrome, print "Palindrome", otherwise print "Not Palindrome". Input The first line of the input contains the number of test cases T. Each ...
def is_palindrome(num): """ Determines if the digits of the number form a palindrome. """ num_str = str(num) return num_str == num_str[::-1] def determine_palindrome_status(numbers): """ For each number in the list, determine if it is a palindrome and print the result accordingly. """ ...
from solution import is_palindrome, determine_palindrome_status def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(12321) == True assert is_palindrome(1234) == False assert is_palindrome(987789) == True assert is_palindrome(1) == True assert is_palindrome(22) == Tr...
[ { "docstring": "Determines if the digits of the number form a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "For each number in the list, determine if it is a palindrome and print the result acco...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n \"\"\"\n Determines if the digits of the given number form a palindrome.\n \n Args:\n number (int): The number to be ch...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00093159", "row_id": 93159, "seed_ids": "[11241]" }
0.783617
Taco_93159
I
[ "is_palindrome", "determine_palindrome_status" ]
2
[ [ "determine_palindrome_status", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
58b89b823b2b9be373c0a0db0241f3101031c9b9
6e9d8088b7449b8f050e99d60f40cd5d192f8dc2
v1.0
instruct
Taco
Taco_93182_I
A well-known mathematician and logician is creating a puzzle for his students to solve. The puzzle is based on a grid of size n×n. The grid is initially empty and the students need to place numbers in the grid according to the following rules: 1. Each cell in the grid must contain a unique number from 1 to n². 2. The ...
import itertools def is_valid_grid(grid, n, target_sum): for row in grid: if sum(row) != target_sum: return False for col in zip(*grid): if sum(col) != target_sum: return False return True def puzzle_grid(n, R, C): numbers = list(range(1, n * n + 1)) ...
from solution import puzzle_grid def test_sample_input(): result = puzzle_grid(3, 15, 15) assert result[0] == "YES" grid = result[1] assert sum(grid[0]) == 15 assert sum(grid[1]) == 15 assert sum(grid[2]) == 15 for col in zip(*grid): assert sum(col) == 15 def test_invalid_case(): ...
[ { "docstring": null, "function_declaration": "def is_valid_grid(grid, n, target_sum):", "function_name": "is_valid_grid", "parameter_list": "(grid, n, target_sum)" }, { "docstring": null, "function_declaration": "def puzzle_grid(n, R, C):", "function_name": "puzzle_grid", "parame...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef is_valid_grid(grid, n, target_sum):\n for row in grid:\n if sum(row) != target_sum:\n return False\n \n for col ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00093182", "row_id": 93182, "seed_ids": "[9896]" }
0.780891
Taco_93182
I
[ "is_valid_grid", "puzzle_grid", "solve" ]
3
[ [ "puzzle_grid", "is_valid_grid" ], [ "solve", "puzzle_grid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f406b4eaf2db35685ecd16109cc0956d8573b03c
398ed319bf9fda6a776273d78a4f3df5fa61421a
v1.0
instruct
Taco
Taco_93229_I
Consider a grid with N rows and M columns. Each cell in the grid contains an integer. Let the value in the cell at row $i$ and column $j$ be denoted by $a_{ij}$. You are given Q queries, each consisting of four integers $r1, c1, r2, c2$, which represent the top-left and bottom-right coordinates of a subgrid. For each q...
def max_in_subgrid(grid, queries): """ Returns the maximum value within the specified subgrid for each query. Args: grid: List[List[int]] - 2D List representing the grid. queries: List[Tuple[int, int, int, int]] - List of tuples representing the queries. Returns: List[int] - List o...
def test_max_in_subgrid_single_query(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] queries = [(1, 1, 2, 2)] assert max_in_subgrid(grid, queries) == [5] def test_max_in_subgrid_multiple_queries(): grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] ...
[ { "docstring": "Returns the maximum value within the specified subgrid for each query.\n\nArgs:\ngrid: List[List[int]] - 2D List representing the grid.\nqueries: List[Tuple[int, int, int, int]] - List of tuples representing the queries.\n\nReturns:\nList[int] - List of maximum values for each query.", "func...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_max_in_subgrid(grid, queries):\n \"\"\"\n Find the maximum value in the specified subgrid for each query.\n \n Parameters:\n - grid (list o...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093229", "row_id": 93229, "seed_ids": "[21609]" }
0.692118
Taco_93229
I
[ "max_in_subgrid", "solve" ]
2
[ [ "solve", "max_in_subgrid" ] ]
1
[]
false
[]
false
pytest
false
[]
true
9e401b926602384fe0239f7a83c56b3d076964e3
7cbc1074540da6d4281ac24f92854fee9ea53be3
v1.0
instruct
Taco
Taco_93262_I
A well-known professional photographer has been hired to document various festivities in a town. The town's layout can be represented as an odd grid of size $n \times n$, where $1 \le n \le 99$ and $n$ is always odd. The grid is numbered from $1$ to $n$ both horizontally and vertically, and each block in the grid is de...
def is_hamiltonian_walk_possible(r, c, n): """ Checks if a Hamiltonian walk (visiting each grid cell exactly once and returning to the start point) is possible on an odd n x n grid starting from (r, c). """ # For the odd grid n x n when n > 2, there is no possibility to complete the tour return ...
from solution import hamiltonian_tour def test_single_block(): assert hamiltonian_tour(1, 1, 1) == "" def test_3x3_grid(): assert hamiltonian_tour(1, 1, 3) == "impossible" assert hamiltonian_tour(2, 2, 3) == "impossible" assert hamiltonian_tour(3, 3, 3) == "impossible" def test_5x5_grid(): assert...
[ { "docstring": "Checks if a Hamiltonian walk (visiting each grid cell exactly once and returning\nto the start point) is possible on an odd n x n grid starting from (r, c).", "function_declaration": "def is_hamiltonian_walk_possible(r, c, n):", "function_name": "is_hamiltonian_walk_possible", "param...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_hamiltonian_walk_possible(r, c, n):\n \"\"\"\n Checks if a Hamiltonian walk (visiting each grid cell exactly once and returning\n to the start poin...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00093262", "row_id": 93262, "seed_ids": "[18549]" }
0.677791
Taco_93262
I
[ "is_hamiltonian_walk_possible", "get_hamiltonian_path", "hamiltonian_tour" ]
3
[ [ "hamiltonian_tour", "get_hamiltonian_path" ], [ "hamiltonian_tour", "is_hamiltonian_walk_possible" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3fe296a8160d0c2e575332bafc00a8dd7ce7ac02
57852ada0302983ae710584a720dc2382ed8a22f
v1.0
instruct
Taco
Taco_93266_I
In a binary tree, the nodes are colored either red or blue. Your task is to determine the color of the lowest common ancestor (LCA) of two given nodes. The LCA of two nodes p and q in a binary tree is defined as the lowest node that has both p and q as descendants (where we allow a node to be a descendant of itself)....
class TreeNode: def __init__(self, value=0, color='red', left=None, right=None): self.value = value self.color = color self.left = left self.right = right def findLCA(root, p, q): """ Helper function to find the lowest common ancestor of two nodes in the binary tree. """...
import pytest from solution import TreeNode, lcaColor def test_lca_color_sample(): # Construct the sample tree root = TreeNode(1, 'red') root.left = TreeNode(2, 'blue') root.right = TreeNode(3, 'red') root.left.left = TreeNode(4, 'blue') root.left.right = TreeNode(5, 'red') root.right.left ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, value, color, left=None, right=None):\n self.value = value\n self.color = color\n self.left = left\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093266", "row_id": 93266, "seed_ids": "[23542]" }
0.519869
Taco_93266
I
[ "findLCA", "lcaColor" ]
2
[ [ "lcaColor", "findLCA" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
b1b262411c6dff78130495aa55f5b5df20a20dae
2f9f2026c380aedb5e0f07bb3a4e5ed37ff26069
v1.0
instruct
Taco
Taco_93317_I
You are given a grid of NxN cells. Each cell can either contain a coin (represented by a 1) or be empty (represented by a 0). Your task is to find the largest square subgrid that contains only coins. -----Input----- The first line contains an integer T denoting the number of test cases. For each test case, the first l...
def largest_square_with_coins(grid): N = len(grid) dp = [[0] * N for _ in range(N)] max_side = 0 for i in range(N): for j in range(N): if grid[i][j] == 1: if i == 0 or j == 0: dp[i][j] = 1 else: dp[i][j] = min(d...
import pytest from solution import solve_large_square_with_coins, parse_input def test_largest_square_with_coins(): input_data = "2\n4\n1 1 1 0\n1 1 0 0\n1 1 1 1\n0 1 1 1\n5\n1 0 1 1 1\n1 1 1 1 1\n0 1 1 1 1\n1 1 1 1 1\n0 1 1 0 1" test_cases = parse_input(input_data) results = solve_large_square_with_coins(...
[ { "docstring": null, "function_declaration": "def largest_square_with_coins(grid):", "function_name": "largest_square_with_coins", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def solve_large_square_with_coins(test_cases):", "function_name": "solve_larg...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def largest_square_subgrid(T, test_cases):\n def size_of_largest_square(grid, N):\n if N == 0:\n return 0\n \n # dp[i][j] will b...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093317", "row_id": 93317, "seed_ids": "[5155]" }
0.668219
Taco_93317
I
[ "largest_square_with_coins", "solve_large_square_with_coins", "parse_input" ]
3
[ [ "solve_large_square_with_coins", "largest_square_with_coins" ] ]
1
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
5267d819a21047811a430ce0dee8b0f2bc9a3c03
3b601aff4743c75cfc527d5238b450a7a03532b5
v1.0
instruct
Taco
Taco_93354_I
In the fictional country Z, there are n cities connected by m two-way flight routes. Each city has a single significant landmark that is a point of interest for tourists. The tourism board of Z has a problem: tourists wish to visit as many distinct landmarks as possible within a given period of k days. The tour must s...
def bfs_max_landmarks(n, adj, k, start=1): from collections import deque queue = deque([(start, 0, 0)]) # (current_city, days_spent, bitmask_visited) visited = {(start, 0): 0} max_landmarks = 0 while queue: city, days, bm = queue.popleft() landmarks_visited = bin(bm).count('1')...
from solution import max_landmarks_visited def test_case_1(): n = 4 m = 4 k = 3 routes = [(1, 2), (1, 3), (2, 4), (3, 4)] assert max_landmarks_visited(n, m, k, routes) == 3 def test_case_2(): n = 5 m = 6 k = 4 routes = [(1, 2), (1, 3), (2, 3), (2, 4), (3, 5), (4, 5)] assert max...
[ { "docstring": null, "function_declaration": "def bfs_max_landmarks(n, adj, k, start=1):", "function_name": "bfs_max_landmarks", "parameter_list": "(n, adj, k, start=1)" }, { "docstring": null, "function_declaration": "def max_landmarks_visited(n, m, k, routes):", "function_name": "m...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bfs_max_landmarks(n, adj, k, start=1):\n from collections import deque\n queue = deque([(start, 0, 0)]) # (current_city, days_spent, bitmask_visited)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00093354", "row_id": 93354, "seed_ids": "[724]" }
0.809871
Taco_93354
I
[ "bfs_max_landmarks", "max_landmarks_visited" ]
2
[ [ "max_landmarks_visited", "bfs_max_landmarks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0596df0968d0da870a70d2d2ac43aadc966cea2f
ebfd8a85bf0eeb99c12186a69b754eb14cd9e977
v1.0
instruct
Taco
Taco_93380_I
Alice loves arrays, especially those involving interesting properties. She recently encountered a specific type of array called a "beautiful" array. An array $a$ of length $n$ is beautiful if the greatest common divisor (gcd) of all elements of $a$ is greater than 1. Alice wants to determine if an array can be transfo...
import math from functools import reduce def gcd_of_list(nums): return reduce(math.gcd, nums) def can_be_beautiful_array(n, arr): overall_gcd = gcd_of_list(arr) if overall_gcd > 1: return "YES" for i in range(n): temp_arr = arr[:i] + arr[i+1:] if gcd_of_list(temp_arr) > 1: ...
from solution import can_be_beautiful_array, process_input def test_gcd_of_list(): assert gcd_of_list([4, 6, 8]) == 2 assert gcd_of_list([15, 10, 5, 10, 5]) == 5 assert gcd_of_list([7, 5, 9, 11]) == 1 def test_can_be_beautiful_array(): assert can_be_beautiful_array(3, [4, 6, 8]) == "YES" assert ca...
[ { "docstring": null, "function_declaration": "def gcd_of_list(nums):", "function_name": "gcd_of_list", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def can_be_beautiful_array(n, arr):", "function_name": "can_be_beautiful_array", "parameter_list": "(...
[ 0, 0, 0, 1, 1 ]
2
medium
0.4
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import gcd\nfrom functools import reduce\n\ndef is_beautiful_array_possible(n, a):\n \"\"\"\n Determines if we can make the array beautiful by remo...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00093380", "row_id": 93380, "seed_ids": "[5001]" }
0.705976
Taco_93380
I
[ "gcd_of_list", "can_be_beautiful_array", "process_input" ]
3
[ [ "can_be_beautiful_array", "gcd_of_list" ], [ "process_input", "can_be_beautiful_array" ] ]
2
[ "process_input" ]
false
[]
false
pytest
true
[]
true
127170f84994454efeadd93e1551f43782648efc
f6d21e3f22316c9f10f5811a3dbc124b1fa8fd8e
v1.0
instruct
Taco
Taco_93387_I
You are given an undirected graph representing a network of servers and connections between them. The graph consists of `n` servers and `m` bidirectional connections, where the cost of maintaining each connection is given. Your task is to optimize the network in such a way that the total maintenance cost of the connect...
def find(parent, i): """ A function to find the set of an element i using path compression. """ if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): """ A function that does union of two sets of x and y...
from solution import minimum_total_maintenance_cost def test_case_1(): n = 4 m = 5 connections = [ (1, 2, 1), (1, 3, 4), (2, 3, 1), (2, 4, 2), (3, 4, 3) ] assert minimum_total_maintenance_cost(n, m, connections) == 4 def test_case_2(): n = 3 m = 3 ...
[ { "docstring": "A function to find the set of an element i using path compression.", "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": "A function that does union of two sets of x and y using rank.", "function_decla...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef find(parent, i):\n if parent[i] == i:\n return i\n else:\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093387", "row_id": 93387, "seed_ids": "[3071]" }
0.775318
Taco_93387
I
[ "find", "union", "kruskal", "minimum_total_maintenance_cost" ]
4
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "minimum_total_maintenance_cost", "kruskal" ], [ "union", "find" ] ]
4
[]
false
[]
false
pytest
true
[]
true
fee20f7530f293346cdff19384e37d2b9dbe9fa5
54a3bb637158188fde0ea56dee9c933edcf99950
v1.0
instruct
Taco
Taco_93432_I
Lily loves numbers and has recently developed a fascination with prime numbers and their occurrence within ranges. She has challenged you to help her find the closest prime numbers around a given number `n`. You need to write a program to determine the nearest prime numbers less than or equal to `n` and greater than o...
def is_prime(num): """ Returns True if num is a prime number, otherwise False. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return ...
def test_is_prime(): # Test some known primes and non-primes assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == False ...
[ { "docstring": "Returns True if num is a prime number, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the closest prime numbers less than or equal to `n` and greater than or equal to `n`.", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093432", "row_id": 93432, "seed_ids": "[19273]" }
0.661976
Taco_93432
I
[ "is_prime", "closest_primes", "find_closest_primes" ]
3
[ [ "closest_primes", "is_prime" ], [ "find_closest_primes", "closest_primes" ] ]
2
[]
false
[]
false
pytest
false
[]
true
165426baab36c4d5ddf612c47c6b257333cbc10a
b9013ed48c29cf5c92fefe448104f19508f73555
v1.0
instruct
Taco
Taco_93479_I
You have been tasked with assessing the strength of passwords based on certain criteria. A strong password should satisfy the following conditions: 1. It contains at least one uppercase letter. 2. It contains at least one lowercase letter. 3. It contains at least one digit. 4. It contains at least one special character...
def is_strong_password(password): """ Determines whether a password is strong based on the given criteria. """ has_upper = any(c.isupper() for c in password) has_lower = any(c.islower() for c in password) has_digit = any(c.isdigit() for c in password) has_special = any(c in "!@#$%^&*()-+" fo...
from solution import is_strong_password, evaluate_passwords def test_is_strong_password(): # Test cases for strong passwords assert is_strong_password('HelloWorld1!') == True assert is_strong_password('Another$Pass2') == True # Test cases for weak passwords assert is_strong_password('weakpassword1...
[ { "docstring": "Determines whether a password is strong based on the given criteria.", "function_declaration": "def is_strong_password(password):", "function_name": "is_strong_password", "parameter_list": "(password)" }, { "docstring": "Evaluates each of the provided passwords and returns 'S...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_strong_password(password):\n \"\"\"\n Determines if the provided password is strong based on the given criteria.\n \n A strong password must hav...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00093479", "row_id": 93479, "seed_ids": "[985]" }
0.61423
Taco_93479
I
[ "is_strong_password", "evaluate_passwords" ]
2
[ [ "evaluate_passwords", "is_strong_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0d99724d81da1555b126cdff504c2a547d9d3a7
4ef610fa93204d7b96b974bf4137a21d8686c4a6
v1.0
instruct
Taco
Taco_93496_I
Professor Dumbledore has a new idea for encouraging teamwork among Hogwarts students. He has decided to organize a treasure hunt in the Forbidden Forest. Each team, consisting of n students, is required to find hidden treasures. The location of these treasures is described by a list of positions on a number line. Dumb...
from bisect import bisect_left, bisect_right def preprocess_positions(positions): """ Preprocess the positions to allow efficient range queries. """ return sorted(positions) def count_treasures_in_range(positions, l, r): """ Counts the number of treasure positions within the range [l, r]. ...
from solution import preprocess_positions, count_treasures_in_range, process_test_case, solve def test_preprocess_positions(): assert preprocess_positions([5, 2, 10, 7, 12]) == [2, 5, 7, 10, 12] def test_count_treasures_in_range(): positions = preprocess_positions([2, 5, 7, 10, 12]) assert count_treasures...
[ { "docstring": "Preprocess the positions to allow efficient range queries.", "function_declaration": "def preprocess_positions(positions):", "function_name": "preprocess_positions", "parameter_list": "(positions)" }, { "docstring": "Counts the number of treasure positions within the range [l...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_treasure_positions(treasure_positions):\n \"\"\"\n Preprocess the list of treasure positions to enable efficient query answering.\n \"\"\"\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00093496", "row_id": 93496, "seed_ids": "[10188]" }
0.589342
Taco_93496
I
[ "preprocess_positions", "count_treasures_in_range", "process_test_case", "solve" ]
4
[ [ "process_test_case", "count_treasures_in_range" ], [ "process_test_case", "preprocess_positions" ], [ "solve", "process_test_case" ] ]
3
[ "process_test_case" ]
false
[]
false
pytest
true
[]
true
42bd6a6215775561ca4fdce50e7a274e7bf27746
56ca676fd8f62a6e272932371e9dec29978d2f1a
v1.0
instruct
Taco
Taco_93503_I
story Alice loves sequences and often plays with different sequence problems. One day, she encountered a challenging one and thought to take help from you. The sequence Alice is interested in is defined as follows: - Start with an integer x. - If x is even, divide it by 2. - If x is odd, multiply it by 3 and add 1. -...
def collatz_length(n): length = 1 while n != 1: if n % 2 == 0: n = n // 2 else: n = 3 * n + 1 length += 1 return length def longest_collatz_sequence(L, R): max_length = 0 for i in range(L, R + 1): length = collatz_length(i) if length >...
def test_collatz_length(): assert collatz_length(1) == 1 assert collatz_length(2) == 2 assert collatz_length(3) == 8 assert collatz_length(4) == 3 assert collatz_length(10) == 7 def test_longest_collatz_sequence(): assert longest_collatz_sequence(1, 10) == 20 assert longest_collatz_sequence...
[ { "docstring": null, "function_declaration": "def collatz_length(n):", "function_name": "collatz_length", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def longest_collatz_sequence(L, R):", "function_name": "longest_collatz_sequence", "parameter_list": ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def collatz_sequence_length(x):\n \"\"\"\n Returns the length of the Collatz sequence starting with x.\n \"\"\"\n length = 1\n while x != 1:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00093503", "row_id": 93503, "seed_ids": "[22986]" }
0.750607
Taco_93503
I
[ "collatz_length", "longest_collatz_sequence" ]
2
[ [ "longest_collatz_sequence", "collatz_length" ] ]
1
[]
false
[]
false
pytest
false
[]
true
8248f29f4b736d55db709755b85d3e7423d80731
c331ae33257002a4b662a5e81039f913ae33fecf
v1.0
instruct
Taco
Taco_93552_I
Farmer John has a large field where he grows various crops in rectangular parcels. He wants to fence each parcel with a rope but since he aims to minimize waste, he wants to know the minimum length of rope required to completely enclose each parcel. Each parcel is defined by its length l and width w. Your task is to w...
def calculate_rope_length(test_cases): """ Calculate the required length of rope for each test case. Args: test_cases (list of tuples): A list where each element is a tuple (l, w) Returns: list of floats: The length of the rope required for each parcel in the same order as inpu...
from solution import format_rope_length def test_format_rope_length_single_case(): assert format_rope_length([(10.00, 5.00)]) == ["30.00"] def test_format_rope_length_multiple_cases(): assert format_rope_length([(10.00, 5.00), (4.20, 3.10)]) == ["30.00", "14.60"] def test_format_rope_length_decimal_precision...
[ { "docstring": "Calculate the required length of rope for each test case.\n\nArgs:\n test_cases (list of tuples): A list where each element is a tuple (l, w)\n\nReturns:\n list of floats: The length of the rope required for each parcel in the same order as input.", "function_declaration": "def calcula...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_rope_length(l, w):\n \"\"\"\n Returns the minimum length of rope required to enclose a rectangular parcel.\n \"\"\"\n return round(2 * (l...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00093552", "row_id": 93552, "seed_ids": "[4637]" }
0.683685
Taco_93552
I
[ "calculate_rope_length", "format_rope_length" ]
2
[ [ "format_rope_length", "calculate_rope_length" ] ]
1
[]
false
[]
false
pytest
true
[]
true
43dc2abe9531029357bdd8eecadaee7bcfce4a81
727c80d4d9d3b01f3b352e5b5b9837e42180c9c9
v1.0
instruct
Taco
Taco_93553_I
Many people enjoy playing with number games and puzzles. One popular puzzle is finding the largest prime number less than a given number $n$. The definition of a prime number is a natural number greater than $1$ that has no positive divisors other than $1$ and itself. Given an integer $n$ ($2 \le n \le 10^{12}$), find...
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def largest_prime_less_than(n)...
from solution import is_prime, largest_prime_less_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(29) == True assert is_prime(30) == False def test_largest_prime_less_than(): assert large...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def largest_prime_less_than(n):", "function_name": "largest_prime_less_than", "parameter_list": "(n)" } ]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False \n if num <= 3:\n return True \n if num % 2 == 0 or num % 3 == 0:\n return Fal...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00093553", "row_id": 93553, "seed_ids": "[10383]" }
0.597523
Taco_93553
I
[ "is_prime", "largest_prime_less_than" ]
2
[ [ "largest_prime_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
364f80807e104df7765d56c685aa9b6e57dc2e39
c307b93efbec822fed82ea2970ec09ea7507d069
v1.0
instruct
Taco
Taco_93555_I
The Great Wall of China is one of the most iconic symbols of China’s rich history. Various sections of the wall attract vast numbers of tourists throughout the year. In order to manage the influx of visitors more effectively, the authorities need a system that can perform quick analyses based on given data. Specificall...
def average_visitors(data): result = [] for dataset in data: d, s = dataset[0] visitors = dataset[1:] averages = [] for section in range(s): total_visitors = sum(visitors[day][section] for day in range(d)) average = total_visitors / d averages...
from solution import process_great_wall_of_china_data def test_example_1(): input_str = """3 4 120 130 140 150 130 140 150 160 140 150 160 170 2 3 60 70 80 90 100 110 0 0""" expected_output = """130.00 140.00 150.00 160.00 75.00 85.00 95.00""" assert process_great_wall_of_china_data(input_str) == expected_...
[ { "docstring": null, "function_declaration": "def average_visitors(data):", "function_name": "average_visitors", "parameter_list": "(data)" }, { "docstring": null, "function_declaration": "def parse_input(input_str):", "function_name": "parse_input", "parameter_list": "(input_str...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def average_visitors(dataset):\n \"\"\"\n Calculate the average number of visitors per section over a given period.\n Args:\n dataset (list of tuples):...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00093555", "row_id": 93555, "seed_ids": "[9543]" }
0.529984
Taco_93555
I
[ "average_visitors", "parse_input", "format_output", "process_great_wall_of_china_data" ]
4
[ [ "process_great_wall_of_china_data", "average_visitors" ], [ "process_great_wall_of_china_data", "format_output" ], [ "process_great_wall_of_china_data", "parse_input" ] ]
3
[ "parse_input", "format_output" ]
false
[]
false
pytest
true
[]
true
bcc4d9e8d69c4475c29d09dda6871bbfc0b6f892
a7f8cb855df6ae5d096640ac77013c09408c8815
v1.0
instruct
Taco
Taco_93647_I
Given a list of words, create a function that finds and returns the longest word that can be formed by deleting some characters of the given string `s` without reordering the remaining characters. input ==== Two values: - `s` : The string from which we want to form words. - `word_list` : A list containing words to be...
def can_form(word, s): """ Helper function to determine if a word can be formed by deleting some characters of string s without reordering the remaining characters. """ it = iter(s) return all(char in it for char in word) def longest_word(s, word_list): """ Returns the longest word tha...
from solution import longest_word def test_example1(): s = "abpcplea" word_list = ["ale", "apple", "monkey", "plea"] assert longest_word(s, word_list) == "apple" def test_example2(): s = "abpcplea" word_list = ["a", "b", "c"] assert longest_word(s, word_list) == "a" def test_no_word_can_be_fo...
[ { "docstring": "Helper function to determine if a word can be formed by deleting \nsome characters of string s without reordering the remaining characters.", "function_declaration": "def can_form(word, s):", "function_name": "can_form", "parameter_list": "(word, s)" }, { "docstring": "Return...
[ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
2
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_form_word(s, word):\n \"\"\"\n Checks if a word can be formed from string s by deleting some characters.\n \"\"\"\n it = iter(s)\n return al...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00093647", "row_id": 93647, "seed_ids": "[24607]" }
0.718393
Taco_93647
I
[ "can_form", "longest_word" ]
2
[ [ "longest_word", "can_form" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8b28d9d363f0358edc2b69abb5ca7cee75ffa2c2
32c6149c2e0e52c0f232628a1cb91b60691c48d3
v1.0
instruct
Taco
Taco_93718_I
Problem Statement: Alice and Bob love prime numbers and they have decided to play a game with them. They will define a special kind of prime number sequence and need your help to find it. A sequence of length N is considered special if it contains exactly M prime numbers and these M prime numbers are maximized in the ...
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
def test_special_prime_sequences(): test_cases = [(2, 1), (4, 2), (5, 6)] expected_outputs = ["2 1", "2 3 1 1", "SEQUENCE IMPOSSIBLE"] assert special_prime_sequences(3, test_cases) == expected_outputs test_cases = [(10, 0), (10, 1), (10, 10)] expected_outputs = ["1 1 1 1 1 1 1 1 1 1", "2 1 1 1 1 1 ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate all prime numbers up to a given number n.", "function_declaration": "def generate_primes_up_to(n):", "function_na...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093718", "row_id": 93718, "seed_ids": "[8120]" }
0.677012
Taco_93718
I
[ "is_prime", "generate_primes_up_to", "lexicographically_smallest_sequence", "special_prime_sequences" ]
4
[ [ "generate_primes_up_to", "is_prime" ], [ "lexicographically_smallest_sequence", "generate_primes_up_to" ], [ "special_prime_sequences", "lexicographically_smallest_sequence" ] ]
3
[]
false
[]
false
pytest
false
[]
true
3971067b000176b739ae6d476bff3986496c7d70
30e8d81d7b17e9099928eb672a6da66de077996e
v1.0
instruct
Taco
Taco_93729_I
Problem You are given a binary tree, and your task is to write a function that returns the level order traversal of its nodes' values in reverse order. That is, the values should be returned from the bottom level to the top level, with each level's values from left to right. Input The input is given as a sequence of...
from collections import deque class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def build_tree(nodes): """ Builds a binary tree from a list of integers where None represents missing nodes. """ if not nodes: return None ...
from solution import reverse_level_order_traversal def test_case_1(): assert reverse_level_order_traversal([3, 9, 20, None, None, 15, 7]) == [[15, 7], [9, 20], [3]] def test_case_2(): assert reverse_level_order_traversal([1, 2, 3, 4, 5, None, 6, None, None, 7, 8]) == [[7, 8], [4, 5, 6], [2, 3], [1]] def test...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093729", "row_id": 93729, "seed_ids": "[12460]" }
0.57048
Taco_93729
I
[ "build_tree", "level_order_bottom", "reverse_level_order_traversal" ]
3
[ [ "reverse_level_order_traversal", "build_tree" ], [ "reverse_level_order_traversal", "level_order_bottom" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
6560c82f4e2b3b5794fc573834345e2751a8d9a6
6103a3531912d4ee17847719a205ddab1972ebda
v1.0
instruct
Taco
Taco_93761_I
Two players are playing a game with an array of integers. They take turns alternately, picking either the first or last element of the array and removing it. Each player's goal is to maximize the sum of the integers they have picked. Write a function that determines the maximum possible sum that the first player can co...
def max_first_player_sum(test_cases): results = [] for array in test_cases: n = len(array) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = array[i] for length in range(2, n + 1): for i in range(n - length + 1): ...
from solution import game_solver def test_game_solver(): t = 2 cases = [(4, 1, 2, 9, 4), (3, 4, 4, 5)] assert game_solver(t, cases) == [10, 9] def test_single_element(): t = 1 cases = [(1, 7)] assert game_solver(t, cases) == [7] def test_two_elements(): t = 1 cases = [(2, 5, 3)] a...
[ { "docstring": null, "function_declaration": "def max_first_player_sum(test_cases):", "function_name": "max_first_player_sum", "parameter_list": "(test_cases)" }, { "docstring": null, "function_declaration": "def game_solver(t, cases):", "function_name": "game_solver", "parameter...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_first_player_sum(t, cases):\n def dp(arr):\n n = len(arr)\n dp = [[0] * n for _ in range(n)]\n \n for i in range(n):\n ...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00093761", "row_id": 93761, "seed_ids": "[1123]" }
0.739963
Taco_93761
I
[ "max_first_player_sum", "game_solver" ]
2
[ [ "game_solver", "max_first_player_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
42b1a302a83465ec31b400f6ffa273f075510a69
c3c539e130be878173341ea315c88985bdbbb7b8
v1.0
instruct
Taco
Taco_93769_I
You are the manager of a parking lot with multiple rows of parking spaces. Each parking space can be either empty or occupied by a car. Cars are arriving at the parking lot one by one, and you want to park them in the most efficient way. Specifically, you want to ensure that the cars are parked as close to the entrance...
def find_nearest_empty(parking_lot): """ This function finds the coordinates of the nearest empty parking space from the top-left corner. It returns a tuple (row, column) of the nearest empty space. """ for i in range(len(parking_lot)): for j in range(len(parking_lot[0])): if par...
def find_nearest_empty(parking_lot): for i in range(len(parking_lot)): for j in range(len(parking_lot[0])): if parking_lot[i][j] == 'E': return i, j return -1, -1 def park_car(parking_lot): i, j = find_nearest_empty(parking_lot) if i != -1 and j != -1: parkin...
[ { "docstring": "This function finds the coordinates of the nearest empty parking space from the top-left corner.\nIt returns a tuple (row, column) of the nearest empty space.", "function_declaration": "def find_nearest_empty(parking_lot):", "function_name": "find_nearest_empty", "parameter_list": "(...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_nearest_empty(parking_lot):\n \"\"\"\n This function finds the coordinates of the nearest empty parking space from the top-left corner.\n It retu...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00093769", "row_id": 93769, "seed_ids": "[9217]" }
0.644543
Taco_93769
I
[ "find_nearest_empty", "park_car", "process_parking_lot", "main" ]
4
[ [ "park_car", "find_nearest_empty" ], [ "process_parking_lot", "park_car" ] ]
2
[]
false
[]
false
pytest
false
[]
true
a9df70084d1f94746b604801ccb8477b40436542
8316c07db2c6fe50df0e9e14938f8217aefd16e5
v1.0
instruct
Taco
Taco_93788_I
Write a program that reads a series of integers and determines whether each integer is prime or not. The program will read a list of integers terminated by the input value -1, which should not be processed. For each integer, print "Prime" if the number is a prime number, otherwise print "Not Prime". Constraints * -1 ...
def is_prime(n): """ Determines if n is a prime number. Returns True if n is prime, else False. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False ...
from solution import is_prime, process_numbers import pytest from io import StringIO import sys def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(-1) == False assert...
[ { "docstring": "Determines if n is a prime number.\nReturns True if n is prime, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of integers and determines if each is a prime.\nPrints \"Prime\" or \...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a given number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093788", "row_id": 93788, "seed_ids": "[22834]" }
0.675367
Taco_93788
I
[ "is_prime", "process_numbers" ]
2
[ [ "process_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3501975150fa9760bd2381e9c3b82aa6caaa4e8e
9572c45d2bfe9758a64c96a0a1e19f2bac1d11f1
v1.0
instruct
Taco
Taco_93821_I
Alice is participating in a cryptography challenge where she needs to encode and decode messages using a special technique. The technique involves shifting characters in the alphabet by a fixed number of positions. This method is a variant of the Caesar Cipher. Alice needs your help to automate the process of encoding...
def caesar_cipher_char(char, shift): """ Shift a character by the specified number of positions in the alphabet. Wraps around the alphabet if necessary. """ return chr(((ord(char) - ord('A') + shift) % 26) + ord('A')) def caesar_cipher(message, shift, encode=True): """ Encodes or decodes a ...
from solution import process_messages def test_encode_message(): assert process_messages([('E', 'HELLO', 3)]) == ['KHOOR'] def test_decode_message(): assert process_messages([('D', 'KHOOR', 3)]) == ['HELLO'] def test_encode_with_wrap_around(): assert process_messages([('E', 'XYZ', 3)]) == ['ABC'] def te...
[ { "docstring": "Shift a character by the specified number of positions in the alphabet.\nWraps around the alphabet if necessary.", "function_declaration": "def caesar_cipher_char(char, shift):", "function_name": "caesar_cipher_char", "parameter_list": "(char, shift)" }, { "docstring": "Encod...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def shift_character(c, k):\n \"\"\"\n Shifts a single character by k positions in the alphabet. Wraps around if necessary.\n \"\"\"\n return chr((ord(c...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093821", "row_id": 93821, "seed_ids": "[11454]" }
0.617734
Taco_93821
I
[ "caesar_cipher_char", "caesar_cipher", "process_messages" ]
3
[ [ "caesar_cipher", "caesar_cipher_char" ], [ "process_messages", "caesar_cipher" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2897cf10e188781ab60b9f4ca3cae470b63c233f
13aa1b07e9ed1e5b5048f0bbc3112597e28ca483
v1.0
instruct
Taco
Taco_93834_I
Given an array of $N$ integers and two types of queries, perform the operations as described: sum_range l r: Report the sum of the elements from index l to index r (inclusive). increment x y: Increment each element in the array from index x to index y (inclusive) by 1. Input Format The first line contains an integer...
def sum_range(arr, l, r): """ Returns the sum of the elements from index l to r (inclusive). """ return sum(arr[l-1:r]) def increment(arr, x, y): """ Increment each element in the array from index x to index y (inclusive) by 1. """ for i in range(x-1, y): arr[i] += 1 def proces...
from solution import sum_range, increment, process_queries def test_sum_range(): arr = [1, 2, 3, 4, 5] assert sum_range(arr, 1, 3) == 6 assert sum_range(arr, 2, 5) == 14 assert sum_range(arr, 1, 5) == 15 def test_increment(): arr = [1, 2, 3, 4, 5] increment(arr, 2, 4) assert arr == [1, 3, ...
[ { "docstring": "Returns the sum of the elements from index l to r (inclusive).", "function_declaration": "def sum_range(arr, l, r):", "function_name": "sum_range", "parameter_list": "(arr, l, r)" }, { "docstring": "Increment each element in the array from index x to index y (inclusive) by 1....
[ 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 process_queries(n, arr, queries):\n results = []\n array = arr\n \n for query in queries:\n q_parts = query.split()\n if q_parts[0] =...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00093834", "row_id": 93834, "seed_ids": "[10400]" }
0.723237
Taco_93834
I
[ "sum_range", "increment", "process_queries" ]
3
[ [ "process_queries", "increment" ], [ "process_queries", "sum_range" ] ]
2
[ "process_queries" ]
false
[]
false
pytest
true
[]
true
5083e9c5004b5fa5095365cb8f50ea44be8b3747
6e97c194d406bd7feb8967f5d4a7e185e8faf13d
v1.0
instruct
Taco
Taco_93841_I
Mary loves playing with strings and numbers. She has found a unique way to look at strings by associating numbers with each character. She assigns each lowercase letter of the alphabet a distinct prime number, starting from the smallest prime number, 2. For instance: 'a' -> 2, 'b' -> 3, 'c' -> 5, 'd' -> 7, and so on u...
def get_prime_numbers(n): """ Generates a list of the first n prime numbers using the Sieve of Eratosthenes. """ primes = [] candidate = 2 while len(primes) < n: is_prime = all(candidate % prime != 0 for prime in primes) if is_prime: primes.append(candidate) c...
from solution import min_product_equalizable_substrings def test_example_cases(): assert min_product_equalizable_substrings(3, ["aabb", "cdeffedc", "abcdef"]) == [-1, 1, -1] def test_single_letter(): assert min_product_equalizable_substrings(1, ["z"]) == [-1] def test_two_identical_characters(): assert m...
[ { "docstring": "Generates a list of the first n prime numbers using the Sieve of Eratosthenes.", "function_declaration": "def get_prime_numbers(n):", "function_name": "get_prime_numbers", "parameter_list": "(n)" }, { "docstring": "Checks if a given string s can be divided into Product-Equali...
[ 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
1
hard
0.111
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef generate_prime_mapping():\n \"\"\"\n Generate a mapping of characters to the first 26 prime numbers.\n \"\"\"\n def is_prime(n):\n ...
trial_gpt4o_5
{ "original_instruction": "", "prompt_id": "00093841", "row_id": 93841, "seed_ids": "[3688]" }
0.60345
Taco_93841
I
[ "get_prime_numbers", "is_product_equalizable", "min_product_equalizable_substrings" ]
3
[ [ "min_product_equalizable_substrings", "get_prime_numbers" ], [ "min_product_equalizable_substrings", "is_product_equalizable" ] ]
2
[]
false
[]
false
pytest
true
[]
true
88cec95aee334a1ceb0e07031d5a24f6b45fd256
4727748d6d01350a8d5e05f53b5b290c1c686687
v1.0
instruct
Taco
Taco_93898_I
Emma is an avid reader and loves collecting books. She groups her books on shelves in a manner that each shelf can hold exactly `n` books placed in a single row. Emma wants to perform specific operations on her shelves which involve either adding a book or removing a book from specific positions on different shelves. ...
def initialize_shelves(m, n): return [[0] * n for _ in range(m)] def add_book(shelves, s, p, b): shelves[s-1][p-1] = b def get_book(shelves, s, p): return shelves[s-1][p-1] def manage_books(m, n, operations): shelves = initialize_shelves(m, n) results = [] for operation in operations: ...
from solution import initialize_shelves, add_book, get_book, manage_books def test_initialize_shelves(): shelves = initialize_shelves(2, 5) assert shelves == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] def test_add_book(): shelves = initialize_shelves(2, 5) add_book(shelves, 1, 2, 101) assert shelves == [[...
[ { "docstring": null, "function_declaration": "def initialize_shelves(m, n):", "function_name": "initialize_shelves", "parameter_list": "(m, n)" }, { "docstring": null, "function_declaration": "def add_book(shelves, s, p, b):", "function_name": "add_book", "parameter_list": "(shel...
[ 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 manage_books(m, n, operations):\n shelves = [[0] * n for _ in range(m)]\n results = []\n\n for operation in operations:\n op = operation[0]\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00093898", "row_id": 93898, "seed_ids": "[23081]" }
0.652027
Taco_93898
I
[ "initialize_shelves", "add_book", "get_book", "manage_books" ]
4
[ [ "manage_books", "add_book" ], [ "manage_books", "get_book" ], [ "manage_books", "initialize_shelves" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c05c5869c683604430d7260fb01166a203bb38ec
3d62b34eeacde26f2da3d85e06bba91a111c88cf
v1.0
instruct
Taco
Taco_94070_I
Given two integers, Y and B, which are within the range of 1 to 100 (inclusive), your task is to determine whether their sum is a prime number. If their sum is a prime number, print "Prime"; otherwise, print "Not Prime". -----Constraints----- - 1 \leq Y, B \leq 100 - All input values are integers. -----Input----- I...
def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, prime_sum_result def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(9) == False assert is_prime(11) == True assert is_prime(25) == False assert is_prime(97) == T...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Checks if the sum of Y and B is a prime number.\nIf it is, returns \"Prime\"; otherwise \"Not Prime\".",...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns whether a given number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00094070", "row_id": 94070, "seed_ids": "[6451]" }
0.669307
Taco_94070
I
[ "is_prime", "prime_sum_result" ]
2
[ [ "prime_sum_result", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e6ed30b626579dc9fff05fc28f9539d805347465
a850c75e35e0e8a4359898c2b65752abc703ff39
v1.0
instruct
Taco
Taco_94084_I
Write a function to generate the list of the first n happy numbers. Happy numbers are defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1, where it will stay, or it loops endlessly in a cycle ...
def is_happy(number): seen = set() while number != 1 and number not in seen: seen.add(number) number = sum(int(digit) ** 2 for digit in str(number)) return number == 1 def first_n_happy_numbers(n): happy_numbers = [] num = 1 while len(happy_numbers) < n: if is_happy(num)...
from solution import first_n_happy_numbers def test_first_5_happy_numbers(): assert first_n_happy_numbers(5) == [1, 7, 10, 13, 19] def test_first_8_happy_numbers(): assert first_n_happy_numbers(8) == [1, 7, 10, 13, 19, 23, 28, 31] def test_first_happy_number(): assert first_n_happy_numbers(1) == [1] def...
[ { "docstring": null, "function_declaration": "def is_happy(number):", "function_name": "is_happy", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def first_n_happy_numbers(n):", "function_name": "first_n_happy_numbers", "parameter_list": "(n)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_happy(n):\n \"\"\"\n Returns True if the number n is a happy number, else False.\n \"\"\"\n seen = set()\n while n != 1 and n not in seen:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00094084", "row_id": 94084, "seed_ids": "[8825]" }
0.54226
Taco_94084
I
[ "is_happy", "first_n_happy_numbers" ]
2
[ [ "first_n_happy_numbers", "is_happy" ] ]
1
[]
false
[]
false
pytest
true
[]
true
40ff19d7189a397767543e7c9a3181c5bdce5ce7
b9fa7f535b666956e458bef7ff7ea4395f062de1
v1.0
instruct
Taco
Taco_94123_I
### Binary Tree Maximum Path Sum You are given a binary tree where each node contains an integer value. Find the maximum path sum. A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can be part of one or two non-overlapping paths in the ...
from typing import List, Union class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def build_tree(nodes: List[Union[int, None]]) -> TreeNode: if not nodes: return None from collections import deque it = it...
from solution import max_path_sum def test_case_1(): assert max_path_sum(5, [1, -2, 3, None, -1]) == 4 def test_case_2(): assert max_path_sum(3, [-10, 9, 20, None, None, 15, 7]) == 42 def test_case_3(): assert max_path_sum(1, [1]) == 1 def test_case_4(): assert max_path_sum(7, [1, 2, 3, 4, 5, 6, 7])...
[]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
1
hard
0.1
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Union\n\nclass TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef bui...
trial_gpt4o_6
{ "original_instruction": "", "prompt_id": "00094123", "row_id": 94123, "seed_ids": "[8060]" }
0.618039
Taco_94123
I
[ "build_tree", "max_path_sum" ]
2
[ [ "max_path_sum", "build_tree" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
b3ab19e6d6490d1bcc68555dcd8dd822efc051b0
e482b201d9bb415e5c248c22eb98fd5fcdefb27a
v1.0
instruct
Taco
Taco_94136_I
A village is planning to build a network of water pipes to ensure every house has access to water. The village consists of N houses connected by M possible pipes. Each pipe can be installed to connect two houses and has a cost associated with it. Due to budget constraints, they need to minimize the total cost of instal...
def find(parent, i): if parent[i] == i: return i else: parent[i] = find(parent, parent[i]) return parent[i] def union(parent, rank, x, y): rootX = find(parent, x) rootY = find(parent, y) if rootX != rootY: if rank[rootX] > rank[rootY]: parent[rootY] ...
from solution import min_cost_to_provide_water def test_example_case(): N = 4 M = 5 pipes = [ (1, 2, 1), (2, 3, 4), (3, 4, 2), (4, 1, 3), (1, 3, 5) ] assert min_cost_to_provide_water(N, M, pipes) == 6 def test_no_connections(): N = 3 M = 0 pipes ...
[ { "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 rootX = find(parent, x)\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00094136", "row_id": 94136, "seed_ids": "[11929]" }
0.65057
Taco_94136
I
[ "find", "union", "min_cost_to_provide_water" ]
3
[ [ "min_cost_to_provide_water", "find" ], [ "min_cost_to_provide_water", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
4a4933e07ff7da9b51a11cca1f91ae3f57611f2d
51044b802bc8901b846c14b1059727d325024603
v1.0
instruct
Taco
Taco_94238_I
You are given a sequence of distinct integers representing the heights of people standing in a line from left to right. The task is to determine if it's possible to break this sequence into three contiguous subarrays such that each subarray is strictly increasing. -----Input----- The first line contains a single inte...
def can_split_into_increasing_subarrays(t, cases): results = [] for i in range(t): n = cases[i][0] heights = cases[i][1] if n < 3: results.append("NO") continue peak_count = 0 peak_position = [] # Find peaks in th...
def test_can_split_into_increasing_subarrays(): cases = [ (5, [1, 2, 3, 4, 5]), (7, [1, 3, 2, 5, 6, 7, 4]), (4, [1, 3, 2, 4]), (9, [1, 2, 1, 3, 4, 2, 5, 6, 7]) ] expected = ["NO", "YES", "NO", "YES"] assert can_split_into_increasing_subarrays(4, cases) == expected def te...
[ { "docstring": null, "function_declaration": "def can_split_into_increasing_subarrays(t, cases):", "function_name": "can_split_into_increasing_subarrays", "parameter_list": "(t, cases)" }, { "docstring": null, "function_declaration": "def solve():", "function_name": "solve", "par...
[ 0, 0, 0, 1, 0 ]
1
hard
0.2
{ "trial_gpt4o_0": { "file_source": "CodeGen_instruction_taco-i2i_100000_1739866661_sanitized_prepared0_results_combined.jsonl", "solution_code": "def can_divide_into_three_increasing_subarrays(n, heights):\n left = [1] * n\n right = [1] * n\n\n for i in range(1, n):\n if heights[i] > heights[...
trial_gpt4o_3
{ "original_instruction": "", "prompt_id": "00094238", "row_id": 94238, "seed_ids": "[2603]" }
0.750155
Taco_94238
I
[ "can_split_into_increasing_subarrays", "solve" ]
2
[ [ "solve", "can_split_into_increasing_subarrays" ] ]
1
[]
false
[]
false
pytest
false
[]
true
20c2abe7e4b144a57e215225b199495f54af9873
6e43878a8053845812f04d304f03a1c0aafeafa4
v1.0
instruct
Taco
Taco_94348_I
Aisha is fascinated by prime numbers and their unique properties. Recently, she encountered a problem and now she wants you to solve it for her. Given a positive integer, $m$, she wants to find the smallest prime number greater than $m$. Input Format A single integer denoting $m$. Constraints $0 < m \leq 10^6$ Out...
def is_prime(n): """ Checks if a number n is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, smallest_prime_greater_than 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 assert is_prime(29) == True def test_smallest_prime_greater_than(): ass...
[ { "docstring": "Checks if a number n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the smallest prime number greater than m.", "function_declaration": "def smallest_prime_greater_than(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": "import math\n\ndef 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\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00094348", "row_id": 94348, "seed_ids": "[12069]" }
0.572536
Taco_94348
I
[ "is_prime", "smallest_prime_greater_than" ]
2
[ [ "smallest_prime_greater_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1ed5f64e26bf7fe52165bfbbdb8f8b8843b2be77
e571526c760c31f120de17df0d9e507332d064c9