qid
string
title
string
language
string
signature
string
arguments
sequence
source_py
string
source_cpp
string
question_info
dict
"1"
"Add 1 To A Given Number 1"
"C++"
"int add1ToAGivenNumber1(int x) {"
[ "x" ]
"def add_1_to_a_given_number_1(x): return (- (~ x))"
"int add_1_to_a_given_number_1(int x) { return ( - ( ~ x ) ); }"
{ "extension": "cpp", "entry_fn_name": "add1ToAGivenNumber1", "test_list": "[{\"idx\": 0, \"outputs\": 21, \"inputs\": {\"x\": 20}}, {\"idx\": 1, \"outputs\": 69, \"inputs\": {\"x\": 68}}, {\"idx\": 2, \"outputs\": 53, \"inputs\": {\"x\": 52}}, {\"idx\": 3, \"outputs\": 62, \"inputs\": {\"x\": 61}}, {\"idx\": 4, \"outputs\": 4, \"inputs\": {\"x\": 3}}, {\"idx\": 5, \"outputs\": 89, \"inputs\": {\"x\": 88}}, {\"idx\": 6, \"outputs\": 42, \"inputs\": {\"x\": 41}}, {\"idx\": 7, \"outputs\": 79, \"inputs\": {\"x\": 78}}, {\"idx\": 8, \"outputs\": 95, \"inputs\": {\"x\": 94}}, {\"idx\": 9, \"outputs\": 19, \"inputs\": {\"x\": 18}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int x, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(x), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(20, 21); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(68, 69); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(52, 53); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(61, 62); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(3, 4); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(88, 89); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(41, 42); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(78, 79); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(94, 95); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(18, 19); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"2"
"Add Two Numbers Without Using Arithmetic Operators"
"C++"
"int addTwoNumbersWithoutUsingArithmeticOperators(int x, int y) {"
[ "x", "y" ]
"def add_two_numbers_without_using_arithmetic_operators(x, y): while (y != 0): carry = (x & y) x = (x ^ y) y = (carry << 1) return x"
"int add_two_numbers_without_using_arithmetic_operators(int x, int y) { while ( y != 0 ) { int carry = x & y; x = x ^ y; y = carry << 1; } return x; }"
{ "extension": "cpp", "entry_fn_name": "addTwoNumbersWithoutUsingArithmeticOperators", "test_list": "[{\"idx\": 0, \"outputs\": 116, \"inputs\": {\"x\": 56, \"y\": 60}}, {\"idx\": 1, \"outputs\": 61, \"inputs\": {\"x\": 17, \"y\": 44}}, {\"idx\": 2, \"outputs\": 169, \"inputs\": {\"x\": 73, \"y\": 96}}, {\"idx\": 3, \"outputs\": 78, \"inputs\": {\"x\": 75, \"y\": 3}}, {\"idx\": 4, \"outputs\": 81, \"inputs\": {\"x\": 27, \"y\": 54}}, {\"idx\": 5, \"outputs\": 62, \"inputs\": {\"x\": 61, \"y\": 1}}, {\"idx\": 6, \"outputs\": 128, \"inputs\": {\"x\": 65, \"y\": 63}}, {\"idx\": 7, \"outputs\": 41, \"inputs\": {\"x\": 22, \"y\": 19}}, {\"idx\": 8, \"outputs\": 70, \"inputs\": {\"x\": 61, \"y\": 9}}, {\"idx\": 9, \"outputs\": 120, \"inputs\": {\"x\": 97, \"y\": 23}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int x, int y, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(x, y), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(56, 60, 116); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(17, 44, 61); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(73, 96, 169); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(75, 3, 78); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(27, 54, 81); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(61, 1, 62); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(65, 63, 128); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(22, 19, 41); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(61, 9, 70); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(97, 23, 120); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"3"
"Analysis Of Algorithms Set 2 Asymptotic Analysis"
"C++"
"int analysisOfAlgorithmsSet2AsymptoticAnalysis(vector<int> arr, int n, int x) {"
[ "arr", "n", "x" ]
"def analysis_of_algorithms_set_2_asymptotic_analysis(arr, n, x): i = 0 for i in range(i, n): if (arr[i] == x): return i return (- 1)"
"int analysis_of_algorithms_set_2_asymptotic_analysis(vector<int> arr, int n, int x) { int i; for ( i = 0; i < n; i ++ ) { if ( arr [ i ] == x ) return i; } return - 1; }"
{ "extension": "cpp", "entry_fn_name": "analysisOfAlgorithmsSet2AsymptoticAnalysis", "test_list": "[{\"idx\": 0, \"outputs\": 1, \"inputs\": {\"arr\": [4, 5, 5, 11, 13, 14, 15, 19, 22, 22, 23, 26, 29, 29, 36, 44, 48, 49, 65, 65, 67, 68, 70, 76, 79, 79, 81, 85, 88, 91, 91, 92, 92, 97], \"n\": 17, \"x\": 5}}, {\"idx\": 1, \"outputs\": -1, \"inputs\": {\"arr\": [-24, -78, -32, -48, 0, 4, -42], \"n\": 4, \"x\": 0}}, {\"idx\": 2, \"outputs\": 0, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], \"n\": 6, \"x\": 0}}, {\"idx\": 3, \"outputs\": 2, \"inputs\": {\"arr\": [38, 14, 75, 16, 91, 11, 98, 43, 67, 9, 21, 10, 82, 72, 32, 81, 48, 60, 2, 91, 10, 90, 12, 83], \"n\": 17, \"x\": 75}}, {\"idx\": 4, \"outputs\": -1, \"inputs\": {\"arr\": [-92, -92, -82, -80, -76, -66, -64, -64, -56, -48, -38, -38, -34, -32, -32, -10, -8, -6, -2, 0, 8, 10, 18, 20, 22, 22, 30, 34, 38, 38, 38, 44, 50, 52, 56, 64, 64, 66, 70, 76, 88], \"n\": 25, \"x\": 25}}, {\"idx\": 5, \"outputs\": -1, \"inputs\": {\"arr\": [0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1], \"n\": 11, \"x\": -1}}, {\"idx\": 6, \"outputs\": 1, \"inputs\": {\"arr\": [1, 4, 4, 4, 4, 8, 12, 13, 14, 14, 22, 25, 25, 27, 29, 33, 36, 38, 40, 40, 40, 41, 47, 47, 47, 48, 48, 50, 51, 52, 52, 52, 55, 56, 59, 59, 62, 64, 66, 77, 82, 84, 90, 91, 91, 93], \"n\": 38, \"x\": 4}}, {\"idx\": 7, \"outputs\": -1, \"inputs\": {\"arr\": [-90, -60, -58, -72, 92, 54, -32, -70, -94, 18, 64, -90, -90, -56, 82, -14, -74, -96, -90, -8, -48, 76, -28, 10, -52, -8, -46, -32, 82, 46, 58, 92, 4, 48, -96, -66, 60, 60, 62, -68], \"n\": 22, \"x\": 22}}, {\"idx\": 8, \"outputs\": -1, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], \"n\": 8, \"x\": 8}}, {\"idx\": 9, \"outputs\": -1, \"inputs\": {\"arr\": [42, 17, 77, 96, 72, 36, 74, 97, 7, 94, 80, 7, 27, 58, 49, 81, 51, 9], \"n\": 16, \"x\": 11}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int n, int x, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, n, x), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({4, 5, 5, 11, 13, 14, 15, 19, 22, 22, 23, 26, 29, 29, 36, 44, 48, 49, 65, 65, 67, 68, 70, 76, 79, 79, 81, 85, 88, 91, 91, 92, 92, 97}, 17, 5, 1); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-24, -78, -32, -48, 0, 4, -42}, 4, 0, -1); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}, 6, 0, 0); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({38, 14, 75, 16, 91, 11, 98, 43, 67, 9, 21, 10, 82, 72, 32, 81, 48, 60, 2, 91, 10, 90, 12, 83}, 17, 75, 2); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-92, -92, -82, -80, -76, -66, -64, -64, -56, -48, -38, -38, -34, -32, -32, -10, -8, -6, -2, 0, 8, 10, 18, 20, 22, 22, 30, 34, 38, 38, 38, 44, 50, 52, 56, 64, 64, 66, 70, 76, 88}, 25, 25, -1); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1}, 11, -1, -1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 4, 4, 4, 4, 8, 12, 13, 14, 14, 22, 25, 25, 27, 29, 33, 36, 38, 40, 40, 40, 41, 47, 47, 47, 48, 48, 50, 51, 52, 52, 52, 55, 56, 59, 59, 62, 64, 66, 77, 82, 84, 90, 91, 91, 93}, 38, 4, 1); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-90, -60, -58, -72, 92, 54, -32, -70, -94, 18, 64, -90, -90, -56, 82, -14, -74, -96, -90, -8, -48, 76, -28, 10, -52, -8, -46, -32, 82, 46, 58, 92, 4, 48, -96, -66, 60, 60, 62, -68}, 22, 22, -1); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 1, 1, 1, 1}, 8, 8, -1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({42, 17, 77, 96, 72, 36, 74, 97, 7, 94, 80, 7, 27, 58, 49, 81, 51, 9}, 16, 11, -1); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"4"
"Area Of A Hexagon"
"C++"
"double areaOfAHexagon(double s) {"
[ "s" ]
"def area_of_a_hexagon(s): return (((3 * math.sqrt(3)) * (s * s)) / 2)"
"double area_of_a_hexagon(double s) { return ( ( 3 * sqrt ( 3 ) * ( s * s ) ) / 2 ); }"
{ "extension": "cpp", "entry_fn_name": "areaOfAHexagon", "test_list": "[{\"idx\": 0, \"outputs\": 8163986.207300422, \"inputs\": {\"s\": 1772.6589509256596}}, {\"idx\": 1, \"outputs\": 934487.9989101035, \"inputs\": {\"s\": -599.737107809315}}, {\"idx\": 2, \"outputs\": 2997804.1448343466, \"inputs\": {\"s\": 1074.1765931782}}, {\"idx\": 3, \"outputs\": 3632345.696441302, \"inputs\": {\"s\": -1182.4087746714795}}, {\"idx\": 4, \"outputs\": 169746524.38794258, \"inputs\": {\"s\": 8083.035797247716}}, {\"idx\": 5, \"outputs\": 97513471.98905805, \"inputs\": {\"s\": -6126.414356565494}}, {\"idx\": 6, \"outputs\": 74922068.46663411, \"inputs\": {\"s\": 5370.057504189614}}, {\"idx\": 7, \"outputs\": 125386010.4299519, \"inputs\": {\"s\": -6947.020794285176}}, {\"idx\": 8, \"outputs\": 11572495.990484647, \"inputs\": {\"s\": 2110.5107873533325}}, {\"idx\": 9, \"outputs\": 108379966.88267714, \"inputs\": {\"s\": -6458.751326919488}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(double actual, double expected){\n return abs(actual - expected) < 1e-09;\n}\n\nstring driver(double s, double expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(s), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(1772.6589509256596, 8163986.207300422); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(-599.737107809315, 934487.9989101035); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(1074.1765931782, 2997804.1448343466); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(-1182.4087746714795, 3632345.696441302); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(8083.035797247716, 169746524.38794258); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(-6126.414356565494, 97513471.98905805); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(5370.057504189614, 74922068.46663411); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(-6947.020794285176, 125386010.4299519); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(2110.5107873533325, 11572495.990484647); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(-6458.751326919488, 108379966.88267714); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"5"
"Area Of The Circle That Has A Square And A Circle Inscribed In It"
"C++"
"double areaOfTheCircleThatHasASquareAndACircleInscribedInIt(int a) {"
[ "a" ]
"def area_of_the_circle_that_has_a_square_and_a_circle_inscribed_in_it(a): area = (((math.pi * a) * a) / 4) return area"
"float area_of_the_circle_that_has_a_square_and_a_circle_inscribed_in_it(int a) { float area = ( M_PI * a * a ) / 4.0; return area; }"
{ "extension": "cpp", "entry_fn_name": "areaOfTheCircleThatHasASquareAndACircleInscribedInIt", "test_list": "[{\"idx\": 0, \"outputs\": 4656.625710783471, \"inputs\": {\"a\": 77}}, {\"idx\": 1, \"outputs\": 254.46900494077323, \"inputs\": {\"a\": 18}}, {\"idx\": 2, \"outputs\": 5410.607947645021, \"inputs\": {\"a\": 83}}, {\"idx\": 3, \"outputs\": 1194.5906065275187, \"inputs\": {\"a\": 39}}, {\"idx\": 4, \"outputs\": 3631.6811075498013, \"inputs\": {\"a\": 68}}, {\"idx\": 5, \"outputs\": 615.7521601035994, \"inputs\": {\"a\": 28}}, {\"idx\": 6, \"outputs\": 3959.192141686537, \"inputs\": {\"a\": 71}}, {\"idx\": 7, \"outputs\": 153.93804002589985, \"inputs\": {\"a\": 14}}, {\"idx\": 8, \"outputs\": 346.36059005827474, \"inputs\": {\"a\": 21}}, {\"idx\": 9, \"outputs\": 4185.386812745001, \"inputs\": {\"a\": 73}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(double actual, double expected){\n return abs(actual - expected) < 1e-09;\n}\n\nstring driver(int a, double expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(a), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(77, 4656.625710783471); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(18, 254.46900494077323); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(83, 5410.607947645021); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(39, 1194.5906065275187); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(68, 3631.6811075498013); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(28, 615.7521601035994); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(71, 3959.192141686537); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(14, 153.93804002589985); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(21, 346.36059005827474); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(73, 4185.386812745001); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"6"
"Area Square Circumscribed Circle"
"C++"
"int areaSquareCircumscribedCircle(int r) {"
[ "r" ]
"def area_square_circumscribed_circle(r): return ((2 * r) * r)"
"int area_square_circumscribed_circle(int r) { return ( 2 * r * r ); }"
{ "extension": "cpp", "entry_fn_name": "areaSquareCircumscribedCircle", "test_list": "[{\"idx\": 0, \"outputs\": 392, \"inputs\": {\"r\": 14}}, {\"idx\": 1, \"outputs\": 12168, \"inputs\": {\"r\": 78}}, {\"idx\": 2, \"outputs\": 4050, \"inputs\": {\"r\": 45}}, {\"idx\": 3, \"outputs\": 8712, \"inputs\": {\"r\": 66}}, {\"idx\": 4, \"outputs\": 648, \"inputs\": {\"r\": 18}}, {\"idx\": 5, \"outputs\": 2048, \"inputs\": {\"r\": 32}}, {\"idx\": 6, \"outputs\": 7200, \"inputs\": {\"r\": 60}}, {\"idx\": 7, \"outputs\": 512, \"inputs\": {\"r\": 16}}, {\"idx\": 8, \"outputs\": 19602, \"inputs\": {\"r\": 99}}, {\"idx\": 9, \"outputs\": 8450, \"inputs\": {\"r\": 65}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int r, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(r), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(14, 392); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(78, 12168); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(45, 4050); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(66, 8712); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(18, 648); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(32, 2048); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(60, 7200); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(16, 512); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(99, 19602); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(65, 8450); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"7"
"Array Element Moved K Using Single Moves"
"C++"
"int arrayElementMovedKUsingSingleMoves(vector<int> a, int n, int k) {"
[ "a", "n", "k" ]
"def array_element_moved_k_using_single_moves(a, n, k): if (k >= (n - 1)): return n best = 0 times = 0 for i in range(n): if (a[i] > best): best = a[i] if (i == True): times = 1 else: times += 1 if (times >= k): return best return best"
"int array_element_moved_k_using_single_moves(vector<int> a, int n, int k) { if ( k >= n - 1 ) return n; int best = 0, times = 0; for ( int i = 0; i < n; i ++ ) { if ( a [ i ] > best ) { best = a [ i ]; if ( i ) times = 1; } else times += 1; if ( times >= k ) return best; } return best; }"
{ "extension": "cpp", "entry_fn_name": "arrayElementMovedKUsingSingleMoves", "test_list": "[{\"idx\": 0, \"outputs\": 33, \"inputs\": {\"a\": [2, 5, 5, 9, 10, 10, 11, 14, 23, 27, 31, 32, 33, 33, 33, 37, 39, 41, 41, 42, 42, 43, 47, 60, 61, 68, 73, 73, 73, 78, 80, 80, 82, 83, 86, 87, 89, 92, 94, 98], \"n\": 33, \"k\": 37}}, {\"idx\": 1, \"outputs\": 14, \"inputs\": {\"a\": [80, -58, 64, 48, -16, 60, -50, -52, 62, -86, -96, 52, 26, -30, 14], \"n\": 14, \"k\": 13}}, {\"idx\": 2, \"outputs\": 7, \"inputs\": {\"a\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], \"n\": 7, \"k\": 6}}, {\"idx\": 3, \"outputs\": 4, \"inputs\": {\"a\": [90, 23, 43, 42, 7, 71, 79], \"n\": 4, \"k\": 4}}, {\"idx\": 4, \"outputs\": 64, \"inputs\": {\"a\": [-96, -96, -90, -84, -68, -64, -56, -56, -50, -50, -48, -46, -28, -18, 0, 0, 6, 32, 32, 34, 42, 42, 46, 50, 50, 52, 64, 64, 70, 76, 84, 88], \"n\": 28, \"k\": 21}}, {\"idx\": 5, \"outputs\": 1, \"inputs\": {\"a\": [1, 1, 1], \"n\": 1, \"k\": 2}}, {\"idx\": 6, \"outputs\": 14, \"inputs\": {\"a\": [2, 9, 15, 19, 26, 29, 42, 45, 46, 47, 55, 60, 60, 61, 62, 64, 68, 69, 74, 79, 96], \"n\": 14, \"k\": 17}}, {\"idx\": 7, \"outputs\": 26, \"inputs\": {\"a\": [-32, 12, 80, 42, 80, 8, 58, -76, -42, -98, 22, -90, -16, -4, -62, -32, 28, 12, 78, -52, -84, 78, 88, -76, -52, 68, -34, -16, -4, 2, -78, -94, -22, 34, 6, -62, 72], \"n\": 26, \"k\": 31}}, {\"idx\": 8, \"outputs\": 1, \"inputs\": {\"a\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 26, \"k\": 14}}, {\"idx\": 9, \"outputs\": 1, \"inputs\": {\"a\": [52, 19], \"n\": 1, \"k\": 1}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(vector<int> a, int n, int k, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(a, n, k), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({2, 5, 5, 9, 10, 10, 11, 14, 23, 27, 31, 32, 33, 33, 33, 37, 39, 41, 41, 42, 42, 43, 47, 60, 61, 68, 73, 73, 73, 78, 80, 80, 82, 83, 86, 87, 89, 92, 94, 98}, 33, 37, 33); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({80, -58, 64, 48, -16, 60, -50, -52, 62, -86, -96, 52, 26, -30, 14}, 14, 13, 14); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, 7, 6, 7); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({90, 23, 43, 42, 7, 71, 79}, 4, 4, 4); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-96, -96, -90, -84, -68, -64, -56, -56, -50, -50, -48, -46, -28, -18, 0, 0, 6, 32, 32, 34, 42, 42, 46, 50, 50, 52, 64, 64, 70, 76, 84, 88}, 28, 21, 64); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 1, 1}, 1, 2, 1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({2, 9, 15, 19, 26, 29, 42, 45, 46, 47, 55, 60, 60, 61, 62, 64, 68, 69, 74, 79, 96}, 14, 17, 14); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-32, 12, 80, 42, 80, 8, 58, -76, -42, -98, 22, -90, -16, -4, -62, -32, 28, 12, 78, -52, -84, 78, 88, -76, -52, 68, -34, -16, -4, 2, -78, -94, -22, 34, 6, -62, 72}, 26, 31, 26); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 26, 14, 1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({52, 19}, 1, 1, 1); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"8"
"Array Range Queries Elements Frequency Value"
"C++"
"int arrayRangeQueriesElementsFrequencyValue(int start, int end_arg1, vector<int> arr) {"
[ "start", "end_arg1", "arr" ]
"def array_range_queries_elements_frequency_value(start, end, arr): frequency = dict() for i in range(start, (end + 1)): if (arr[i] in frequency.keys()): frequency[arr[i]] += 1 else: frequency[arr[i]] = 1 count = 0 for x in frequency: if (x == frequency[x]): count += 1 return count"
"int array_range_queries_elements_frequency_value(int start, int end, vector<int> arr) { unordered_map < int, int > frequency; for ( int i = start; i <= end; i ++ ) frequency [ arr [ i ] ] ++; int count = 0; for ( auto x : frequency ) if ( x . first == x . second ) count ++; return count; }"
{ "extension": "cpp", "entry_fn_name": "arrayRangeQueriesElementsFrequencyValue", "test_list": "[{\"idx\": 0, \"outputs\": 3, \"inputs\": {\"start\": 0, \"end_arg1\": 31, \"arr\": [1, 2, 2, 3, 3, 3, 12, 13, 18, 18, 26, 28, 29, 36, 37, 39, 40, 49, 55, 57, 63, 69, 69, 73, 85, 86, 87, 87, 89, 89, 90, 91, 92, 93, 93, 93, 95, 99]}}, {\"idx\": 1, \"outputs\": 2, \"inputs\": {\"start\": 1, \"end_arg1\": 25, \"arr\": [24, -62, 2, 1, 94, 56, -22, -70, -22, -34, -92, -18, 56, 2, 60, 38, -88, 16, -28, 30, -30, 58, -80, 94, 6, 56]}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"start\": 3, \"end_arg1\": 4, \"arr\": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}}, {\"idx\": 3, \"outputs\": 0, \"inputs\": {\"start\": 10, \"end_arg1\": 15, \"arr\": [84, 13, 81, 40, 87, 82, 50, 30, 90, 80, 81, 70, 14, 54, 72, 93, 78, 27, 61]}}, {\"idx\": 4, \"outputs\": 0, \"inputs\": {\"start\": 2, \"end_arg1\": 3, \"arr\": [-20, 20, 34, 60, 90]}}, {\"idx\": 5, \"outputs\": 1, \"inputs\": {\"start\": 0, \"end_arg1\": 6, \"arr\": [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]}}, {\"idx\": 6, \"outputs\": 0, \"inputs\": {\"start\": 14, \"end_arg1\": 18, \"arr\": [11, 18, 18, 19, 25, 30, 42, 42, 56, 58, 63, 66, 67, 68, 69, 75, 78, 83, 83]}}, {\"idx\": 7, \"outputs\": 0, \"inputs\": {\"start\": 29, \"end_arg1\": 33, \"arr\": [-24, -82, 24, -84, 94, 2, -30, 86, 58, -56, -96, 60, -38, 76, 94, 74, -98, -84, -38, 46, 4, -84, -90, -28, -50, 46, 16, 28, -14, -82, -64, 42, 64, -2, -40, 96, 60, 2, -86, 32, 38, -66]}}, {\"idx\": 8, \"outputs\": 0, \"inputs\": {\"start\": 31, \"end_arg1\": 19, \"arr\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}}, {\"idx\": 9, \"outputs\": 0, \"inputs\": {\"start\": 21, \"end_arg1\": 32, \"arr\": [2, 91, 42, 85, 97, 92, 24, 39, 63, 89, 31, 59, 51, 89, 72, 62, 26, 92, 75, 4, 6, 13, 20, 95, 22, 30, 52, 60, 37, 27, 49, 15, 67, 26]}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int start, int end_arg1, vector<int> arr, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(start, end_arg1, arr), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(0, 31, {1, 2, 2, 3, 3, 3, 12, 13, 18, 18, 26, 28, 29, 36, 37, 39, 40, 49, 55, 57, 63, 69, 69, 73, 85, 86, 87, 87, 89, 89, 90, 91, 92, 93, 93, 93, 95, 99}, 3); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(1, 25, {24, -62, 2, 1, 94, 56, -22, -70, -22, -34, -92, -18, 56, 2, 60, 38, -88, 16, -28, 30, -30, 58, -80, 94, 6, 56}, 2); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(3, 4, {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 15, {84, 13, 81, 40, 87, 82, 50, 30, 90, 80, 81, 70, 14, 54, 72, 93, 78, 27, 61}, 0); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(2, 3, {-20, 20, 34, 60, 90}, 0); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(0, 6, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(14, 18, {11, 18, 18, 19, 25, 30, 42, 42, 56, 58, 63, 66, 67, 68, 69, 75, 78, 83, 83}, 0); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(29, 33, {-24, -82, 24, -84, 94, 2, -30, 86, 58, -56, -96, 60, -38, 76, 94, 74, -98, -84, -38, 46, 4, -84, -90, -28, -50, 46, 16, 28, -14, -82, -64, 42, 64, -2, -40, 96, 60, 2, -86, 32, 38, -66}, 0); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(31, 19, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 0); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(21, 32, {2, 91, 42, 85, 97, 92, 24, 39, 63, 89, 31, 59, 51, 89, 72, 62, 26, 92, 75, 4, 6, 13, 20, 95, 22, 30, 52, 60, 37, 27, 49, 15, 67, 26}, 0); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"9"
"Basic And Extended Euclidean Algorithms"
"C++"
"int basicAndExtendedEuclideanAlgorithms(int a, int b) {"
[ "a", "b" ]
"def basic_and_extended_euclidean_algorithms(a, b): if (a == 0): return b return basic_and_extended_euclidean_algorithms((b % a), a)"
"int basic_and_extended_euclidean_algorithms(int a, int b) { if ( a == 0 ) return b; return basic_and_extended_euclidean_algorithms ( b % a, a ); }"
{ "extension": "cpp", "entry_fn_name": "basicAndExtendedEuclideanAlgorithms", "test_list": "[{\"idx\": 0, \"outputs\": 1, \"inputs\": {\"a\": 46, \"b\": 89}}, {\"idx\": 1, \"outputs\": 2, \"inputs\": {\"a\": 26, \"b\": 82}}, {\"idx\": 2, \"outputs\": 4, \"inputs\": {\"a\": 40, \"b\": 12}}, {\"idx\": 3, \"outputs\": 2, \"inputs\": {\"a\": 58, \"b\": 4}}, {\"idx\": 4, \"outputs\": 1, \"inputs\": {\"a\": 25, \"b\": 44}}, {\"idx\": 5, \"outputs\": 1, \"inputs\": {\"a\": 2, \"b\": 87}}, {\"idx\": 6, \"outputs\": 1, \"inputs\": {\"a\": 8, \"b\": 65}}, {\"idx\": 7, \"outputs\": 3, \"inputs\": {\"a\": 21, \"b\": 87}}, {\"idx\": 8, \"outputs\": 2, \"inputs\": {\"a\": 82, \"b\": 10}}, {\"idx\": 9, \"outputs\": 1, \"inputs\": {\"a\": 17, \"b\": 61}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int a, int b, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(a, b), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(46, 89, 1); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(26, 82, 2); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(40, 12, 4); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(58, 4, 2); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(25, 44, 1); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(2, 87, 1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(8, 65, 1); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(21, 87, 3); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(82, 10, 2); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(17, 61, 1); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"10"
"Bell Numbers Number Of Ways To Partition A Set"
"C++"
"int bellNumbersNumberOfWaysToPartitionASet(int n) {"
[ "n" ]
"def bell_numbers_number_of_ways_to_partition_a_set(n): bell = [[0 for i in range((n + 1))] for j in range((n + 1))] bell[0][0] = 1 for i in range(1, (n + 1)): bell[i][0] = bell[(i - 1)][(i - 1)] for j in range(1, (i + 1)): bell[i][j] = (bell[(i - 1)][(j - 1)] + bell[i][(j - 1)]) return bell[n][0]"
"int bell_numbers_number_of_ways_to_partition_a_set(int n) { int bell [ n + 1 ] [ n + 1 ]; bell [ 0 ] [ 0 ] = 1; for ( int i = 1; i <= n; i ++ ) { bell [ i ] [ 0 ] = bell [ i - 1 ] [ i - 1 ]; for ( int j = 1; j <= i; j ++ ) bell [ i ] [ j ] = bell [ i - 1 ] [ j - 1 ] + bell [ i ] [ j - 1 ]; } return bell [ n ] [ 0 ]; }"
{ "extension": "cpp", "entry_fn_name": "bellNumbersNumberOfWaysToPartitionASet", "test_list": "[{\"idx\": 0, \"outputs\": 21147, \"inputs\": {\"n\": 9}}, {\"idx\": 1, \"outputs\": 15, \"inputs\": {\"n\": 4}}, {\"idx\": 2, \"outputs\": 203, \"inputs\": {\"n\": 6}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int n, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(9, 21147); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(4, 15); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(6, 203); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"11"
"Binary Search"
"C++"
"int binarySearch(vector<int> arr, int l, int r, int x) {"
[ "arr", "l", "r", "x" ]
"def binary_search(arr, l, r, x): if (r >= l): mid = (l + ((r - l) // 2)) if (arr[mid] == x): return mid elif (arr[mid] > x): return binary_search(arr, l, (mid - 1), x) else: return binary_search(arr, (mid + 1), r, x) else: return (- 1)"
"int binary_search(vector<int> arr, int l, int r, int x) { if ( r >= l ) { int mid = l + ( r - l ) / 2; if ( arr [ mid ] == x ) return mid; if ( arr [ mid ] > x ) return binary_search ( arr, l, mid - 1, x ); return binary_search ( arr, mid + 1, r, x ); } return - 1; }"
{ "extension": "cpp", "entry_fn_name": "binarySearch", "test_list": "[{\"idx\": 0, \"outputs\": -1, \"inputs\": {\"arr\": [3, 4, 4, 8, 9, 13, 13, 15, 18, 27, 30, 32, 42, 48, 50, 52, 56, 66, 69, 69, 77, 84, 84, 93], \"l\": 19, \"r\": 12, \"x\": 22}}, {\"idx\": 1, \"outputs\": -1, \"inputs\": {\"arr\": [52, -58, -22, -80, 44, -52, -34, 94, -34, -74, 42, 60, -62, 70, 98, 32, 10, 94, 26, 56, -48, -50, 42, 2, 46, 28, -68, -16, -96, -12, 66, -46, 74, -60, -52, 28, -92, -78, 32, 28, 16, 34, 30, -60, -14], \"l\": 40, \"r\": 35, \"x\": 44}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"arr\": [0, 1], \"l\": 1, \"r\": 1, \"x\": 1}}, {\"idx\": 3, \"outputs\": -1, \"inputs\": {\"arr\": [28, 84, 40, 81], \"l\": 2, \"r\": 2, \"x\": 2}}, {\"idx\": 4, \"outputs\": -1, \"inputs\": {\"arr\": [-66, -62, -60, -56, -56, -2, 40, 44, 50, 74, 82, 94], \"l\": 8, \"r\": 6, \"x\": 8}}, {\"idx\": 5, \"outputs\": -1, \"inputs\": {\"arr\": [1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1], \"l\": 7, \"r\": 7, \"x\": 10}}, {\"idx\": 6, \"outputs\": -1, \"inputs\": {\"arr\": [15, 26, 31, 36, 36, 61, 68, 72, 75, 79, 82, 98], \"l\": 6, \"r\": 7, \"x\": 8}}, {\"idx\": 7, \"outputs\": -1, \"inputs\": {\"arr\": [0, -82, -94, 48, 48, -96, 14, 66, 76, -30, 86, 28, -28, -66, -64, 92, -94, -66, 86, 26, 8, 94, -82, -80, 4, -26, 76, -46, 72, 88, -6, 8, -30, 40, -88, 2, -40, -98, -22, -20, 4, -12, 54, -20, -36, 12], \"l\": 38, \"r\": 33, \"x\": 39}}, {\"idx\": 8, \"outputs\": -1, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], \"l\": 12, \"r\": 10, \"x\": 6}}, {\"idx\": 9, \"outputs\": -1, \"inputs\": {\"arr\": [81, 47], \"l\": 1, \"r\": 1, \"x\": 1}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int l, int r, int x, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, l, r, x), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({3, 4, 4, 8, 9, 13, 13, 15, 18, 27, 30, 32, 42, 48, 50, 52, 56, 66, 69, 69, 77, 84, 84, 93}, 19, 12, 22, -1); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({52, -58, -22, -80, 44, -52, -34, 94, -34, -74, 42, 60, -62, 70, 98, 32, 10, 94, 26, 56, -48, -50, 42, 2, 46, 28, -68, -16, -96, -12, 66, -46, 74, -60, -52, 28, -92, -78, 32, 28, 16, 34, 30, -60, -14}, 40, 35, 44, -1); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 1}, 1, 1, 1, 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({28, 84, 40, 81}, 2, 2, 2, -1); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-66, -62, -60, -56, -56, -2, 40, 44, 50, 74, 82, 94}, 8, 6, 8, -1); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1}, 7, 7, 10, -1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({15, 26, 31, 36, 36, 61, 68, 72, 75, 79, 82, 98}, 6, 7, 8, -1); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, -82, -94, 48, 48, -96, 14, 66, 76, -30, 86, 28, -28, -66, -64, 92, -94, -66, 86, 26, 8, 94, -82, -80, 4, -26, 76, -46, 72, 88, -6, 8, -30, 40, -88, 2, -40, -98, -22, -20, 4, -12, 54, -20, -36, 12}, 38, 33, 39, -1); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, 12, 10, 6, -1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({81, 47}, 1, 1, 1, -1); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"12"
"Breaking Number First Part Integral Division Second Power 10"
"C++"
"int breakingNumberFirstPartIntegralDivisionSecondPower10(string n) {"
[ "n" ]
"def breaking_number_first_part_integral_division_second_power_10(N): length = len(N) l = int((length / 2)) count = 0 for i in range((l + 1)): s = N[0:(0 + i)] l1 = len(s) t = N[i:(l1 + i)] try: if ((s[0] == '0') or (t[0] == '0')): continue except: continue if (s == t): count += 1 return count"
"int breaking_number_first_part_integral_division_second_power_10(string N) { int len = N . length ( ); int l = ( len ) / 2; int count = 0; for ( int i = 1; i <= l; i ++ ) { string s = N . substr ( 0, i ); int l1 = s . length ( ); string t = N . substr ( i, l1 ); if ( s [ 0 ] == '0' || t [ 0 ] == '0' ) continue; if ( s . compare ( t ) == 0 ) count ++; } return count; }"
{ "extension": "cpp", "entry_fn_name": "breakingNumberFirstPartIntegralDivisionSecondPower10", "test_list": "[{\"idx\": 0, \"outputs\": 0, \"inputs\": {\"n\": \"ZCoQhuM\"}}, {\"idx\": 1, \"outputs\": 0, \"inputs\": {\"n\": \"2674377254\"}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"n\": \"11\"}}, {\"idx\": 3, \"outputs\": 0, \"inputs\": {\"n\": \"LbuGlvRyWAPBpo\"}}, {\"idx\": 4, \"outputs\": 0, \"inputs\": {\"n\": \"26382426486138\"}}, {\"idx\": 5, \"outputs\": 2, \"inputs\": {\"n\": \"111010111010\"}}, {\"idx\": 6, \"outputs\": 0, \"inputs\": {\"n\": \"hUInqJXNdbfP\"}}, {\"idx\": 7, \"outputs\": 0, \"inputs\": {\"n\": \"5191\"}}, {\"idx\": 8, \"outputs\": 1, \"inputs\": {\"n\": \"1110101101\"}}, {\"idx\": 9, \"outputs\": 2, \"inputs\": {\"n\": \"2202200\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(string n, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"ZCoQhuM\", 0); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"2674377254\", 0); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"11\", 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"LbuGlvRyWAPBpo\", 0); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"26382426486138\", 0); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"111010111010\", 2); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"hUInqJXNdbfP\", 0); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"5191\", 0); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"1110101101\", 1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"2202200\", 2); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"15"
"Calculate Area Tetrahedron"
"C++"
"float calculateAreaTetrahedron(int side) {"
[ "side" ]
"def calculate_area_tetrahedron(side): volume = ((side ** 3) / (6 * math.sqrt(2))) return round(volume, 2)"
"double calculate_area_tetrahedron(int side) { double volume = ( pow ( side, 3 ) / ( 6 * sqrt ( 2 ) ) ); return volume; }"
{ "extension": "cpp", "entry_fn_name": "calculateAreaTetrahedron", "test_list": "[{\"idx\": 0, \"outputs\": 22994.17, \"inputs\": {\"side\": 58}}, {\"idx\": 1, \"outputs\": 20696.54, \"inputs\": {\"side\": 56}}, {\"idx\": 2, \"outputs\": 5052.87, \"inputs\": {\"side\": 35}}, {\"idx\": 3, \"outputs\": 114350.83, \"inputs\": {\"side\": 99}}, {\"idx\": 4, \"outputs\": 258.92, \"inputs\": {\"side\": 13}}, {\"idx\": 5, \"outputs\": 10739.18, \"inputs\": {\"side\": 45}}, {\"idx\": 6, \"outputs\": 7542.47, \"inputs\": {\"side\": 40}}, {\"idx\": 7, \"outputs\": 91769.26, \"inputs\": {\"side\": 92}}, {\"idx\": 8, \"outputs\": 40.42, \"inputs\": {\"side\": 7}}, {\"idx\": 9, \"outputs\": 258.92, \"inputs\": {\"side\": 13}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(float actual, float expected){\n return abs(actual - expected) < 1e-06;\n}\n\nstring driver(int side, float expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(side), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(58, 22994.17); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(56, 20696.54); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(35, 5052.87); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(99, 114350.83); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(13, 258.92); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(45, 10739.18); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(40, 7542.47); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(92, 91769.26); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(7, 40.42); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(13, 258.92); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"16"
"Calculate Maximum Value Using Sign Two Numbers String"
"C++"
"int calculateMaximumValueUsingSignTwoNumbersString(string str) {"
[ "str" ]
"def calculate_maximum_value_using_sign_two_numbers_string(str): res = (ord(str[0]) - 48) for i in range(1, len(str)): if ((str[i] == '0') or (str[i] == '1') or (res < 2)): res += (ord(str[i]) - 48) else: res *= (ord(str[i]) - 48) return res"
"int calculate_maximum_value_using_sign_two_numbers_string(string str) { int res = str [ 0 ] - '0'; for ( int i = 1; i < str . length ( ); i ++ ) { if ( str [ i ] == '0' || str [ i ] == '1' || res < 2 ) res += ( str [ i ] - '0' ); else res *= ( str [ i ] - '0' ); } return res; }"
{ "extension": "cpp", "entry_fn_name": "calculateMaximumValueUsingSignTwoNumbersString", "test_list": "[{\"idx\": 0, \"outputs\": 2176, \"inputs\": {\"str\": \"pR\"}}, {\"idx\": 1, \"outputs\": 368, \"inputs\": {\"str\": \"9518\"}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"str\": \"1\"}}, {\"idx\": 3, \"outputs\": 6272, \"inputs\": {\"str\": \"3170487\"}}, {\"idx\": 4, \"outputs\": 4, \"inputs\": {\"str\": \"0100101010\"}}, {\"idx\": 5, \"outputs\": -303, \"inputs\": {\"str\": \"Z rONcUqWb\"}}, {\"idx\": 6, \"outputs\": 5670, \"inputs\": {\"str\": \"00419297\"}}, {\"idx\": 7, \"outputs\": 0, \"inputs\": {\"str\": \"00\"}}, {\"idx\": 8, \"outputs\": 66, \"inputs\": {\"str\": \"r\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(string str, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(str), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"pR\", 2176); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"9518\", 368); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"1\", 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"3170487\", 6272); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"0100101010\", 4); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"Z rONcUqWb\", -303); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"00419297\", 5670); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"00\", 0); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"r\", 66); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"17"
"Calculate Volume Dodecahedron"
"C++"
"double calculateVolumeDodecahedron(int side) {"
[ "side" ]
"def calculate_volume_dodecahedron(side): return (((15 + (7 * math.sqrt(5))) / 4) * math.pow(side, 3))"
"double calculate_volume_dodecahedron(int side) { return ( ( ( 15 + ( 7 * ( sqrt ( 5 ) ) ) ) / 4 ) * ( pow ( side, 3 ) ) ); }"
{ "extension": "cpp", "entry_fn_name": "calculateVolumeDodecahedron", "test_list": "[{\"idx\": 0, \"outputs\": 1345766.2993890555, \"inputs\": {\"side\": 56}}, {\"idx\": 1, \"outputs\": 2981083.5487053124, \"inputs\": {\"side\": 73}}, {\"idx\": 2, \"outputs\": 81596.89069273109, \"inputs\": {\"side\": 22}}, {\"idx\": 3, \"outputs\": 7663.118960624633, \"inputs\": {\"side\": 10}}, {\"idx\": 4, \"outputs\": 4541961.260438062, \"inputs\": {\"side\": 84}}, {\"idx\": 5, \"outputs\": 61304.95168499706, \"inputs\": {\"side\": 20}}, {\"idx\": 6, \"outputs\": 1016520.3932458181, \"inputs\": {\"side\": 51}}, {\"idx\": 7, \"outputs\": 5774704.218276865, \"inputs\": {\"side\": 91}}, {\"idx\": 8, \"outputs\": 7663.118960624633, \"inputs\": {\"side\": 10}}, {\"idx\": 9, \"outputs\": 4381671.801138677, \"inputs\": {\"side\": 83}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(double actual, double expected){\n return abs(actual - expected) < 1e-09;\n}\n\nstring driver(int side, double expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(side), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(56, 1345766.2993890555); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(73, 2981083.5487053124); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(22, 81596.89069273109); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 7663.118960624633); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(84, 4541961.260438062); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(20, 61304.95168499706); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(51, 1016520.3932458181); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(91, 5774704.218276865); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 7663.118960624633); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(83, 4381671.801138677); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"18"
"Cassinis Identity"
"C++"
"int cassinisIdentity(int n) {"
[ "n" ]
"def cassinis_identity(n): return ((- 1) if (n & 1) else 1)"
"int cassinis_identity(int n) { return ( n & 1 ) ? - 1 : 1; }"
{ "extension": "cpp", "entry_fn_name": "cassinisIdentity", "test_list": "[{\"idx\": 0, \"outputs\": -1, \"inputs\": {\"n\": 67}}, {\"idx\": 1, \"outputs\": 1, \"inputs\": {\"n\": 2}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"n\": 58}}, {\"idx\": 3, \"outputs\": 1, \"inputs\": {\"n\": 6}}, {\"idx\": 4, \"outputs\": 1, \"inputs\": {\"n\": 42}}, {\"idx\": 5, \"outputs\": -1, \"inputs\": {\"n\": 17}}, {\"idx\": 6, \"outputs\": -1, \"inputs\": {\"n\": 37}}, {\"idx\": 7, \"outputs\": 1, \"inputs\": {\"n\": 44}}, {\"idx\": 8, \"outputs\": -1, \"inputs\": {\"n\": 23}}, {\"idx\": 9, \"outputs\": 1, \"inputs\": {\"n\": 40}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int n, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(67, -1); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(2, 1); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(58, 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(6, 1); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(42, 1); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(17, -1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(37, -1); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(44, 1); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(23, -1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(40, 1); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"19"
"Ceiling In A Sorted Array"
"C++"
"int ceilingInASortedArray(vector<int> arr, int low, int high, int x) {"
[ "arr", "low", "high", "x" ]
"def ceiling_in_a_sorted_array(arr, low, high, x): if (x <= arr[low]): return low i = low for i in range(high): if (arr[i] == x): return i if ((arr[i] < x) and (arr[(i + 1)] >= x)): return (i + 1) return (- 1)"
"int ceiling_in_a_sorted_array(vector<int> arr, int low, int high, int x) { int i; if ( x <= arr [ low ] ) return low; for ( i = low; i < high; i ++ ) { if ( arr [ i ] == x ) return i; if ( arr [ i ] < x && arr [ i + 1 ] >= x ) return i + 1; } return - 1; }"
{ "extension": "cpp", "entry_fn_name": "ceilingInASortedArray", "test_list": "[{\"idx\": 0, \"outputs\": 28, \"inputs\": {\"arr\": [2, 3, 4, 6, 8, 9, 9, 10, 11, 16, 19, 20, 21, 21, 21, 24, 24, 25, 28, 30, 30, 30, 32, 34, 35, 39, 41, 42, 49, 52, 57, 59, 61, 62, 66, 68, 71, 73, 76, 79, 83, 84, 85, 86, 87, 87], \"low\": 23, \"high\": 37, \"x\": 44}}, {\"idx\": 1, \"outputs\": 36, \"inputs\": {\"arr\": [92, 50, -84, 60, 32, -54, 84, -82, -42, -72, -64, -28, -48, 66, 92, -42, 42, -66, 52, -30, 48, 42, 36, -4, 64, 62, -16, 0, 20, 26, 78, 78, 12, -6, -30, -14, 76, 72, 70, -34, 98, 32], \"low\": 36, \"high\": 35, \"x\": 34}}, {\"idx\": 2, \"outputs\": -1, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], \"low\": 11, \"high\": 9, \"x\": 13}}, {\"idx\": 3, \"outputs\": 23, \"inputs\": {\"arr\": [26, 68, 73, 76, 14, 19, 56, 80, 17, 7, 15, 64, 99, 98, 21, 21, 72, 12, 14, 10, 44, 82, 25, 42, 46, 86, 79, 43, 91], \"low\": 23, \"high\": 27, \"x\": 26}}, {\"idx\": 4, \"outputs\": 9, \"inputs\": {\"arr\": [-90, -86, -84, -50, -30, -24, -12, -2, 8, 22, 30, 44, 58, 58, 60, 60, 62, 90], \"low\": 9, \"high\": 16, \"x\": 10}}, {\"idx\": 5, \"outputs\": -1, \"inputs\": {\"arr\": [0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1], \"low\": 12, \"high\": 15, \"x\": 18}}, {\"idx\": 6, \"outputs\": 9, \"inputs\": {\"arr\": [2, 2, 29, 31, 34, 39, 48, 50, 56, 61, 66, 66, 69, 73, 88], \"low\": 9, \"high\": 12, \"x\": 10}}, {\"idx\": 7, \"outputs\": 1, \"inputs\": {\"arr\": [-98, 48, -58, 8, 70, 62, 92, 84, -58, -46, -26, -92, 18, -88, 40, -12, 60, 14, 54, -64, 88, 52, -44, 88, -46, -8, 36, -22, 28, -20, -50, 58, -82, -44, -44, 54, -86, 40, 10, 0, -24, -84, -10, 62, 58, 0, -88], \"low\": 40, \"high\": 29, \"x\": 24}}, {\"idx\": 8, \"outputs\": -1, \"inputs\": {\"arr\": [0, 0, 0, 0, 1, 1], \"low\": 5, \"high\": 5, \"x\": 5}}, {\"idx\": 9, \"outputs\": 46, \"inputs\": {\"arr\": [56, 30, 33, 5, 67, 35, 22, 54, 36, 55, 94, 89, 40, 65, 29, 76, 17, 14, 14, 49, 40, 44, 35, 69, 63, 2, 81, 78, 19, 67, 12, 14, 68, 30, 82, 85, 12, 2, 94, 33, 85, 75, 97, 31, 69, 31, 85, 26], \"low\": 46, \"high\": 47, \"x\": 47}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int low, int high, int x, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, low, high, x), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({2, 3, 4, 6, 8, 9, 9, 10, 11, 16, 19, 20, 21, 21, 21, 24, 24, 25, 28, 30, 30, 30, 32, 34, 35, 39, 41, 42, 49, 52, 57, 59, 61, 62, 66, 68, 71, 73, 76, 79, 83, 84, 85, 86, 87, 87}, 23, 37, 44, 28); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({92, 50, -84, 60, 32, -54, 84, -82, -42, -72, -64, -28, -48, 66, 92, -42, 42, -66, 52, -30, 48, 42, 36, -4, 64, 62, -16, 0, 20, 26, 78, 78, 12, -6, -30, -14, 76, 72, 70, -34, 98, 32}, 36, 35, 34, 36); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, 11, 9, 13, -1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({26, 68, 73, 76, 14, 19, 56, 80, 17, 7, 15, 64, 99, 98, 21, 21, 72, 12, 14, 10, 44, 82, 25, 42, 46, 86, 79, 43, 91}, 23, 27, 26, 23); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-90, -86, -84, -50, -30, -24, -12, -2, 8, 22, 30, 44, 58, 58, 60, 60, 62, 90}, 9, 16, 10, 9); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1}, 12, 15, 18, -1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({2, 2, 29, 31, 34, 39, 48, 50, 56, 61, 66, 66, 69, 73, 88}, 9, 12, 10, 9); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-98, 48, -58, 8, 70, 62, 92, 84, -58, -46, -26, -92, 18, -88, 40, -12, 60, 14, 54, -64, 88, 52, -44, 88, -46, -8, 36, -22, 28, -20, -50, 58, -82, -44, -44, 54, -86, 40, 10, 0, -24, -84, -10, 62, 58, 0, -88}, 40, 29, 24, 1); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 1, 1}, 5, 5, 5, -1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({56, 30, 33, 5, 67, 35, 22, 54, 36, 55, 94, 89, 40, 65, 29, 76, 17, 14, 14, 49, 40, 44, 35, 69, 63, 2, 81, 78, 19, 67, 12, 14, 68, 30, 82, 85, 12, 2, 94, 33, 85, 75, 97, 31, 69, 31, 85, 26}, 46, 47, 47, 46); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"20"
"Ceiling In A Sorted Array 1"
"C++"
"int ceilingInASortedArray1(vector<int> arr, int low, int high, int x) {"
[ "arr", "low", "high", "x" ]
"def ceiling_in_a_sorted_array_1(arr, low, high, x): if (x <= arr[low]): return low if (x > arr[high]): return (- 1) mid = ((low + high) / 2) if (arr[mid] == x): return mid elif (arr[mid] < x): if (((mid + 1) <= high) and (x <= arr[(mid + 1)])): return (mid + 1) else: return ceiling_in_a_sorted_array_1(arr, (mid + 1), high, x) elif (((mid - 1) >= low) and (x > arr[(mid - 1)])): return mid else: return ceiling_in_a_sorted_array_1(arr, low, (mid - 1), x)"
"int ceiling_in_a_sorted_array_1(vector<int> arr, int low, int high, int x) { int mid; if ( x <= arr [ low ] ) return low; if ( x > arr [ high ] ) return - 1; mid = ( low + high ) / 2; if ( arr [ mid ] == x ) return mid; else if ( arr [ mid ] < x ) { if ( mid + 1 <= high && x <= arr [ mid + 1 ] ) return mid + 1; else return ceiling_in_a_sorted_array_1 ( arr, mid + 1, high, x ); } else { if ( mid - 1 >= low && x > arr [ mid - 1 ] ) return mid; else return ceiling_in_a_sorted_array_1 ( arr, low, mid - 1, x ); } }"
{ "extension": "cpp", "entry_fn_name": "ceilingInASortedArray1", "test_list": "[{\"idx\": 0, \"outputs\": 13, \"inputs\": {\"arr\": [2, 6, 13, 16, 23, 24, 24, 27, 30, 32, 34, 34, 55, 56, 56, 63, 66, 81, 83, 96], \"low\": 13, \"high\": 11, \"x\": 18}}, {\"idx\": 1, \"outputs\": 11, \"inputs\": {\"arr\": [-28, -96, 48, 22, -12, 72, 48, -70, -96, -84, -62, 22, 18, -92, -74, 14, 28, 52, 64, 72, 16, -76, 46], \"low\": 11, \"high\": 18, \"x\": 21}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"arr\": [0, 1], \"low\": 1, \"high\": 1, \"x\": 1}}, {\"idx\": 3, \"outputs\": -1, \"inputs\": {\"arr\": [51, 98, 25, 10, 43, 91, 33, 25, 85, 51, 94, 6, 35, 48, 11, 97, 67, 21, 50, 9, 11, 51, 86, 61, 22, 88, 89, 11], \"low\": 20, \"high\": 20, \"x\": 15}}, {\"idx\": 4, \"outputs\": 20, \"inputs\": {\"arr\": [-94, -92, -88, -74, -52, -50, -48, -44, -40, -36, -32, -26, 20, 22, 30, 32, 46, 56, 56, 60, 62, 64, 80, 84, 86, 94, 96, 96], \"low\": 20, \"high\": 15, \"x\": 15}}, {\"idx\": 5, \"outputs\": -1, \"inputs\": {\"arr\": [1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], \"low\": 15, \"high\": 17, \"x\": 22}}, {\"idx\": 6, \"outputs\": 12, \"inputs\": {\"arr\": [4, 5, 5, 13, 26, 40, 46, 51, 58, 60, 64, 66, 68, 69, 71, 74, 78, 81, 83, 88, 88, 90, 98, 99], \"low\": 12, \"high\": 17, \"x\": 14}}, {\"idx\": 7, \"outputs\": 23, \"inputs\": {\"arr\": [92, 6, -54, 84, -10, 32, 50, 40, -38, 64, -64, -10, 70, -68, -6, -16, 68, 34, -66, -82, 84, 98, 50, 82, 78, 4, 34, -34, 78, 64, 32, 58, -94, 40, 50, 0, -92, -36, 10, -54, 58, -78, -88, 32, 6], \"low\": 23, \"high\": 28, \"x\": 28}}, {\"idx\": 8, \"outputs\": -1, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"low\": 24, \"high\": 17, \"x\": 22}}, {\"idx\": 9, \"outputs\": 2, \"inputs\": {\"arr\": [80, 67, 30, 35, 9], \"low\": 2, \"high\": 3, \"x\": 2}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int low, int high, int x, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, low, high, x), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({2, 6, 13, 16, 23, 24, 24, 27, 30, 32, 34, 34, 55, 56, 56, 63, 66, 81, 83, 96}, 13, 11, 18, 13); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-28, -96, 48, 22, -12, 72, 48, -70, -96, -84, -62, 22, 18, -92, -74, 14, 28, 52, 64, 72, 16, -76, 46}, 11, 18, 21, 11); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 1}, 1, 1, 1, 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({51, 98, 25, 10, 43, 91, 33, 25, 85, 51, 94, 6, 35, 48, 11, 97, 67, 21, 50, 9, 11, 51, 86, 61, 22, 88, 89, 11}, 20, 20, 15, -1); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-94, -92, -88, -74, -52, -50, -48, -44, -40, -36, -32, -26, 20, 22, 30, 32, 46, 56, 56, 60, 62, 64, 80, 84, 86, 94, 96, 96}, 20, 15, 15, 20); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 15, 17, 22, -1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({4, 5, 5, 13, 26, 40, 46, 51, 58, 60, 64, 66, 68, 69, 71, 74, 78, 81, 83, 88, 88, 90, 98, 99}, 12, 17, 14, 12); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({92, 6, -54, 84, -10, 32, 50, 40, -38, 64, -64, -10, 70, -68, -6, -16, 68, 34, -66, -82, 84, 98, 50, 82, 78, 4, 34, -34, 78, 64, 32, 58, -94, 40, 50, 0, -92, -36, 10, -54, 58, -78, -88, 32, 6}, 23, 28, 28, 23); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 24, 17, 22, -1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({80, 67, 30, 35, 9}, 2, 3, 2, 2); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"22"
"Change Bits Can Made One Flip"
"C++"
"bool changeBitsCanMadeOneFlip(string str) {"
[ "str" ]
"def change_bits_can_made_one_flip(str): zeros = 0 ones = 0 for i in range(0, len(str)): ch = str[i] if (ch == '0'): zeros = (zeros + 1) else: ones = (ones + 1) return ((zeros == 1) or (ones == 1))"
"bool change_bits_can_made_one_flip(string str) { int zeros = 0, ones = 0; for ( char ch : str ) ( ch == '0' ) ? ++ zeros : ++ ones; return ( zeros == 1 || ones == 1 ); }"
{ "extension": "cpp", "entry_fn_name": "changeBitsCanMadeOneFlip", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"str\": \"00001\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"str\": \"0000\"}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"str\": \"11\"}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"str\": \"111110\"}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"str\": \"1\"}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"str\": \"111010111010\"}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"str\": \"hUInqJXNdbfP\"}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"str\": \"5191\"}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"str\": \"1110101101\"}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"str\": \"NupSrU xz\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(string str, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(str), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"00001\", true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"0000\", false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"11\", false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"111110\", true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"1\", true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"111010111010\", false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"hUInqJXNdbfP\", false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"5191\", false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"1110101101\", false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"NupSrU xz\", false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"23"
"Check Array Contains Contiguous Integers Duplicates Allowed"
"C++"
"bool checkArrayContainsContiguousIntegersDuplicatesAllowed(vector<int> arr, int n) {"
[ "arr", "n" ]
"def check_array_contains_contiguous_integers_duplicates_allowed(arr, n): max1 = max(arr) min1 = min(arr) m = ((max1 - min1) + 1) if (m > n): return False visited = ([0] * m) for i in range(0, n): visited[(arr[i] - min1)] = True for i in range(0, m): if (visited[i] == False): return False return True"
"bool check_array_contains_contiguous_integers_duplicates_allowed(vector<int> arr, int n) { int max = * max_element(arr.begin(), arr.end()); int min = * min_element(arr.begin(), arr.end()); int m = max - min + 1; if ( m > n ) return false; bool visited [ m ]; memset ( visited, false, sizeof ( visited ) ); for ( int i = 0; i < n; i ++ ) visited [ arr [ i ] - min ] = true; for ( int i = 0; i < m; i ++ ) if ( visited [ i ] == false ) return false; return true; }"
{ "extension": "cpp", "entry_fn_name": "checkArrayContainsContiguousIntegersDuplicatesAllowed", "test_list": "[{\"idx\": 0, \"outputs\": false, \"inputs\": {\"arr\": [2, 4, 19, 25, 65, 72, 75, 83, 90, 92], \"n\": 8}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"arr\": [46, 2, 28, -44, 74, -36, -8, 30, -96, 60, 52, -58, 16, -38, 78, 38, -28, 16, 26, -42, 48, 40, 6, 72], \"n\": 14}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"arr\": [0, 1, 1, 1], \"n\": 2}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"arr\": [50, 21, 9, 29, 86, 2, 82, 49, 34, 18, 77, 83, 44, 67, 85, 58, 15, 85, 22, 3, 39, 67, 42, 37, 6, 35, 18, 57, 41, 32, 39, 30, 41, 68, 84, 36, 64, 36], \"n\": 23}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"arr\": [-92, -82, -80, -78, -66, -66, -62, -58, -54, -52, -48, -30, -26, -22, -20, -20, -18, -14, -2, 12, 20, 24, 26, 26, 28, 28, 32, 36, 42, 48, 50, 52, 56, 64, 70, 72, 72, 80, 82, 84, 86, 92], \"n\": 26}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"arr\": [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0], \"n\": 43}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"arr\": [18, 19, 21, 23, 30, 33, 38, 40, 45, 56, 63, 68, 93, 96], \"n\": 8}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"arr\": [20, -90, -42, 48, 18, -46, 82, -12, -88, 82, 62, 24, 20, 64, -68, -34, -38, 8, -54, -20, -92, 34, -90, 78, 18, 8, -6, 10, 98, -24, 72, -92, 76, -22, 12, -44, 2, 68, -72, 42, 34, 20, -48], \"n\": 34}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 1, 1, 1, 1], \"n\": 8}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"arr\": [81, 25, 50, 48, 35, 38, 49, 21, 47, 94, 94, 55, 23, 45, 92, 23, 93, 33, 64, 9, 90, 64, 81, 17, 2, 73, 8, 7, 35, 36, 72], \"n\": 27}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({2, 4, 19, 25, 65, 72, 75, 83, 90, 92}, 8, false); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({46, 2, 28, -44, 74, -36, -8, 30, -96, 60, 52, -58, 16, -38, 78, 38, -28, 16, 26, -42, 48, 40, 6, 72}, 14, false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 1, 1, 1}, 2, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({50, 21, 9, 29, 86, 2, 82, 49, 34, 18, 77, 83, 44, 67, 85, 58, 15, 85, 22, 3, 39, 67, 42, 37, 6, 35, 18, 57, 41, 32, 39, 30, 41, 68, 84, 36, 64, 36}, 23, false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-92, -82, -80, -78, -66, -66, -62, -58, -54, -52, -48, -30, -26, -22, -20, -20, -18, -14, -2, 12, 20, 24, 26, 26, 28, 28, 32, 36, 42, 48, 50, 52, 56, 64, 70, 72, 72, 80, 82, 84, 86, 92}, 26, false); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0}, 43, true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({18, 19, 21, 23, 30, 33, 38, 40, 45, 56, 63, 68, 93, 96}, 8, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({20, -90, -42, 48, 18, -46, 82, -12, -88, 82, 62, 24, 20, 64, -68, -34, -38, 8, -54, -20, -92, 34, -90, 78, 18, 8, -6, 10, 98, -24, 72, -92, 76, -22, 12, -44, 2, 68, -72, 42, 34, 20, -48}, 34, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 1, 1, 1, 1}, 8, true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({81, 25, 50, 48, 35, 38, 49, 21, 47, 94, 94, 55, 23, 45, 92, 23, 93, 33, 64, 9, 90, 64, 81, 17, 2, 73, 8, 7, 35, 36, 72}, 27, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"24"
"Check Array Represents Inorder Binary Search Tree Not"
"C++"
"bool checkArrayRepresentsInorderBinarySearchTreeNot(vector<int> arr, int n) {"
[ "arr", "n" ]
"def check_array_represents_inorder_binary_search_tree_not(arr, n): if ((n == 0) or (n == 1)): return True for i in range(1, n, 1): if (arr[(i - 1)] > arr[i]): return False return True"
"bool check_array_represents_inorder_binary_search_tree_not(vector<int> arr, int n) { if ( n == 0 || n == 1 ) return true; for ( int i = 1; i < n; i ++ ) if ( arr [ i - 1 ] > arr [ i ] ) return false; return true; }"
{ "extension": "cpp", "entry_fn_name": "checkArrayRepresentsInorderBinarySearchTreeNot", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"arr\": [2, 3, 4, 10, 11, 13, 17, 19, 23, 26, 28, 29, 30, 34, 35, 37, 38, 38, 43, 49, 49, 50, 52, 53, 55, 55, 57, 58, 58, 59, 64, 66, 67, 70, 72, 72, 75, 77, 77, 87, 89, 89, 90, 91, 98, 99, 99, 99], \"n\": 46}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"arr\": [56, -94, -26, -52, 58, -66, -52, -66, -94, 44, 38, -66, 70, -70, -80, -78, -72, -60, -76, 68, -50, 32, -16, 84, 74, -42, 98, -8, 72, 26, 24, 6, 24, 86, 86, 78, -92, 80, 32, -74, 26, 50, 92, 4, 2, -34, -2, -18, -10], \"n\": 30}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 13}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"arr\": [38, 79, 76, 92, 92], \"n\": 2}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"arr\": [-42, -28, 2, 32, 50, 56, 86, 96, 98], \"n\": 7}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"arr\": [1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], \"n\": 11}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"arr\": [1, 9, 12, 21, 21, 24, 34, 55, 60, 63, 67, 68, 88, 89, 91, 94, 98, 99], \"n\": 9}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"arr\": [-96, 96, -98, -42, -74, 40, 42, 50, -46, -52, 8, -46, 48, 88, -78, -72, -10, -20, 98, -40, -18, 36, 4, 46, 52, 28, -88, -28, -28, -86], \"n\": 29}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"arr\": [0, 0, 0, 0, 1, 1], \"n\": 3}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"arr\": [66, 12, 48, 82, 33, 77, 99, 98, 14, 92], \"n\": 7}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({2, 3, 4, 10, 11, 13, 17, 19, 23, 26, 28, 29, 30, 34, 35, 37, 38, 38, 43, 49, 49, 50, 52, 53, 55, 55, 57, 58, 58, 59, 64, 66, 67, 70, 72, 72, 75, 77, 77, 87, 89, 89, 90, 91, 98, 99, 99, 99}, 46, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({56, -94, -26, -52, 58, -66, -52, -66, -94, 44, 38, -66, 70, -70, -80, -78, -72, -60, -76, 68, -50, 32, -16, 84, 74, -42, 98, -8, 72, 26, 24, 6, 24, 86, 86, 78, -92, 80, 32, -74, 26, 50, 92, 4, 2, -34, -2, -18, -10}, 30, false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 13, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({38, 79, 76, 92, 92}, 2, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-42, -28, 2, 32, 50, 56, 86, 96, 98}, 7, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, 11, false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 9, 12, 21, 21, 24, 34, 55, 60, 63, 67, 68, 88, 89, 91, 94, 98, 99}, 9, true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-96, 96, -98, -42, -74, 40, 42, 50, -46, -52, 8, -46, 48, 88, -78, -72, -10, -20, 98, -40, -18, 36, 4, 46, 52, 28, -88, -28, -28, -86}, 29, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 1, 1}, 3, true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({66, 12, 48, 82, 33, 77, 99, 98, 14, 92}, 7, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"25"
"Check Exist Two Elements Array Whose Sum Equal Sum Rest Array"
"C++"
"bool checkExistTwoElementsArrayWhoseSumEqualSumRestArray(vector<int> arr, int n) {"
[ "arr", "n" ]
"def check_exist_two_elements_array_whose_sum_equal_sum_rest_array(arr, n): s = set() sum = 0 for i in range(n): sum += arr[i] if ((sum % 2) != 0): return False sum = (sum / 2) for i in range(n): val = (sum - arr[i]) if (arr[i] not in s): s.add(arr[i]) if (val in s): print('Pair elements are', arr[i], 'and', int(val))"
"bool check_exist_two_elements_array_whose_sum_equal_sum_rest_array(vector<int> arr, int n) { int sum = 0; for ( int i = 0; i < n; i ++ ) sum += arr [ i ]; if ( sum % 2 != 0 ) return false; sum = sum / 2; unordered_set < int > s; for ( int i = 0; i < n; i ++ ) { int val = sum - arr [ i ]; if ( s . find ( val ) != s . end ( ) ) { return true; } s . insert ( arr [ i ] ); } return false; }"
{ "extension": "cpp", "entry_fn_name": "checkExistTwoElementsArrayWhoseSumEqualSumRestArray", "test_list": "[{\"idx\": 0, \"outputs\": null, \"inputs\": {\"arr\": [2, 11, 5, 1, 4, 7], \"n\": 6}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"arr\": [2, 4, 2, 1, 11, 15], \"n\": 6}}, {\"idx\": 2, \"outputs\": null, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 13}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"arr\": [69, 6, 24, 30, 75, 37, 61, 76, 19, 18, 90, 9, 49, 24, 58, 97, 18, 85, 24, 93, 71, 98, 92, 59, 75, 75, 75, 70, 35, 58, 50, 1, 64, 66, 33], \"n\": 18}}, {\"idx\": 4, \"outputs\": null, \"inputs\": {\"arr\": [-94, -94, -92, -74, -60, -58, -56, -44, -42, -40, -28, -14, 2, 4, 14, 20, 24, 28, 40, 42, 42, 66, 78, 78, 80, 82, 96], \"n\": 26}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"arr\": [1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1], \"n\": 10}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"arr\": [21, 26, 26, 27, 61, 62, 96], \"n\": 6}}, {\"idx\": 7, \"outputs\": null, \"inputs\": {\"arr\": [-54, 86, 20, 26], \"n\": 3}}, {\"idx\": 8, \"outputs\": null, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 4}}, {\"idx\": 9, \"outputs\": null, \"inputs\": {\"arr\": [44, 35, 26, 15, 56, 6, 36, 53, 15, 66, 20, 53, 99, 96, 51, 12, 61, 19, 79, 40, 99, 42, 86, 8, 11, 54, 93, 46, 23, 47, 41, 26, 66, 5, 86, 52, 64, 51, 4, 21, 63, 14, 7, 53, 31, 8, 9, 63], \"n\": 31}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({2, 11, 5, 1, 4, 7}, 6, false); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({2, 4, 2, 1, 11, 15}, 6, false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 13, false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({69, 6, 24, 30, 75, 37, 61, 76, 19, 18, 90, 9, 49, 24, 58, 97, 18, 85, 24, 93, 71, 98, 92, 59, 75, 75, 75, 70, 35, 58, 50, 1, 64, 66, 33}, 18, false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-94, -94, -92, -74, -60, -58, -56, -44, -42, -40, -28, -14, 2, 4, 14, 20, 24, 28, 40, 42, 42, 66, 78, 78, 80, 82, 96}, 26, false); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1}, 10, false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({21, 26, 26, 27, 61, 62, 96}, 6, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-54, 86, 20, 26}, 3, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 4, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({44, 35, 26, 15, 56, 6, 36, 53, 15, 66, 20, 53, 99, 96, 51, 12, 61, 19, 79, 40, 99, 42, 86, 8, 11, 54, 93, 46, 23, 47, 41, 26, 66, 5, 86, 52, 64, 51, 4, 21, 63, 14, 7, 53, 31, 8, 9, 63}, 31, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"26"
"Check Given Circle Lies Completely Inside Ring Formed Two Concentric Circles"
"C++"
"bool checkGivenCircleLiesCompletelyInsideRingFormedTwoConcentricCircles(int r0, int r10, int r11, int x1, int y1) {"
[ "r0", "r10", "r11", "x1", "y1" ]
"def check_given_circle_lies_completely_inside_ring_formed_two_concentric_circles(r, R, r1, x1, y1): dis = int(math.sqrt(((x1 * x1) + (y1 * y1)))) return (((dis - r1) >= R) and ((dis + r1) <= r))"
"bool check_given_circle_lies_completely_inside_ring_formed_two_concentric_circles(int r, int R, int r1, int x1, int y1) { int dis = sqrt ( x1 * x1 + y1 * y1 ); return ( dis - r1 >= R && dis + r1 <= r ); }"
{ "extension": "cpp", "entry_fn_name": "checkGivenCircleLiesCompletelyInsideRingFormedTwoConcentricCircles", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"r0\": 8, \"r10\": 4, \"r11\": 2, \"x1\": 6, \"y1\": 0}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"r0\": 400, \"r10\": 1, \"r11\": 10, \"x1\": 74, \"y1\": 38}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"r0\": 1, \"r10\": 400, \"r11\": 10, \"x1\": 74, \"y1\": 38}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"r0\": 61, \"r10\": 40, \"r11\": 2, \"x1\": 50, \"y1\": 0}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"r0\": 60, \"r10\": 49, \"r11\": 68, \"x1\": 77, \"y1\": 71}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"r0\": 88, \"r10\": 10, \"r11\": 69, \"x1\": 71, \"y1\": 26}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"r0\": 60, \"r10\": 79, \"r11\": 92, \"x1\": 29, \"y1\": 38}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"r0\": 26, \"r10\": 88, \"r11\": 75, \"x1\": 84, \"y1\": 10}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"r0\": 33, \"r10\": 65, \"r11\": 57, \"x1\": 21, \"y1\": 61}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"r0\": 70, \"r10\": 57, \"r11\": 77, \"x1\": 52, \"y1\": 87}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(int r0, int r10, int r11, int x1, int y1, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(r0, r10, r11, x1, y1), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(8, 4, 2, 6, 0, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(400, 1, 10, 74, 38, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(1, 400, 10, 74, 38, false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(61, 40, 2, 50, 0, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(60, 49, 68, 77, 71, false); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(88, 10, 69, 71, 26, false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(60, 79, 92, 29, 38, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(26, 88, 75, 84, 10, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(33, 65, 57, 21, 61, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(70, 57, 77, 52, 87, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"27"
"Check Given String Can Split Four Distinct Strings"
"C++"
"bool checkGivenStringCanSplitFourDistinctStrings(string s) {"
[ "s" ]
"def check_given_string_can_split_four_distinct_strings(s): if (len(s) >= 10): return True for i in range(1, len(s)): for j in range((i + 1), len(s)): for k in range((j + 1), len(s)): s1 = s[0:i] s2 = s[i:(j - i)] s3 = s[j:(k - j)] s4 = s[k:(len(s) - k)] if ((s1 != s2) and (s1 != s3) and (s1 != s4) and (s2 != s3) and (s2 != s4) and (s3 != s4)): return True return False"
"bool check_given_string_can_split_four_distinct_strings(string s) { if ( s . size ( ) >= 10 ) return true; for ( int i = 1; i < s . size ( ); i ++ ) { for ( int j = i + 1; j < s . size ( ); j ++ ) { for ( int k = j + 1; k < s . size ( ); k ++ ) { string s1 = s . substr ( 0, i ); string s2 = s . substr ( i, j - i ); string s3 = s . substr ( j, k - j ); string s4 = s . substr ( k, s . size ( ) - k ); if ( s1 != s2 && s1 != s3 && s1 != s4 && s2 != s3 && s2 != s4 && s3 != s4 ) return true; } } } return false; }"
{ "extension": "cpp", "entry_fn_name": "checkGivenStringCanSplitFourDistinctStrings", "test_list": "[{\"idx\": 0, \"outputs\": false, \"inputs\": {\"s\": \"WKTj Nw\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s\": \"8235021\"}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"s\": \"0101\"}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"s\": \"BLMhiQsQcFla\"}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"s\": \"00363175722\"}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"s\": \"10000\"}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"s\": \"aqEYWNd bqgye\"}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"s\": \"83\"}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"s\": \"000011110111\"}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"s\": \"E\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(string s, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(s), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"WKTj Nw\", false); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"8235021\", false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"0101\", false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"BLMhiQsQcFla\", true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"00363175722\", true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"10000\", false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"aqEYWNd bqgye\", true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"83\", false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"000011110111\", true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"E\", false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"28"
"Check Given String Rotation Palindrome"
"C++"
"bool checkGivenStringRotationPalindrome(string string_arg0) {"
[ "string_arg0" ]
"def check_given_string_rotation_palindrome(string): l = 0 h = (len(string) - 1) while (h > l): l += 1 h -= 1 if (string[(l - 1)] != string[(h + 1)]): return False return True"
"bool check_given_string_rotation_palindrome(string str) { int l = 0; int h = str . length ( ) - 1; while ( h > l ) if ( str [ l ++ ] != str [ h -- ] ) return false; return true; }"
{ "extension": "cpp", "entry_fn_name": "checkGivenStringRotationPalindrome", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"string_arg0\": \"aadaa\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"string_arg0\": \"2674377254\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"string_arg0\": \"11\"}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"string_arg0\": \"0011000\"}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"string_arg0\": \"26382426486138\"}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"string_arg0\": \"111010111010\"}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"string_arg0\": \"abccba\"}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"string_arg0\": \"5191\"}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"string_arg0\": \"1110101101\"}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"string_arg0\": \"abcdecbe\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(string string_arg0, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(string_arg0), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"aadaa\", true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"2674377254\", false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"11\", true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"0011000\", false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"26382426486138\", false); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"111010111010\", false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"abccba\", true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"5191\", false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"1110101101\", false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"abcdecbe\", false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"29"
"Check If All The Elements Can Be Made Of Same Parity By Inverting Adjacent Elements"
"C++"
"bool checkIfAllTheElementsCanBeMadeOfSameParityByInvertingAdjacentElements(vector<int> a, int n) {"
[ "a", "n" ]
"def check_if_all_the_elements_can_be_made_of_same_parity_by_inverting_adjacent_elements(a, n): count_odd = 0 count_even = 0 for i in range(n): if (a[i] & 1): count_odd += 1 else: count_even += 1 if ((count_odd % 2) and (count_even % 2)): return False else: return True"
"bool check_if_all_the_elements_can_be_made_of_same_parity_by_inverting_adjacent_elements(vector<int> a, int n) { int count_odd = 0, count_even = 0; for ( int i = 0; i < n; i ++ ) { if ( a [ i ] & 1 ) count_odd ++; else count_even ++; } if ( count_odd % 2 && count_even % 2 ) return false; else return true; }"
{ "extension": "cpp", "entry_fn_name": "checkIfAllTheElementsCanBeMadeOfSameParityByInvertingAdjacentElements", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"a\": [1, 1, 1, 7, 7, 8, 10, 10, 10, 14, 15, 18, 20, 23, 24, 24, 26, 30, 32, 32, 33, 36, 42, 43, 46, 48, 51, 51, 52, 53, 58, 58, 59, 59, 59, 60, 67, 71, 72, 74, 76, 77, 83, 84, 86, 90, 91], \"n\": 30}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"a\": [-90, -20, -60, -64, -24, 84, -2, -32, 28, -54, 44, -96, 52, 88, 20, -56, -2], \"n\": 12}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"a\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 36}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"a\": [98, 70, 24, 18, 7, 4, 78, 19, 70, 56, 99, 54, 69, 15, 88, 20, 40, 13, 19, 56, 62], \"n\": 19}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"a\": [-72, -66, -58, -20, 36, 80, 92], \"n\": 6}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"a\": [0, 1], \"n\": 1}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"a\": [6, 13, 14, 16, 21, 26, 26, 28, 29, 35, 38, 42, 47, 47, 62, 67, 77, 81, 81, 83, 84, 88, 90, 96, 97, 98], \"n\": 17}}, {\"idx\": 7, \"outputs\": true, \"inputs\": {\"a\": [-48, -8, 20, 32, -90, -42, -6, -88, -72, 42, 66, -62, 82, -4, 8, 12, -22, 82, 56, 96, -54, 92, -42, 30, -18, 14, -6, -66, 34, 16, -84, -94, 48, -48, 52, -60, -92, -16], \"n\": 35}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"a\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 14}}, {\"idx\": 9, \"outputs\": true, \"inputs\": {\"a\": [45, 86, 53, 80, 27, 45, 1, 85, 91, 93, 92, 43, 75, 86, 81, 48, 21, 34, 5, 10, 88, 42, 7, 15, 96, 85, 62, 86, 52, 37], \"n\": 29}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(vector<int> a, int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(a, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({1, 1, 1, 7, 7, 8, 10, 10, 10, 14, 15, 18, 20, 23, 24, 24, 26, 30, 32, 32, 33, 36, 42, 43, 46, 48, 51, 51, 52, 53, 58, 58, 59, 59, 59, 60, 67, 71, 72, 74, 76, 77, 83, 84, 86, 90, 91}, 30, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-90, -20, -60, -64, -24, 84, -2, -32, 28, -54, 44, -96, 52, 88, 20, -56, -2}, 12, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 36, false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({98, 70, 24, 18, 7, 4, 78, 19, 70, 56, 99, 54, 69, 15, 88, 20, 40, 13, 19, 56, 62}, 19, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-72, -66, -58, -20, 36, 80, 92}, 6, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 1}, 1, true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({6, 13, 14, 16, 21, 26, 26, 28, 29, 35, 38, 42, 47, 47, 62, 67, 77, 81, 81, 83, 84, 88, 90, 96, 97, 98}, 17, true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-48, -8, 20, 32, -90, -42, -6, -88, -72, 42, 66, -62, 82, -4, 8, 12, -22, 82, 56, 96, -54, 92, -42, 30, -18, 14, -6, -66, 34, 16, -84, -94, 48, -48, 52, -60, -92, -16}, 35, true); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 14, true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({45, 86, 53, 80, 27, 45, 1, 85, 91, 93, 92, 43, 75, 86, 81, 48, 21, 34, 5, 10, 88, 42, 7, 15, 96, 85, 62, 86, 52, 37}, 29, true); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"30"
"Check If A Number Is Jumbled Or Not"
"C++"
"bool checkIfANumberIsJumbledOrNot(int num) {"
[ "num" ]
"def check_if_a_number_is_jumbled_or_not(num): if ((num // 10) == 0): return True while (num != 0): if ((num // 10) == 0): return True digit1 = (num % 10) digit2 = ((num // 10) % 10) if (abs((digit2 - digit1)) > 1): return False num = (num // 10) return True"
"bool check_if_a_number_is_jumbled_or_not(int num) { if ( num / 10 == 0 ) return true; while ( num != 0 ) { if ( num / 10 == 0 ) return true; int digit1 = num % 10; int digit2 = ( num / 10 ) % 10; if ( abs ( digit2 - digit1 ) > 1 ) return false; num = num / 10; } return true; }"
{ "extension": "cpp", "entry_fn_name": "checkIfANumberIsJumbledOrNot", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"num\": 67}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"num\": 77}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"num\": 35}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"num\": 79}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"num\": 45}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"num\": 22}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"num\": 68}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"num\": 17}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"num\": 5}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"num\": 85}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(int num, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(num), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(67, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(77, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(35, false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(79, false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(45, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(22, true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(68, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(17, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(5, true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(85, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"31"
"Check If A Number Is Power Of Another Number"
"C++"
"bool checkIfANumberIsPowerOfAnotherNumber(int x, int y) {"
[ "x", "y" ]
"def check_if_a_number_is_power_of_another_number(x, y): if (x == 1): return (y == 1) pow = 1 while (pow < y): pow = (pow * x) return (pow == y)"
"bool check_if_a_number_is_power_of_another_number(int x, long int y) { if ( x == 1 ) return ( y == 1 ); long int pow = 1; while ( pow < y ) pow *= x; return ( pow == y ); }"
{ "extension": "cpp", "entry_fn_name": "checkIfANumberIsPowerOfAnotherNumber", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x\": 57, \"y\": 1}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x\": 3, \"y\": 9}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"x\": 10, \"y\": 101}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"x\": 10, \"y\": 10000}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"x\": 6, \"y\": 46656}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"x\": 2, \"y\": 2048}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"x\": 1, \"y\": 40}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"x\": 20, \"y\": 79}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"x\": 96, \"y\": 98}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"x\": 25, \"y\": 5}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(int x, int y, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(x, y), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(57, 1, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(3, 9, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 101, false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 10000, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(6, 46656, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(2, 2048, true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(1, 40, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(20, 79, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(96, 98, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(25, 5, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"32"
"Check If A Number Is Power Of Another Number 1"
"C++"
"int checkIfANumberIsPowerOfAnotherNumber1(int x, int y) {"
[ "x", "y" ]
"def check_if_a_number_is_power_of_another_number_1(x, y): res1 = (math.log(y) / math.log(x)) res2 = (math.log(y) / math.log(x)) return (1 if (res1 == res2) else 0)"
"bool check_if_a_number_is_power_of_another_number_1(int x, int y) { int res1 = log ( y ) / log ( x ); double res2 = log ( y ) / log ( x ); return ( res1 == res2 ); }"
{ "extension": "cpp", "entry_fn_name": "checkIfANumberIsPowerOfAnotherNumber1", "test_list": "[{\"idx\": 0, \"outputs\": 1, \"inputs\": {\"x\": 57, \"y\": 1}}, {\"idx\": 1, \"outputs\": 1, \"inputs\": {\"x\": 3, \"y\": 9}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"x\": 10, \"y\": 101}}, {\"idx\": 3, \"outputs\": 1, \"inputs\": {\"x\": 10, \"y\": 10000}}, {\"idx\": 4, \"outputs\": 1, \"inputs\": {\"x\": 6, \"y\": 46656}}, {\"idx\": 5, \"outputs\": 1, \"inputs\": {\"x\": 2, \"y\": 2048}}, {\"idx\": 6, \"outputs\": 1, \"inputs\": {\"x\": 2, \"y\": 40}}, {\"idx\": 7, \"outputs\": 1, \"inputs\": {\"x\": 20, \"y\": 79}}, {\"idx\": 8, \"outputs\": 1, \"inputs\": {\"x\": 96, \"y\": 98}}, {\"idx\": 9, \"outputs\": 1, \"inputs\": {\"x\": 25, \"y\": 5}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(int x, int y, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(x, y), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(57, 1, 1); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(3, 9, 1); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 101, 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 10000, 1); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(6, 46656, 1); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(2, 2048, 1); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(2, 40, 1); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(20, 79, 1); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(96, 98, 1); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(25, 5, 1); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"33"
"Check If String Remains Palindrome After Removing Given Number Of Characters"
"C++"
"bool checkIfStringRemainsPalindromeAfterRemovingGivenNumberOfCharacters(string str, int n) {"
[ "str", "n" ]
"def check_if_string_remains_palindrome_after_removing_given_number_of_characters(str, n): l = len(str) if (l >= n): return True return False"
"bool check_if_string_remains_palindrome_after_removing_given_number_of_characters(string str, int n) { int len = str . length ( ); if ( len >= n ) return true; return false; }"
{ "extension": "cpp", "entry_fn_name": "checkIfStringRemainsPalindromeAfterRemovingGivenNumberOfCharacters", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"str\": \"ZCoQhuM\", \"n\": 2}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"str\": \"7437725\", \"n\": 53}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"str\": \"11\", \"n\": 30}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"str\": \"buGlvR\", \"n\": 1}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"str\": \"9\", \"n\": 92}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"str\": \"101101010110\", \"n\": 3}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"str\": \"YguiM\", \"n\": 18}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"str\": \"8198\", \"n\": 90}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"str\": \"11101\", \"n\": 71}}, {\"idx\": 9, \"outputs\": true, \"inputs\": {\"str\": \"hUInqJXNdbfP\", \"n\": 4}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(string str, int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(str, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"ZCoQhuM\", 2, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"7437725\", 53, false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"11\", 30, false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"buGlvR\", 1, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"9\", 92, false); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"101101010110\", 3, true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"YguiM\", 18, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"8198\", 90, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"11101\", 71, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"hUInqJXNdbfP\", 4, true); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"34"
"Check If X Can Give Change To Every Person In The Queue"
"C++"
"int checkIfXCanGiveChangeToEveryPersonInTheQueue(vector<int> notes, int n) {"
[ "notes", "n" ]
"def check_if_x_can_give_change_to_every_person_in_the_queue(notes, n): fiveCount = 0 tenCount = 0 for i in range(n): if (notes[i] == 5): fiveCount += 1 elif (notes[i] == 10): if (fiveCount > 0): fiveCount -= 1 tenCount += 1 else: return 0 elif ((fiveCount > 0) and (tenCount > 0)): fiveCount -= 1 tenCount -= 1 elif (fiveCount >= 3): fiveCount -= 3 else: return 0 return 1"
"int check_if_x_can_give_change_to_every_person_in_the_queue(vector<int> notes, int n) { int fiveCount = 0; int tenCount = 0; for ( int i = 0; i < n; i ++ ) { if ( notes [ i ] == 5 ) fiveCount ++; else if ( notes [ i ] == 10 ) { if ( fiveCount > 0 ) { fiveCount --; tenCount ++; } else return 0; } else { if ( fiveCount > 0 && tenCount > 0 ) { fiveCount --; tenCount --; } else if ( fiveCount >= 3 ) { fiveCount -= 3; } else return 0; } } return 1; }"
{ "extension": "cpp", "entry_fn_name": "checkIfXCanGiveChangeToEveryPersonInTheQueue", "test_list": "[{\"idx\": 0, \"outputs\": 1, \"inputs\": {\"notes\": [5, 5, 5, 10, 20], \"n\": 4}}, {\"idx\": 1, \"outputs\": 0, \"inputs\": {\"notes\": [5, 5, 5, 20, 10], \"n\": 5}}, {\"idx\": 2, \"outputs\": 1, \"inputs\": {\"notes\": [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], \"n\": 27}}, {\"idx\": 3, \"outputs\": 0, \"inputs\": {\"notes\": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 18], \"n\": 12}}, {\"idx\": 4, \"outputs\": 1, \"inputs\": {\"notes\": [5, 5, 20], \"n\": 2}}, {\"idx\": 5, \"outputs\": 0, \"inputs\": {\"notes\": [10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], \"n\": 17}}, {\"idx\": 6, \"outputs\": 0, \"inputs\": {\"notes\": [5, 10, 20, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], \"n\": 7}}, {\"idx\": 7, \"outputs\": 0, \"inputs\": {\"notes\": [-82, -10, -78, -84, 68, 62, 10, 20, -86, -98, 92, 70, 40, -12, -20, -36, 8, -70, 6, 8, 44, -24, 8, -18, 76, -54, -14, -94, -68, -62, -24, -36, -74, 92, 92, -80, 48, 56, 94], \"n\": 31}}, {\"idx\": 8, \"outputs\": 0, \"inputs\": {\"notes\": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], \"n\": 25}}, {\"idx\": 9, \"outputs\": 0, \"inputs\": {\"notes\": [46, 46, 93, 57, 82, 34, 83, 80, 77, 36, 80, 85, 69, 28, 9, 56, 49, 27, 83, 25, 1, 80, 99, 14, 69, 82, 79, 71, 74, 34], \"n\": 20}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(int actual, int expected){\n return actual == expected;\n}\n\nstring driver(vector<int> notes, int n, int expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(notes, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({5, 5, 5, 10, 20}, 4, 1); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({5, 5, 5, 20, 10}, 5, 0); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, 27, 1); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 18}, 12, 0); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({5, 5, 20}, 2, 1); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, 17, 0); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({5, 10, 20, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, 7, 0); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-82, -10, -78, -84, 68, 62, 10, 20, -86, -98, 92, 70, 40, -12, -20, -36, 8, -70, 6, 8, 44, -24, 8, -18, 76, -54, -14, -94, -68, -62, -24, -36, -74, 92, 92, -80, 48, 56, 94}, 31, 0); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, 25, 0); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({46, 46, 93, 57, 82, 34, 83, 80, 77, 36, 80, 85, 69, 28, 9, 56, 49, 27, 83, 25, 1, 80, 99, 14, 69, 82, 79, 71, 74, 34}, 20, 0); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"35"
"Check Integer Overflow Multiplication"
"C++"
"bool checkIntegerOverflowMultiplication(long long a, long long b) {"
[ "a", "b" ]
"def check_integer_overflow_multiplication(a, b): if ((a == 0) or (b == 0)): return False result = (a * b) if ((result >= 9223372036854775807) or (result <= (- 9223372036854775808))): result = 0 if (a == (result // b)): print((result // b)) return False else: return True"
"bool check_integer_overflow_multiplication(long long a, long long b) { if ( a == 0 || b == 0 ) return false; long long result = a * b; if ( a == result / b ) return false; else return true; }"
{ "extension": "cpp", "entry_fn_name": "checkIntegerOverflowMultiplication", "test_list": "[{\"idx\": 0, \"outputs\": false, \"inputs\": {\"a\": 37, \"b\": 80}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"a\": 10000000000, \"b\": -10000000000}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"a\": 10000000000, \"b\": 10000000000}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"a\": 999999999, \"b\": 999999999}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"a\": 39, \"b\": 36}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"a\": 92, \"b\": 56}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"a\": 14, \"b\": 21}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"a\": 19, \"b\": 38}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"a\": 14, \"b\": 82}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"a\": 88, \"b\": 41}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(long long a, long long b, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(a, b), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(37, 80, false); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10000000000, -10000000000, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10000000000, 10000000000, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(999999999, 999999999, false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(39, 36, false); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(92, 56, false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(14, 21, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(19, 38, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(14, 82, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(88, 41, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"36"
"Check Large Number Divisible 13 Not"
"C++"
"bool checkLargeNumberDivisible13Not(string num) {"
[ "num" ]
"def check_large_number_divisible_13_not(num): length = len(num) if ((length == 1) and (num[0] == '0')): return True if ((length % 3) == 1): num = (str(num) + '00') length += 2 elif ((length % 3) == 2): num = (str(num) + '0') length += 1 sum = 0 p = 1 for i in range((length - 1), (- 1), (- 1)): group = 0 group += (ord(num[i]) - ord('0')) i -= 1 group += ((ord(num[i]) - ord('0')) * 10) i -= 1 group += ((ord(num[i]) - ord('0')) * 100) sum = (sum + (group * p)) p *= (- 1) sum = abs(sum) return ((sum % 13) == 0)"
"bool check_large_number_divisible_13_not(string num) { int length = num . size ( ); if ( length == 1 && num [ 0 ] == '0' ) return true; if ( length % 3 == 1 ) { num += "00"; length += 2; } else if ( length % 3 == 2 ) { num += "0"; length += 1; } int sum = 0, p = 1; for ( int i = length - 1; i >= 0; i -- ) { int group = 0; group += num [ i -- ] - '0'; group += ( num [ i -- ] - '0' ) * 10; group += ( num [ i ] - '0' ) * 100; sum = sum + group * p; p *= ( - 1 ); } sum = abs ( sum ); return ( sum % 13 == 0 ); }"
{ "extension": "cpp", "entry_fn_name": "checkLargeNumberDivisible13Not", "test_list": "[{\"idx\": 0, \"outputs\": false, \"inputs\": {\"num\": \"vzTUaItpCpLnjY\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"num\": \"33855\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"num\": \"0011110101011\"}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"num\": \"MMQ\"}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"num\": \"439340517954\"}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"num\": \"000000000\"}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"num\": \"UugAuRRJbjEgl\"}}, {\"idx\": 7, \"outputs\": true, \"inputs\": {\"num\": \"6406553695441\"}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"num\": \"011001\"}}, {\"idx\": 9, \"outputs\": true, \"inputs\": {\"num\": \"yjFqEEvgiNjEX\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(string num, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(num), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"vzTUaItpCpLnjY\", false); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"33855\", true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"0011110101011\", true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"MMQ\", false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"439340517954\", true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"000000000\", true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"UugAuRRJbjEgl\", true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"6406553695441\", true); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"011001\", true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"yjFqEEvgiNjEX\", true); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"37"
"Check Line Passes Origin"
"C++"
"bool checkLinePassesOrigin(int x1, int y1, int x2, int y2) {"
[ "x1", "y1", "x2", "y2" ]
"def check_line_passes_origin(x1, y1, x2, y2): return ((x1 * (y2 - y1)) == (y1 * (x2 - x1)))"
"bool check_line_passes_origin(int x1, int y1, int x2, int y2) { return ( x1 * ( y2 - y1 ) == y1 * ( x2 - x1 ) ); }"
{ "extension": "cpp", "entry_fn_name": "checkLinePassesOrigin", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"x1\": 1, \"y1\": 28, \"x2\": 2, \"y2\": 56}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"x1\": 10, \"y1\": 0, \"x2\": 20, \"y2\": 0}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"x1\": 0, \"y1\": 1, \"x2\": 0, \"y2\": 17}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"x1\": 1, \"y1\": 1, \"x2\": 10, \"y2\": 10}}, {\"idx\": 4, \"outputs\": false, \"inputs\": {\"x1\": 82, \"y1\": 86, \"x2\": 19, \"y2\": 4}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"x1\": 78, \"y1\": 86, \"x2\": 11, \"y2\": 6}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"x1\": 13, \"y1\": 46, \"x2\": 33, \"y2\": 33}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"x1\": 18, \"y1\": 29, \"x2\": 95, \"y2\": 12}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"x1\": 42, \"y1\": 35, \"x2\": 25, \"y2\": 36}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"x1\": 29, \"y1\": 17, \"x2\": 45, \"y2\": 35}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(int x1, int y1, int x2, int y2, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(x1, y1, x2, y2), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(1, 28, 2, 56, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(10, 0, 20, 0, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(0, 1, 0, 17, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(1, 1, 10, 10, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(82, 86, 19, 4, false); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(78, 86, 11, 6, false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(13, 46, 33, 33, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(18, 29, 95, 12, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(42, 35, 25, 36, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(29, 17, 45, 35, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"38"
"Check Number Is Perfect Square Using Additionsubtraction"
"C++"
"bool checkNumberIsPerfectSquareUsingAdditionsubtraction(int n) {"
[ "n" ]
"def check_number_is_perfect_square_using_additionsubtraction(n): i = 1 the_sum = 0 while (the_sum < n): the_sum += i if (the_sum == n): return True i += 2 return False"
"bool check_number_is_perfect_square_using_additionsubtraction(int n) { for ( int sum = 0, i = 1; sum < n; i += 2 ) { sum += i; if ( sum == n ) return true; } return false; }"
{ "extension": "cpp", "entry_fn_name": "checkNumberIsPerfectSquareUsingAdditionsubtraction", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 1}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 4}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 9}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"n\": 25}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"n\": 36}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"n\": 3}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"n\": 121}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"n\": 14}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"n\": 17}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"n\": 80}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(1, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(4, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(9, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(25, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(36, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(3, false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(121, true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(14, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(17, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(80, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"39"
"Check Number Power K Using Base Changing Method"
"C++"
"bool checkNumberPowerKUsingBaseChangingMethod(int n, int k) {"
[ "n", "k" ]
"def check_number_power_k_using_base_changing_method(n, k): oneSeen = False while (n > 0): digit = (n % k) if (digit > 1): return False if (digit == 1): if oneSeen: return False oneSeen = True n //= k return True"
"bool check_number_power_k_using_base_changing_method(unsigned int n, unsigned int k) { bool oneSeen = false; while ( n > 0 ) { int digit = n % k; if ( digit > 1 ) return false; if ( digit == 1 ) { if ( oneSeen ) return false; oneSeen = true; } n /= k; } return true; }"
{ "extension": "cpp", "entry_fn_name": "checkNumberPowerKUsingBaseChangingMethod", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"n\": 64, \"k\": 4}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"n\": 16, \"k\": 2}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"n\": 27, \"k\": 3}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"n\": 81, \"k\": 72}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"n\": 1, \"k\": 9}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"n\": 69, \"k\": 17}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"n\": 8, \"k\": 20}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"n\": 31, \"k\": 79}}, {\"idx\": 8, \"outputs\": false, \"inputs\": {\"n\": 43, \"k\": 81}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"n\": 54, \"k\": 89}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(int n, int k, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(n, k), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(64, 4, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(16, 2, true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(27, 3, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(81, 72, false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(1, 9, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(69, 17, false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(8, 20, false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(31, 79, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(43, 81, false); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(54, 89, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"40"
"Check Occurrences Character Appear Together"
"C++"
"bool checkOccurrencesCharacterAppearTogether(string s, char c) {"
[ "s", "c" ]
"def check_occurrences_character_appear_together(s, c): oneSeen = False i = 0 n = len(s) while (i < n): if (s[i] == c): if (oneSeen == True): return False while ((i < n) and (s[i] == c)): i = (i + 1) oneSeen = True else: i = (i + 1) return True"
"bool check_occurrences_character_appear_together(string s, char c) { bool oneSeen = false; int i = 0, n = s . length ( ); while ( i < n ) { if ( s [ i ] == c ) { if ( oneSeen == true ) return false; while ( i < n && s [ i ] == c ) i ++; oneSeen = true; } else i ++; } return true; }"
{ "extension": "cpp", "entry_fn_name": "checkOccurrencesCharacterAppearTogether", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s\": \"gILrzLimS\", \"c\": \"m\"}}, {\"idx\": 1, \"outputs\": true, \"inputs\": {\"s\": \"307471222\", \"c\": \"2\"}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"s\": \"110\", \"c\": \"0\"}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"s\": \"GcAB\", \"c\": \"v\"}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"s\": \"113\", \"c\": \"3\"}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"s\": \"011110010\", \"c\": \"0\"}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"s\": \"wcwob\", \"c\": \"w\"}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"s\": \"74571582216153\", \"c\": \"1\"}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"s\": \"100000011\", \"c\": \"0\"}}, {\"idx\": 9, \"outputs\": true, \"inputs\": {\"s\": \"ryPErkzY\", \"c\": \"q\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(string s, char c, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(s, c), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"gILrzLimS\", 'm', true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"307471222\", '2', true); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"110\", '0', true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"GcAB\", 'v', true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"113\", '3', true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"011110010\", '0', false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"wcwob\", 'w', false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"74571582216153\", '1', false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"100000011\", '0', true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"ryPErkzY\", 'q', true); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"41"
"Check Possible Sort Array Conditional Swapping Adjacent Allowed"
"C++"
"bool checkPossibleSortArrayConditionalSwappingAdjacentAllowed(vector<int> arr, int n) {"
[ "arr", "n" ]
"def check_possible_sort_array_conditional_swapping_adjacent_allowed(arr, n): for i in range(0, (n - 1)): if (arr[i] > arr[(i + 1)]): if ((arr[i] - arr[(i + 1)]) == 1): (arr[i], arr[(i + 1)]) = (arr[(i + 1)], arr[i]) else: return False return True"
"bool check_possible_sort_array_conditional_swapping_adjacent_allowed(vector<int> arr, int n) { for ( int i = 0; i < n - 1; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) { if ( arr [ i ] - arr [ i + 1 ] == 1 ) swap ( arr [ i ], arr [ i + 1 ] ); else return false; } } return true; }"
{ "extension": "cpp", "entry_fn_name": "checkPossibleSortArrayConditionalSwappingAdjacentAllowed", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"arr\": [1, 4, 12, 16, 37, 44, 47, 51, 55, 57, 57, 62, 62, 62, 64, 69, 69, 70, 72, 81, 81, 88, 89, 97], \"n\": 15}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"arr\": [-86, 0, 14, -16, -12, -72, 62, -34, -72, 30, 84, -60, 84, -64, 50, 74, 18, -82, -64, -64, -74, -56, 86, 84, -32, -10, 20, 4, 8, 96, 82, 26, 42], \"n\": 18}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 31}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"arr\": [48, 66, 83, 12, 77, 98, 18, 33, 21, 16, 28, 24, 46, 43], \"n\": 13}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"arr\": [-92, -58, -36, -28, -6, 2, 4, 26, 48, 58, 60, 62, 62, 98], \"n\": 10}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"arr\": [0, 0, 0, 1, 0, 1], \"n\": 4}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"arr\": [22, 38, 41, 41, 42, 51, 54, 58, 68, 76, 80, 85], \"n\": 9}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"arr\": [84, -38, 52, -72, -24, 82, 54, 74, 0], \"n\": 8}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"arr\": [0, 1, 1], \"n\": 2}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"arr\": [63, 31, 14, 19, 77, 64, 62, 23, 22, 19, 39, 9, 79, 1, 87, 29, 58, 3, 3, 39, 1, 39, 35, 64, 64], \"n\": 13}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({1, 4, 12, 16, 37, 44, 47, 51, 55, 57, 57, 62, 62, 62, 64, 69, 69, 70, 72, 81, 81, 88, 89, 97}, 15, true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-86, 0, 14, -16, -12, -72, 62, -34, -72, 30, 84, -60, 84, -64, 50, 74, 18, -82, -64, -64, -74, -56, 86, 84, -32, -10, 20, 4, 8, 96, 82, 26, 42}, 18, false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 31, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({48, 66, 83, 12, 77, 98, 18, 33, 21, 16, 28, 24, 46, 43}, 13, false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-92, -58, -36, -28, -6, 2, 4, 26, 48, 58, 60, 62, 62, 98}, 10, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 1, 0, 1}, 4, true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({22, 38, 41, 41, 42, 51, 54, 58, 68, 76, 80, 85}, 9, true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({84, -38, 52, -72, -24, 82, 54, 74, 0}, 8, false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 1, 1}, 2, true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({63, 31, 14, 19, 77, 64, 62, 23, 22, 19, 39, 9, 79, 1, 87, 29, 58, 3, 3, 39, 1, 39, 35, 64, 64}, 13, false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"42"
"Check Possible Transform One String Another"
"C++"
"bool checkPossibleTransformOneStringAnother(string s1, string s2) {"
[ "s1", "s2" ]
"def check_possible_transform_one_string_another(s1, s2): n = len(s1) m = len(s2) dp = [[False for i in range((m + 1))] for i in range((n + 1))] dp[0][0] = True for i in range(len(s1)): for j in range((len(s2) + 1)): if dp[i][j]: if ((j < len(s2)) and (s1[i].upper() == s2[j])): dp[(i + 1)][(j + 1)] = True if (s1[i].isupper() == False): dp[(i + 1)][j] = True return dp[n][m]"
"bool check_possible_transform_one_string_another(string s1, string s2) { int n = s1 . length ( ); int m = s2 . length ( ); bool dp [ n + 1 ] [ m + 1 ]; for ( int i = 0; i <= n; i ++ ) { for ( int j = 0; j <= m; j ++ ) { dp [ i ] [ j ] = false; } } dp [ 0 ] [ 0 ] = true; for ( int i = 0; i < s1 . length ( ); i ++ ) { for ( int j = 0; j <= s2 . length ( ); j ++ ) { if ( dp [ i ] [ j ] ) { if ( j < s2 . length ( ) && ( toupper ( s1 [ i ] ) == s2 [ j ] ) ) dp [ i + 1 ] [ j + 1 ] = true; if ( ! isupper ( s1 [ i ] ) ) dp [ i + 1 ] [ j ] = true; } } } return ( dp [ n ] [ m ] ); }"
{ "extension": "cpp", "entry_fn_name": "checkPossibleTransformOneStringAnother", "test_list": "[{\"idx\": 0, \"outputs\": true, \"inputs\": {\"s1\": \"daBcd\", \"s2\": \"ABC\"}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"s1\": \"417514\", \"s2\": \"9\"}}, {\"idx\": 2, \"outputs\": false, \"inputs\": {\"s1\": \"010000\", \"s2\": \"1111011010\"}}, {\"idx\": 3, \"outputs\": false, \"inputs\": {\"s1\": \"ZcKYguiMrdyn\", \"s2\": \"iz\"}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"s1\": \"argaju\", \"s2\": \"RAJ\"}}, {\"idx\": 5, \"outputs\": false, \"inputs\": {\"s1\": \"1110101101\", \"s2\": \"110101001\"}}, {\"idx\": 6, \"outputs\": false, \"inputs\": {\"s1\": \"ySOCoSaygi\", \"s2\": \"aRhxkYqh\"}}, {\"idx\": 7, \"outputs\": false, \"inputs\": {\"s1\": \"204\", \"s2\": \"6986871066\"}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"s1\": \"10011100000010\", \"s2\": \"0\"}}, {\"idx\": 9, \"outputs\": false, \"inputs\": {\"s1\": \"nMAioozPmY\", \"s2\": \"WZFdDKw\"}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(string s1, string s2, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(s1, s2), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver(\"daBcd\", \"ABC\", true); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"417514\", \"9\", false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"010000\", \"1111011010\", false); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"ZcKYguiMrdyn\", \"iz\", false); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"argaju\", \"RAJ\", true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"1110101101\", \"110101001\", false); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"ySOCoSaygi\", \"aRhxkYqh\", false); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"204\", \"6986871066\", false); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"10011100000010\", \"0\", true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver(\"nMAioozPmY\", \"WZFdDKw\", false); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }
"44"
"Check Reversing Sub Array Make Array Sorted 1"
"C++"
"bool checkReversingSubArrayMakeArraySorted1(vector<int> arr, int n) {"
[ "arr", "n" ]
"def check_reversing_sub_array_make_array_sorted_1(arr, n): if (n == 1): return True i = 1 for i in range(1, n): if (arr[(i - 1)] < arr[i]): if (i == n): return True j = i while (arr[j] < arr[(j - 1)]): if ((i > 1) and (arr[j] < arr[(i - 2)])): return False j += 1 if (j == n): return True k = j if (arr[k] < arr[(i - 1)]): return False while ((k > 1) and (k < n)): if (arr[k] < arr[(k - 1)]): return False k += 1 return True"
"bool check_reversing_sub_array_make_array_sorted_1(vector<int> arr, int n) { if ( n == 1 ) return true; int i; for ( i = 1; i < n && arr [ i - 1 ] < arr [ i ]; i ++ ); if ( i == n ) return true; int j = i; while ( arr [ j ] < arr [ j - 1 ] ) { if ( i > 1 && arr [ j ] < arr [ i - 2 ] ) return false; j ++; } if ( j == n ) return true; int k = j; if ( arr [ k ] < arr [ i - 1 ] ) return false; while ( k > 1 && k < n ) { if ( arr [ k ] < arr [ k - 1 ] ) return false; k ++; } return true; }"
{ "extension": "cpp", "entry_fn_name": "checkReversingSubArrayMakeArraySorted1", "test_list": "[{\"idx\": 0, \"outputs\": false, \"inputs\": {\"arr\": [1, 2, 5, 4, 3], \"n\": 5}}, {\"idx\": 1, \"outputs\": false, \"inputs\": {\"arr\": [1, 2, 4, 5, 3], \"n\": 5}}, {\"idx\": 2, \"outputs\": true, \"inputs\": {\"arr\": [1, 1, 0, 0], \"n\": 4}}, {\"idx\": 3, \"outputs\": true, \"inputs\": {\"arr\": [5, 99, 40, 33, 61, 4, 64, 92, 28, 27, 21, 35, 40, 79, 10, 20, 76, 87, 80, 15, 57, 39, 96, 98, 99, 72, 72, 50, 61, 39, 35, 70, 27], \"n\": 32}}, {\"idx\": 4, \"outputs\": true, \"inputs\": {\"arr\": [-98, -92, -86, -58, -22, -12, 0, 26], \"n\": 6}}, {\"idx\": 5, \"outputs\": true, \"inputs\": {\"arr\": [0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0], \"n\": 24}}, {\"idx\": 6, \"outputs\": true, \"inputs\": {\"arr\": [6, 10, 27, 30, 40, 47, 49, 55, 59, 60, 68, 82, 91], \"n\": 8}}, {\"idx\": 7, \"outputs\": true, \"inputs\": {\"arr\": [36, 56, -56, 94, 52, -82, 88, -62, 70, -94, 38, 10, -78, 66, -94, -72, 18, 96, -72, 88, -6, 48, 6, -88, 64, -96, -40, 8, 36, 36, -90, -68, -20, -76, 22, -92], \"n\": 30}}, {\"idx\": 8, \"outputs\": true, \"inputs\": {\"arr\": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"n\": 31}}, {\"idx\": 9, \"outputs\": true, \"inputs\": {\"arr\": [2, 5, 42, 28, 47, 26, 88, 16, 30, 30, 36, 49, 21, 95, 99, 21, 41, 52, 57, 39, 69, 2, 42, 22, 55, 92, 64, 27, 95, 71, 19, 38, 40, 65, 7, 21, 29, 38, 13, 11, 41, 54, 38, 40, 35, 51, 88], \"n\": 46}}]", "test_code": "#include <algorithm>\n#include <assert.h>\n#include <cstdlib>\n#include <iostream>\n#include <map>\n#include <set>\n#include <string>\n#include <tuple> \n#include <unordered_map>\n#include <vector>\n#include <math.h>\n#include <cmath>\n#include <bits/stdc++.h>\n#include <numeric>\n#include <functional>\n\nusing namespace std;\n\n// SOLUTION CODE\n// ============================================\nPLACEHOLDER_CODE_BODY\n\n// TESTING CODE \n// ============================================\nbool validateSolution(bool actual, bool expected){\n return actual == expected;\n}\n\nstring driver(vector<int> arr, int n, bool expected){\n try\n {\n if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)){\n return \"PASSED\";\n }\n return \"FAILED\";\n }\n catch (const std::overflow_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::runtime_error& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (const std::exception& exception_obj)\n {\n return typeid(exception_obj).name();\n }\n catch (...)\n {\n return \"UNK_ERROR\";\n }\n}\n\nint main() {\n string result = \"\";\n\n result = driver({1, 2, 5, 4, 3}, 5, false); \n cout << \"TEST-\" << 0 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 2, 4, 5, 3}, 5, false); \n cout << \"TEST-\" << 1 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({1, 1, 0, 0}, 4, true); \n cout << \"TEST-\" << 2 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({5, 99, 40, 33, 61, 4, 64, 92, 28, 27, 21, 35, 40, 79, 10, 20, 76, 87, 80, 15, 57, 39, 96, 98, 99, 72, 72, 50, 61, 39, 35, 70, 27}, 32, true); \n cout << \"TEST-\" << 3 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({-98, -92, -86, -58, -22, -12, 0, 26}, 6, true); \n cout << \"TEST-\" << 4 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0}, 24, true); \n cout << \"TEST-\" << 5 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({6, 10, 27, 30, 40, 47, 49, 55, 59, 60, 68, 82, 91}, 8, true); \n cout << \"TEST-\" << 6 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({36, 56, -56, 94, 52, -82, 88, -62, 70, -94, 38, 10, -78, 66, -94, -72, 18, 96, -72, 88, -6, 48, 6, -88, 64, -96, -40, 8, 36, 36, -90, -68, -20, -76, 22, -92}, 30, true); \n cout << \"TEST-\" << 7 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 31, true); \n cout << \"TEST-\" << 8 << \"...\"\n << result\n << \"\\n\";\n\n result = driver({2, 5, 42, 28, 47, 26, 88, 16, 30, 30, 36, 49, 21, 95, 99, 21, 41, 52, 57, 39, 69, 2, 42, 22, 55, 92, 64, 27, 95, 71, 19, 38, 40, 65, 7, 21, 29, 38, 13, 11, 41, 54, 38, 40, 35, 51, 88}, 46, true); \n cout << \"TEST-\" << 9 << \"...\"\n << result\n << \"\\n\";\n\n return 0;\n}", "entry_cls_name": "Solution", "test_case_ids": [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ], "commands": [ [ "g++", "__FILENAME__", "-o", "main.exe" ], [ "./main.exe" ] ], "timeouts": [ 10, 10 ] }

Dataset Card for BabelCode Transcoder

How To Use This Dataset

To use this dataset, you can either use the original BabelCode Repo, or you can use the bc_eval Metric.

Dataset Summary

The Transcoder dataset in BabelCode format. Currently supports translation from C++ and Python.

Supported Tasks and Leaderboards

Languages

BC-Transcoder supports:

  • C++
  • C#
  • Dart
  • Go
  • Haskell
  • Java
  • Javascript
  • Julia
  • Kotlin
  • Lua
  • PHP
  • Python
  • R
  • Rust
  • Scala
  • TypeScript

Dataset Structure

>>> from datasets import load_dataset
>>> load_dataset("gabeorlanski/bc-transcoder")
DatasetDict({
    test: Dataset({
        features: ['qid', 'title', 'language', 'signature', 'arguments', 'source_py', 'source_cpp', 'question_info'],
        num_rows: 8384
    })
})

Data Fields

  • qid: The question ID used for running tests.
  • title: The title of the question.
  • language: The programming language of the example.
  • signature: The signature for the problem.
  • arguments: The arguments of the problem.
  • source_py: The source solution in Python.
  • source_cpp: The source in C++.
  • question_info: The dict of information used for executing predictions. It has the keys:
    • test_code: The raw testing script used in the language. If you want to use this, replace PLACEHOLDER_FN_NAME (and PLACEHOLDER_CLS_NAME if needed) with the corresponding entry points. Next, replace PLACEHOLDER_CODE_BODY with the postprocessed prediction.
    • test_list: The raw json line of the list of tests for the problem. To load them, use json.loads
    • test_case_ids: The list of test case ids for the problem. These are used to determine if a prediction passes or not.
    • entry_fn_name: The function's name to use an entry point.
    • entry_cls_name: The class name to use an entry point.
    • commands: The commands used to execute the prediction. Includes a __FILENAME__ hole that is replaced with the filename.
    • timeouts: The default timeouts for each command.
    • extension: The extension for the prediction file.

NOTE: If you want to use a different function name (or class name for languages that require class names) for the prediction, you must update the entry_fn_name and entry_cls_name accordingly. For example, if you have the original question with entry_fn_name of add, but want to change it to f, you must update ds["question_info"]["entry_fn_name"] to f:

>>> from datasets import load_dataset
>>> ds = load_dataset("gabeorlanski/bc-mbpp")['test']
>>> # The original entry_fn_name
>>> ds[0]['question_info']['entry_fn_name']
removeOcc
>>> # You MUST update the corresponding entry_fn_name
>>> ds[0]['question_info']['entry_fn_name'] = 'f'
>>> ds[0]['question_info']['entry_fn_name']
f

Dataset Creation

See section 2 of the BabelCode Paper to learn more about how the datasets are translated.

For information on the original curation of the Transcoder Dataset, please see Unsupervised Translation of Programming Languages by Roziere et. al.

Dataset Curators

Google Research

Licensing Information

CC-BY-4.0

Citation Information

@article{orlanski2023measuring,
  title={Measuring The Impact Of Programming Language Distribution},
  author={Orlanski, Gabriel and Xiao, Kefan and Garcia, Xavier and Hui, Jeffrey and Howland, Joshua and Malmaud, Jonathan and Austin, Jacob and Singh, Rishah and Catasta, Michele},
  journal={arXiv preprint arXiv:2302.01973},
  year={2023}
}
@article{roziere2020unsupervised,
  title={Unsupervised translation of programming languages},
  author={Roziere, Baptiste and Lachaux, Marie-Anne and Chanussot, Lowik and Lample, Guillaume},
  journal={Advances in Neural Information Processing Systems},
  volume={33},
  year={2020}
}
Downloads last month
18
Edit dataset card
Evaluate models HF Leaderboard