id
stringlengths
36
64
content
stringlengths
278
9.76k
multipl-e_mbpp-cpp_data_mbpp_626_triangle_area
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the area of the largest triangle that can be inscribed in a semicircle with a given radius. std::optional<long> triangle_area(long r) { } int main() { auto candidate = triangle_area; assert(candidate((-1)) == std::nullopt); ass...
multipl-e_mbpp-cpp_data_mbpp_627_find_First_Missing
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the smallest missing number from a sorted vector of natural numbers. long find_First_Missing(std::vector<long> array) { } int main() { auto candidate = find_First_Missing; assert(candidate((std::vector<long>({(long)0, (long)1, (lon...
multipl-e_mbpp-cpp_data_mbpp_628_replace_spaces
#include<assert.h> #include<bits/stdc++.h> // Write a function to replace all spaces in the given string with '%20'. std::string replace_spaces(std::string string) { } int main() { auto candidate = replace_spaces; assert(candidate(("My Name is Dawood")) == ("My%20Name%20is%20Dawood")); assert(candidate(("...
multipl-e_mbpp-cpp_data_mbpp_629_Split
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find even numbers from a vector of numbers. std::vector<long> Split(std::vector<long> list) { } int main() { auto candidate = Split; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3, (long)4, (long)5}))) == (std::vector<lo...
multipl-e_mbpp-cpp_data_mbpp_630_get_coordinates
#include<assert.h> #include<bits/stdc++.h> // Write a function to extract all the adjacent coordinates of the given coordinate tuple. std::vector<std::vector<long>> get_coordinates(std::tuple<long, long> test_tup) { } int main() { auto candidate = get_coordinates; assert(candidate((std::make_tuple(3, 4))) == ...
multipl-e_mbpp-cpp_data_mbpp_631_replace_spaces
#include<assert.h> #include<bits/stdc++.h> // Write a function to replace whitespaces with an underscore and vice versa in a given string. std::string replace_spaces(std::string text) { } int main() { auto candidate = replace_spaces; assert(candidate(("Jumanji The Jungle")) == ("Jumanji_The_Jungle")); ass...
multipl-e_mbpp-cpp_data_mbpp_632_move_zero
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to move all zeroes to the end of the given vector. std::vector<long> move_zero(std::vector<long> num_list) { } int main() { auto candidate = move_zero; assert(candidate((std::vector<long>({(long)1, (long)0, (long)2, (long)0, (long)3, (long...
multipl-e_mbpp-cpp_data_mbpp_633_pair_xor_Sum
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the sum of xor of all pairs of numbers in the given vector. long pair_xor_Sum(std::vector<long> arr, long n) { } int main() { auto candidate = pair_xor_Sum; assert(candidate((std::vector<long>({(long)5, (long)9, (long)7, (long)6}))...
multipl-e_mbpp-cpp_data_mbpp_635_heap_sort
#include<assert.h> #include<bits/stdc++.h> // Write a function to sort the given vector. std::vector<long> heap_sort(std::vector<long> iterable) { } int main() { auto candidate = heap_sort; assert(candidate((std::vector<long>({(long)1, (long)3, (long)5, (long)7, (long)9, (long)2, (long)4, (long)6, (long)8, (l...
multipl-e_mbpp-cpp_data_mbpp_637_noprofit_noloss
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether the given amount has no profit and no loss bool noprofit_noloss(long actual_cost, long sale_amount) { } int main() { auto candidate = noprofit_noloss; assert(candidate((1500), (1200)) == (false)); assert(candidate((100), (100)...
multipl-e_mbpp-cpp_data_mbpp_638_wind_chill
#include<assert.h> #include<bits/stdc++.h> // Write a function to calculate the wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius. long wind_chill(long v, long t) { } int main() { auto candidate = wind_chill; assert(candidate((120), (35)) == (40)); a...
multipl-e_mbpp-cpp_data_mbpp_639_sample_nam
#include<assert.h> #include<bits/stdc++.h> // Write a function to sum the length of the names of a given vector of names after removing the names that start with a lowercase letter. long sample_nam(std::vector<std::string> sample_names) { } int main() { auto candidate = sample_nam; assert(candidate((std::vect...
multipl-e_mbpp-cpp_data_mbpp_640_remove_parenthesis
#include<assert.h> #include<bits/stdc++.h> // Write a function to remove the parenthesis and what is inbetween them from a string. std::string remove_parenthesis(std::vector<std::string> items) { } int main() { auto candidate = remove_parenthesis; assert(candidate((std::vector<std::string>({(std::string)"pyth...
multipl-e_mbpp-cpp_data_mbpp_641_is_nonagonal
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the nth nonagonal number. long is_nonagonal(long n) { } int main() { auto candidate = is_nonagonal; assert(candidate((10)) == (325)); assert(candidate((15)) == (750)); assert(candidate((18)) == (1089)); }
multipl-e_mbpp-cpp_data_mbpp_643_text_match_wordz_middle
#include<assert.h> #include<bits/stdc++.h> // Write a function that checks if a strings contains 'z', except at the start and end of the word. bool text_match_wordz_middle(std::string text) { } int main() { auto candidate = text_match_wordz_middle; assert(candidate(("pythonzabc.")) == (true)); assert(cand...
multipl-e_mbpp-cpp_data_mbpp_644_reverse_Array_Upto_K
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to reverse a vector upto a given position. std::vector<long> reverse_Array_Upto_K(std::vector<long> input, long k) { } int main() { auto candidate = reverse_Array_Upto_K; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3, (lon...
multipl-e_mbpp-cpp_data_mbpp_720_add_dict_to_tuple
#include<assert.h> #include<bits/stdc++.h> // Write a function to add a map to the tuple. The output should be a tuple. std::tuple<long, long, long, std::map<std::string,long>> add_dict_to_tuple(std::tuple<long, long, long> test_tup, std::map<std::string,long> test_dict) { } int main() { auto candidate = add_dict...
multipl-e_mbpp-cpp_data_mbpp_721_maxAverageOfPath
#include<assert.h> #include<bits/stdc++.h> // Given a square matrix of size N*N given as a vector of vectors, where each cell is associated with a specific cost. A path is defined as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell. We want to find a ...
multipl-e_mbpp-cpp_data_mbpp_722_filter_data
#include<assert.h> #include<bits/stdc++.h> // The input is given as - a map with a student name as a key and a tuple of float (student_height, student_weight) as a value, - minimal height, - minimal weight. Write a function to filter students that have height and weight above the minimum. std::map<std::string,std::tupl...
multipl-e_mbpp-cpp_data_mbpp_723_count_same_pair
#include<assert.h> #include<bits/stdc++.h> // The input is defined as two vectors of the same length. Write a function to count indices where the vectors have the same values. long count_same_pair(std::vector<long> nums1, std::vector<long> nums2) { } int main() { auto candidate = count_same_pair; assert(candi...
multipl-e_mbpp-cpp_data_mbpp_724_power_base_sum
#include<assert.h> #include<bits/stdc++.h> // Write a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power. long power_base_sum(long base, long power) { } int main() { auto candidate = power_base_sum; assert(candidate((2), (100)) == (115)); ...
multipl-e_mbpp-cpp_data_mbpp_725_extract_quotation
#include<assert.h> #include<bits/stdc++.h> // Write a function to extract values between quotation marks " " of the given string. std::vector<std::any> extract_quotation(std::string text1) { } int main() { auto candidate = extract_quotation; assert(candidate(("Cortex "A53" Based "multi" tasking "Processor""))...
multipl-e_mbpp-cpp_data_mbpp_726_multiply_elements
#include<assert.h> #include<bits/stdc++.h> // Write a function that takes as input a vector of numbers (t_1,...,t_{N+1}) and returns a vector of length N where the i-th element of the tuple is equal to t_i * t_{i+1}. std::vector<std::any> multiply_elements(std::vector<long> test_tup) { } int main() { auto candida...
multipl-e_mbpp-cpp_data_mbpp_728_sum_list
#include<assert.h> #include<bits/stdc++.h> // Write a function takes as input two vectors [a_1,...,a_n], [b_1,...,b_n] and returns [a_1+b_1,...,a_n+b_n]. std::vector<long> sum_list(std::vector<long> lst1, std::vector<long> lst2) { } int main() { auto candidate = sum_list; assert(candidate((std::vector<long>({...
multipl-e_mbpp-cpp_data_mbpp_730_consecutive_duplicates
#include<assert.h> #include<bits/stdc++.h> // Write a function to remove consecutive duplicates of a given vector. std::vector<std::any> consecutive_duplicates(std::vector<std::any> nums) { } int main() { auto candidate = consecutive_duplicates; assert(candidate((std::vector<std::any>({(long)0, (long)0, (long...
multipl-e_mbpp-cpp_data_mbpp_731_lateralsurface_cone
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the lateral surface area of a cone given radius r and the height h. float lateralsurface_cone(long r, long h) { } int main() { auto candidate = lateralsurface_cone; assert(candidate((5), (12)) == (204.20352248333654f)); assert(candidat...
multipl-e_mbpp-cpp_data_mbpp_732_replace_specialchar
#include<assert.h> #include<bits/stdc++.h> // Write a function to replace all occurrences of spaces, commas, or dots with a colon. std::string replace_specialchar(std::string text) { } int main() { auto candidate = replace_specialchar; assert(candidate(("Python language, Programming language.")) == ("Python:l...
multipl-e_mbpp-cpp_data_mbpp_733_find_first_occurrence
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the index of the first occurrence of a given number in a sorted vector. long find_first_occurrence(std::vector<long> A, long x) { } int main() { auto candidate = find_first_occurrence; assert(candidate((std::vector<long>({(long)2, (long)5,...
multipl-e_mbpp-cpp_data_mbpp_734_sum_Of_Subarray_Prod
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find sum of products of all possible subvectors of a given vector. https://www.geeksforgeeks.org/sum-of-products-of-all-possible-subvectors/ long sum_Of_Subarray_Prod(std::vector<long> arr) { } int main() { auto candidate = sum_Of_Subarray_...
multipl-e_mbpp-cpp_data_mbpp_735_toggle_middle_bits
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to toggle bits of the number except the first and the last bit. https://www.geeksforgeeks.org/toggle-bits-number-expect-first-last-bits/ long toggle_middle_bits(long n) { } int main() { auto candidate = toggle_middle_bits; assert(candidate...
multipl-e_mbpp-cpp_data_mbpp_736_left_insertion
#include<assert.h> #include<bits/stdc++.h> // Write a function to locate the left insertion point for a specified value in sorted order. https://www.w3resource.com/cppthon-exercises/data-structures-and-algorithms/cppthon-data-structure-exercise-24.php long left_insertion(std::vector<long> a, long x) { } int main() { ...
multipl-e_mbpp-cpp_data_mbpp_737_check_str
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether the given string is starting with a vowel or not using regex. bool check_str(std::string string) { } int main() { auto candidate = check_str; assert(candidate(("annie")) == (true)); assert(candidate(("dawood")) == (false)); ...
multipl-e_mbpp-cpp_data_mbpp_738_geometric_sum
#include<assert.h> #include<bits/stdc++.h> // Write a function to calculate the geometric sum of n-1. https://www.w3resource.com/cppthon-exercises/data-structures-and-algorithms/cppthon-recursion-exercise-9.php float geometric_sum(long n) { } int main() { auto candidate = geometric_sum; assert(candidate((7)) ...
multipl-e_mbpp-cpp_data_mbpp_739_find_Index
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the index of smallest triangular number with n digits. https://www.geeksforgeeks.org/index-of-smallest-triangular-number-with-n-digits/ long find_Index(long n) { } int main() { auto candidate = find_Index; assert(candidate((2)) == ...
multipl-e_mbpp-cpp_data_mbpp_740_tuple_to_dict
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert the given tuple to a key-value map using adjacent elements. https://www.geeksforgeeks.org/cppthon-convert-tuple-to-adjacent-pair-map/ std::map<long,long> tuple_to_dict(std::tuple<long, long, long, long, long, long> test_tup) { } int main() { ...
multipl-e_mbpp-cpp_data_mbpp_741_all_Characters_Same
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether all the characters are same or not. bool all_Characters_Same(std::string s) { } int main() { auto candidate = all_Characters_Same; assert(candidate(("python")) == (false)); assert(candidate(("aaa")) == (true)); ass...
multipl-e_mbpp-cpp_data_mbpp_742_area_tetrahedron
#include<assert.h> #include<bits/stdc++.h> // Write a function to caluclate the area of a tetrahedron. float area_tetrahedron(long side) { } int main() { auto candidate = area_tetrahedron; assert(candidate((3)) == (15.588457268119894f)); assert(candidate((20)) == (692.8203230275509f)); assert(candidat...
multipl-e_mbpp-cpp_data_mbpp_743_rotate_right
#include<assert.h> #include<bits/stdc++.h> // Write a function to rotate a given vector by specified number of items to the right direction. https://www.geeksforgeeks.org/cppthon-program-right-rotate-vector-n/ std::vector<long> rotate_right(std::vector<long> list, long m) { } int main() { auto candidate = rotate_...
multipl-e_mbpp-cpp_data_mbpp_744_check_none
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if the given tuple has any none value or not. bool check_none(std::any test_tup) { } int main() { auto candidate = check_none; assert(candidate(std::make_tuple(std::optional<long>(10), std::optional<long>(4), std::optional<long>(5), std::...
multipl-e_mbpp-cpp_data_mbpp_745_divisible_by_digits
#include<assert.h> #include<bits/stdc++.h> // Write a function to find numbers within a given range from startnum ti endnum where every number is divisible by every digit it contains. https://www.w3resource.com/cppthon-exercises/lambda/cppthon-lambda-exercise-24.php std::vector<long> divisible_by_digits(long startnum, ...
multipl-e_mbpp-cpp_data_mbpp_746_sector_area
#include<assert.h> #include<bits/stdc++.h> // Write a function to find area of a sector. The function takes the radius and angle as inputs. Function should return None if the angle is larger than 360 degrees. std::optional<float> sector_area(long r, long a) { } int main() { auto candidate = sector_area; asser...
multipl-e_mbpp-cpp_data_mbpp_747_lcs_of_three
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the longest common subsequence for the given three string sequence. https://www.geeksforgeeks.org/lcs-longest-common-subsequence-three-strings/ long lcs_of_three(std::string X, std::string Y, std::string Z) { } int main() { auto candidate = lc...
multipl-e_mbpp-cpp_data_mbpp_748_capital_words_spaces
#include<assert.h> #include<bits/stdc++.h> // Write a function to put spaces between words starting with capital letters in a given string. std::string capital_words_spaces(std::string str1) { } int main() { auto candidate = capital_words_spaces; assert(candidate(("Python")) == ("Python")); assert(candida...
multipl-e_mbpp-cpp_data_mbpp_749_sort_numeric_strings
#include<assert.h> #include<bits/stdc++.h> // Write a function to sort a given vector of strings of numbers numerically. https://www.geeksforgeeks.org/cppthon-sort-numeric-strings-in-a-vector/ std::vector<long> sort_numeric_strings(std::vector<std::string> nums_str) { } int main() { auto candidate = sort_numeric_...
multipl-e_mbpp-cpp_data_mbpp_750_add_tuple
#include<assert.h> #include<bits/stdc++.h> // Write a function to add the given tuple to the given vector. std::vector<long> add_tuple(std::vector<long> test_list, std::tuple<long, long> test_tup) { } int main() { auto candidate = add_tuple; assert(candidate((std::vector<long>({(long)5, (long)6, (long)7})), (...
multipl-e_mbpp-cpp_data_mbpp_751_check_min_heap
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if the given vector represents min heap or not. https://www.geeksforgeeks.org/how-to-check-if-a-given-vector-represents-a-binary-heap/ bool check_min_heap(std::vector<long> arr) { } int main() { auto candidate = check_min_heap; assert(can...
multipl-e_mbpp-cpp_data_mbpp_752_jacobsthal_num
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the nth jacobsthal number. https://www.geeksforgeeks.org/jacobsthal-and-jacobsthal-lucas-numbers/ 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731, ... long jacobsthal_num(long n) { } int main() { auto candidate = jacobsthal_num; a...
multipl-e_mbpp-cpp_data_mbpp_753_min_k
#include<assert.h> #include<bits/stdc++.h> // Write a function to find minimum k records from tuple vector. https://www.geeksforgeeks.org/cppthon-find-minimum-k-records-from-tuple-vector/ - in this case a verbatim cocpp of test cases std::vector<std::tuple<std::string, long>> min_k(std::vector<std::tuple<std::string, l...
multipl-e_mbpp-cpp_data_mbpp_754_extract_index_list
#include<assert.h> #include<bits/stdc++.h> // We say that an element is common for vectors l1, l2, l3 if it appears in all three vectors under the same index. Write a function to find common elements from three vectors. The function should return a vector. std::vector<std::any> extract_index_list(std::vector<long> l1, ...
multipl-e_mbpp-cpp_data_mbpp_755_second_smallest
#include<assert.h> #include<bits/stdc++.h> union Union_long_float{ long f0; float f1; Union_long_float(long _f0) : f0(_f0) {} Union_long_float(float _f1) : f1(_f1) {} ~Union_long_float() {} bool operator==(long f) { return f0 == f ; } bool operator==(float f) { return f1 ==...
multipl-e_mbpp-cpp_data_mbpp_756_text_match_zero_one
#include<assert.h> #include<bits/stdc++.h> // Write a function that matches a string that has an 'a' followed by one or more 'b's. https://www.w3resource.com/cppthon-exercises/re/cppthon-re-exercise-3.php bool text_match_zero_one(std::string text) { } int main() { auto candidate = text_match_zero_one; assert(...
multipl-e_mbpp-cpp_data_mbpp_757_count_reverse_pairs
#include<assert.h> #include<bits/stdc++.h> // Write a function to count the pairs of reverse strings in the given string vector. https://www.geeksforgeeks.org/cppthon-program-to-count-the-pairs-of-reverse-strings/ long count_reverse_pairs(std::vector<std::string> test_list) { } int main() { auto candidate = count...
multipl-e_mbpp-cpp_data_mbpp_759_is_decimal
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether a given string is a decimal number with a precision of 2. bool is_decimal(std::string num) { } int main() { auto candidate = is_decimal; assert(candidate(("123.11")) == (true)); assert(candidate(("e666.86")) == (false)); a...
multipl-e_mbpp-cpp_data_mbpp_760_unique_Element
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether a vector of numbers contains only one distinct element or not. bool unique_Element(std::vector<long> arr) { } int main() { auto candidate = unique_Element; assert(candidate((std::vector<long>({(long)1, (long)1, (long)1})))...
multipl-e_mbpp-cpp_data_mbpp_762_check_monthnumber_number
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12. bool check_monthnumber_number(long monthnum3) { } int main() { auto candidate = check_monthnumber_number; assert(candidate((6)) == (true)); ...
multipl-e_mbpp-cpp_data_mbpp_763_find_min_diff
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the minimum difference between any two elements in a given vector. https://www.geeksforgeeks.org/find-minimum-difference-pair/ long find_min_diff(std::vector<long> arr, long n) { } int main() { auto candidate = find_min_diff; asser...
multipl-e_mbpp-cpp_data_mbpp_764_number_ctr
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count number of digits in a given string. long number_ctr(std::string str) { } int main() { auto candidate = number_ctr; assert(candidate(("program2bedone")) == (1)); assert(candidate(("3wonders")) == (1)); assert(candidate(("12...
multipl-e_mbpp-cpp_data_mbpp_765_is_polite
#include<assert.h> #include<bits/stdc++.h> // Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/ long is_polite(long n) { } int main() { auto candidate = is_polite; assert(candidate((7)) == (11)); assert(candidate((4)) == (7)); assert(candidate((9)) == (13)); }
multipl-e_mbpp-cpp_data_mbpp_766_pair_wise
#include<assert.h> #include<bits/stdc++.h> // Write a function to return a vector of all pairs of consecutive items in a given vector. std::vector<std::tuple<long, long>> pair_wise(std::vector<long> l1) { } int main() { auto candidate = pair_wise; assert(candidate((std::vector<long>({(long)1, (long)1, (long)2...
multipl-e_mbpp-cpp_data_mbpp_767_get_pairs_count
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count the number of pairs whose sum is equal to ‘sum’. The funtion gets as input a vector of numbers and the sum, long get_pairs_count(std::vector<long> arr, long sum) { } int main() { auto candidate = get_pairs_count; assert(candidate(...
multipl-e_mbpp-cpp_data_mbpp_769_Diff
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to get the difference between two vectors. std::vector<long> Diff(std::vector<long> li1, std::vector<long> li2) { } int main() { auto candidate = Diff; assert(candidate((std::vector<long>({(long)10, (long)15, (long)20, (long)25, (long)30, ...
multipl-e_mbpp-cpp_data_mbpp_770_odd_num_sum
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the sum of fourth power of first n odd natural numbers. long odd_num_sum(long n) { } int main() { auto candidate = odd_num_sum; assert(candidate((2)) == (82)); assert(candidate((3)) == (707)); assert(candidate((4)) == (3108...
multipl-e_mbpp-cpp_data_mbpp_771_check_expression
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/ bool check_expression(std::string exp) { } int main() { auto candidate = check_expression; assert(candidate(("{()}[...
multipl-e_mbpp-cpp_data_mbpp_772_remove_length
#include<assert.h> #include<bits/stdc++.h> // Write a function to remove all the words with k length in the given string. std::string remove_length(std::string test_str, long K) { } int main() { auto candidate = remove_length; assert(candidate(("The person is most value tet"), (3)) == ("person is most value")...
multipl-e_mbpp-cpp_data_mbpp_773_occurance_substring
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the occurrence and position of the substrings within a string. Return None if there is no match. std::optional<std::tuple<std::string, long, long>> occurance_substring(std::string text, std::string pattern) { } int main() { auto candidate = oc...
multipl-e_mbpp-cpp_data_mbpp_775_odd_position
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether every odd index contains odd numbers of a given vector. bool odd_position(std::vector<long> nums) { } int main() { auto candidate = odd_position; assert(candidate((std::vector<long>({(long)2, (long)1, (long)4, (long)3, (lo...
multipl-e_mbpp-cpp_data_mbpp_776_count_vowels
#include<assert.h> #include<bits/stdc++.h> // Write a function to count those characters which have vowels as their neighbors in the given string. long count_vowels(std::string test_str) { } int main() { auto candidate = count_vowels; assert(candidate(("bestinstareels")) == (7)); assert(candidate(("partof...
multipl-e_mbpp-cpp_data_mbpp_777_find_sum
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the sum of non-repeated elements in a given vector. long find_sum(std::vector<long> arr) { } int main() { auto candidate = find_sum; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3, (long)1, (long)1, (long)4, (long)5...
multipl-e_mbpp-cpp_data_mbpp_778_pack_consecutive_duplicates
#include<assert.h> #include<bits/stdc++.h> // Write a function to pack consecutive duplicates of a given vector elements into subvectors. std::vector<std::vector<std::any>> pack_consecutive_duplicates(std::vector<std::any> list1) { } int main() { auto candidate = pack_consecutive_duplicates; assert(candidate(...
multipl-e_mbpp-cpp_data_mbpp_780_find_combinations
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the combinations of sums with tuples in the given tuple vector. https://www.geeksforgeeks.org/cppthon-combinations-of-sum-with-tuples-in-tuple-vector/ std::vector<std::tuple<long, long>> find_combinations(std::vector<std::tuple<long, long>> test_lis...
multipl-e_mbpp-cpp_data_mbpp_781_count_divisors
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether the count of divisors is even. https://www.w3resource.com/cppthon-exercises/basic/cppthon-basic-1-exercise-24.php bool count_divisors(long n) { } int main() { auto candidate = count_divisors; assert(candidate((10)) == (tru...
multipl-e_mbpp-cpp_data_mbpp_782_odd_length_sum
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the sum of all odd length subvectors. https://www.geeksforgeeks.org/sum-of-all-odd-length-subvectors/ long odd_length_sum(std::vector<long> arr) { } int main() { auto candidate = odd_length_sum; assert(candidate((std::vector<long>(...
multipl-e_mbpp-cpp_data_mbpp_783_rgb_to_hsv
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert rgb color to hsv color. https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/ std::vector<float> rgb_to_hsv(long r, long g, long b) { } int main() { auto candidate = rgb_to_hsv; assert(candidate((255), (255), (25...
multipl-e_mbpp-cpp_data_mbpp_784_mul_even_odd
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the product of first even and odd number of a given vector. long mul_even_odd(std::vector<long> list1) { } int main() { auto candidate = mul_even_odd; assert(candidate((std::vector<long>({(long)1, (long)3, (long)5, (long)7, (long)4, (long)...
multipl-e_mbpp-cpp_data_mbpp_785_tuple_str_int
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert tuple string to integer tuple. std::tuple<long, long, long> tuple_str_int(std::string test_str) { } int main() { auto candidate = tuple_str_int; assert(candidate(("(7, 8, 9)")) == (std::make_tuple(7, 8, 9))); assert(candidate(("(1, ...
multipl-e_mbpp-cpp_data_mbpp_786_right_insertion
#include<assert.h> #include<bits/stdc++.h> // Write a function to locate the right insertion point for a specified value in sorted order. long right_insertion(std::vector<long> a, long x) { } int main() { auto candidate = right_insertion; assert(candidate((std::vector<long>({(long)1, (long)2, (long)4, (long)5...
multipl-e_mbpp-cpp_data_mbpp_787_text_match_three
#include<assert.h> #include<bits/stdc++.h> // Write a function that matches a string that has an a followed by three 'b'. bool text_match_three(std::string text) { } int main() { auto candidate = text_match_three; assert(candidate(("ac")) == (false)); assert(candidate(("dc")) == (false)); assert(candi...
multipl-e_mbpp-cpp_data_mbpp_788_new_tuple
#include<assert.h> #include<bits/stdc++.h> // Write a function to create a new tuple from the given string and vector. std::tuple<std::string, std::string, std::string> new_tuple(std::vector<std::string> test_list, std::string test_str) { } int main() { auto candidate = new_tuple; assert(candidate((std::vecto...
multipl-e_mbpp-cpp_data_mbpp_790_even_position
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether every even index contains even numbers of a given vector. bool even_position(std::vector<long> nums) { } int main() { auto candidate = even_position; assert(candidate((std::vector<long>({(long)3, (long)2, (long)1}))) == (f...
multipl-e_mbpp-cpp_data_mbpp_791_remove_nested
#include<assert.h> #include<bits/stdc++.h> // Write a function to remove tuples from the given tuple. std::tuple<long, long, long, long> remove_nested(std::any test_tup) { } int main() { auto candidate = remove_nested; assert(candidate(std::make_tuple(1, 5, 7, std::make_tuple(4, 6), 10)) == (std::make_tuple(1...
multipl-e_mbpp-cpp_data_mbpp_792_count_list
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count the number of vectors in a given number of vectors. long count_list(std::vector<std::vector<long>> input_list) { } int main() { auto candidate = count_list; assert(candidate((std::vector<std::vector<long>>({(std::vector<long>)std:...
multipl-e_mbpp-cpp_data_mbpp_793_last
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the last position of an element in a sorted vector. long last(std::vector<long> arr, long x) { } int main() { auto candidate = last; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3})), (1)) == (0)); assert(candid...
multipl-e_mbpp-cpp_data_mbpp_794_text_starta_endb
#include<assert.h> #include<bits/stdc++.h> // Write a function that matches a string that has an 'a' followed by anything, ending in 'b'. bool text_starta_endb(std::string text) { } int main() { auto candidate = text_starta_endb; assert(candidate(("aabbbb")) == (true)); assert(candidate(("aabAbbbc")) == (...
multipl-e_mbpp-cpp_data_mbpp_796_return_sum
#include<assert.h> #include<bits/stdc++.h> // Write function to find the sum of all items in the given map. long return_sum(std::map<std::string,long> dict) { } int main() { auto candidate = return_sum; assert(candidate((std::map<std::string,long>({{"a", 100}, {"b", 200}, {"c", 300}}))) == (600)); assert(...
multipl-e_mbpp-cpp_data_mbpp_797_sum_in_range
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the sum of all odd natural numbers within the range l and r. long sum_in_range(long l, long r) { } int main() { auto candidate = sum_in_range; assert(candidate((2), (5)) == (8)); assert(candidate((5), (7)) == (12)); assert(...
multipl-e_mbpp-cpp_data_mbpp_798__sum
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the sum of a vector. long _sum(std::vector<long> arr) { } int main() { auto candidate = _sum; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3}))) == (6)); assert(candidate((std::vector<long>({(long)15, (long)12, ...
multipl-e_mbpp-cpp_data_mbpp_799_left_rotate
#include<assert.h> #include<bits/stdc++.h> // Write a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit. long left_rotate(long n, long d) { } int main() { auto candidate = left_rotate; assert(candidate((16), (2)) == (64)); assert(candidate((10), (2)) == (40));...
multipl-e_mbpp-cpp_data_mbpp_800_remove_all_spaces
#include<assert.h> #include<bits/stdc++.h> // Write a function to remove all whitespaces from a string. std::string remove_all_spaces(std::string text) { } int main() { auto candidate = remove_all_spaces; assert(candidate(("python program")) == ("pythonprogram")); assert(candidate(("python programming ...
multipl-e_mbpp-cpp_data_mbpp_801_test_three_equal
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count the number of equal numbers from three given integers. long test_three_equal(long x, long y, long z) { } int main() { auto candidate = test_three_equal; assert(candidate((1), (1), (1)) == (3)); assert(candidate((-1), (-2), (-3...
multipl-e_mbpp-cpp_data_mbpp_802_count_rotation
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count the number of rotations required to generate a sorted vector. https://www.geeksforgeeks.org/count-of-rotations-required-to-generate-a-sorted-vector/ long count_rotation(std::vector<long> arr) { } int main() { auto candidate = count_ro...
multipl-e_mbpp-cpp_data_mbpp_803_is_perfect_square
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether the given number is a perfect square or not. https://www.geeksforgeeks.org/check-if-given-number-is-perfect-square-in-cpp/ bool is_perfect_square(long n) { } int main() { auto candidate = is_perfect_square; assert(candidate((10)) ...
multipl-e_mbpp-cpp_data_mbpp_804_is_product_even
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether the product of numbers in a vector is even or not. bool is_product_even(std::vector<long> arr) { } int main() { auto candidate = is_product_even; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3}))) == (true)); a...
multipl-e_mbpp-cpp_data_mbpp_805_max_sum_list
#include<assert.h> #include<bits/stdc++.h> // Write a function that returns the vector in a vector of vectors whose sum of elements is the highest. std::vector<long> max_sum_list(std::vector<std::vector<long>> lists) { } int main() { auto candidate = max_sum_list; assert(candidate((std::vector<std::vector<lon...
multipl-e_mbpp-cpp_data_mbpp_806_max_run_uppercase
#include<assert.h> #include<bits/stdc++.h> // Write a function to find maximum run of uppercase characters in the given string. long max_run_uppercase(std::string test_str) { } int main() { auto candidate = max_run_uppercase; assert(candidate(("GeMKSForGERksISBESt")) == (5)); assert(candidate(("PrECIOusMO...
multipl-e_mbpp-cpp_data_mbpp_807_first_odd
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the first odd number in a given vector of numbers. long first_odd(std::vector<long> nums) { } int main() { auto candidate = first_odd; assert(candidate((std::vector<long>({(long)1, (long)3, (long)5}))) == (1)); assert(candidate...
multipl-e_mbpp-cpp_data_mbpp_808_check_K
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if the given tuples contain the k or not. bool check_K(std::vector<long> test_tup, long K) { } int main() { auto candidate = check_K; assert(candidate((std::vector<long>({(long)10, (long)4, (long)5, (long)6, (long)8})), (6)) == (true)); ...
multipl-e_mbpp-cpp_data_mbpp_809_check_smaller
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if each element of second tuple is smaller than its corresponding element in the first tuple. bool check_smaller(std::tuple<long, long, long> test_tup1, std::tuple<long, long, long> test_tup2) { } int main() { auto candidate = check_smaller; ...