From 2ff4dd55c368a6cca80cc70edebff1365e084401 Mon Sep 17 00:00:00 2001 From: vishal Date: Thu, 25 Jul 2024 09:10:44 +0530 Subject: [PATCH] fix test cases --- apps/boilerplate-generator/src/FullBoilerPlateParser.ts | 4 ++-- apps/problems/Broken-SubArray/boilerplate-full/function.cpp | 6 +++--- .../Calculate-Fibonacci/boilerplate-full/function.cpp | 2 +- .../problems/Check-Palindrome/boilerplate-full/function.cpp | 2 +- .../boilerplate-full/function.cpp | 2 +- apps/problems/Find-Median/boilerplate-full/function.cpp | 6 +++--- .../Find-Prime-Numbers/boilerplate-full/function.cpp | 2 +- apps/problems/Intersting-Arrays/tests/inputs/2.txt | 4 ++-- apps/problems/Intersting-Arrays/tests/inputs/3.txt | 4 ++-- apps/problems/Intersting-Arrays/tests/inputs/5.txt | 2 +- apps/problems/Intersting-Arrays/tests/outputs/1.txt | 2 +- apps/problems/Intersting-Arrays/tests/outputs/2.txt | 2 +- apps/problems/Intersting-Arrays/tests/outputs/4.txt | 2 +- .../Merge-Sorted-Arrays/boilerplate-full/function.cpp | 2 +- apps/problems/Reverse-String/boilerplate-full/function.cpp | 2 +- apps/problems/Sort-Array/boilerplate-full/function.cpp | 6 +++--- apps/problems/max-element/boilerplate-full/function.cpp | 4 ++-- 17 files changed, 27 insertions(+), 27 deletions(-) diff --git a/apps/boilerplate-generator/src/FullBoilerPlateParser.ts b/apps/boilerplate-generator/src/FullBoilerPlateParser.ts index 3b6d3e4..cd1fab1 100644 --- a/apps/boilerplate-generator/src/FullBoilerPlateParser.ts +++ b/apps/boilerplate-generator/src/FullBoilerPlateParser.ts @@ -121,14 +121,14 @@ export class FullBoilerPlateParser { const inputReads = this.inputFields .map((field, index) => { if (field.type.startsWith("list<")) { - return `int size_${field.name};\n std::istringstream(lines[${index}]) >> size_${field.name};\n ${this.mapTypeToCpp(field.type)} ${field.name}(size_${field.name});\n if(!size_${field.name}==0) {\n \tstd::istringstream iss(lines[${index + 1}]);\n \tfor (int i=0; i < size_arr; i++) iss >> arr[i];\n }`; + return `int size_${field.name};\n std::istringstream(lines[${index}]) >> size_${field.name};\n ${this.mapTypeToCpp(field.type)} ${field.name}(size_${field.name});\n if(size_${field.name} != 0) {\n \tstd::istringstream iss(lines[${index + 1}]);\n \tfor (int i=0; i < size_${field.name}; i++) iss >> ${field.name}[i];\n }`; } else { return `${this.mapTypeToCpp(field.type)} ${field.name};\n std::istringstream(lines[${index}]) >> ${field.name};`; } }) .join("\n "); const outputType = this.outputFields[0].type; - const functionCall = `${outputType} result = ${this.functionName}(${this.inputFields.map((field) => field.name).join(", ")});`; + const functionCall = `std::${outputType} result = ${this.functionName}(${this.inputFields.map((field) => field.name).join(", ")});`; const outputWrite = `std::cout << result << std::endl;`; return `#include diff --git a/apps/problems/Broken-SubArray/boilerplate-full/function.cpp b/apps/problems/Broken-SubArray/boilerplate-full/function.cpp index 0974b4f..5b36bae 100644 --- a/apps/problems/Broken-SubArray/boilerplate-full/function.cpp +++ b/apps/problems/Broken-SubArray/boilerplate-full/function.cpp @@ -17,13 +17,13 @@ int size_A; std::istringstream(lines[0]) >> size_A; std::vector A(size_A); - if(!size_A==0) { + if(size_A != 0) { std::istringstream iss(lines[1]); - for (int i=0; i < size_arr; i++) iss >> arr[i]; + for (int i=0; i < size_A; i++) iss >> A[i]; } int B; std::istringstream(lines[1]) >> B; - int result = solve(A, B); + std::int result = solve(A, B); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Calculate-Fibonacci/boilerplate-full/function.cpp b/apps/problems/Calculate-Fibonacci/boilerplate-full/function.cpp index ae66193..d8d6be8 100644 --- a/apps/problems/Calculate-Fibonacci/boilerplate-full/function.cpp +++ b/apps/problems/Calculate-Fibonacci/boilerplate-full/function.cpp @@ -16,7 +16,7 @@ file.close(); int n; std::istringstream(lines[0]) >> n; - int result = calculateFibonacci(n); + std::int result = calculateFibonacci(n); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Check-Palindrome/boilerplate-full/function.cpp b/apps/problems/Check-Palindrome/boilerplate-full/function.cpp index 8889b4b..53dcf4d 100644 --- a/apps/problems/Check-Palindrome/boilerplate-full/function.cpp +++ b/apps/problems/Check-Palindrome/boilerplate-full/function.cpp @@ -16,7 +16,7 @@ file.close(); std::string text; std::istringstream(lines[0]) >> text; - bool result = isPalindrome(text); + std::bool result = isPalindrome(text); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Convert-Celsius-to-Fahrenheit/boilerplate-full/function.cpp b/apps/problems/Convert-Celsius-to-Fahrenheit/boilerplate-full/function.cpp index 736b957..c1109c5 100644 --- a/apps/problems/Convert-Celsius-to-Fahrenheit/boilerplate-full/function.cpp +++ b/apps/problems/Convert-Celsius-to-Fahrenheit/boilerplate-full/function.cpp @@ -16,7 +16,7 @@ file.close(); float celsius; std::istringstream(lines[0]) >> celsius; - float result = celsiusToFahrenheit(celsius); + std::float result = celsiusToFahrenheit(celsius); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Find-Median/boilerplate-full/function.cpp b/apps/problems/Find-Median/boilerplate-full/function.cpp index cb93b92..ab550c1 100644 --- a/apps/problems/Find-Median/boilerplate-full/function.cpp +++ b/apps/problems/Find-Median/boilerplate-full/function.cpp @@ -17,11 +17,11 @@ int size_numbers; std::istringstream(lines[0]) >> size_numbers; std::vector numbers(size_numbers); - if(!size_numbers==0) { + if(size_numbers != 0) { std::istringstream iss(lines[1]); - for (int i=0; i < size_arr; i++) iss >> arr[i]; + for (int i=0; i < size_numbers; i++) iss >> numbers[i]; } - float result = findMedian(numbers); + std::float result = findMedian(numbers); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Find-Prime-Numbers/boilerplate-full/function.cpp b/apps/problems/Find-Prime-Numbers/boilerplate-full/function.cpp index 1ab3dc9..280c0d7 100644 --- a/apps/problems/Find-Prime-Numbers/boilerplate-full/function.cpp +++ b/apps/problems/Find-Prime-Numbers/boilerplate-full/function.cpp @@ -16,7 +16,7 @@ file.close(); int limit; std::istringstream(lines[0]) >> limit; - list result = findPrimes(limit); + std::list result = findPrimes(limit); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Intersting-Arrays/tests/inputs/2.txt b/apps/problems/Intersting-Arrays/tests/inputs/2.txt index a789e87..5779e04 100644 --- a/apps/problems/Intersting-Arrays/tests/inputs/2.txt +++ b/apps/problems/Intersting-Arrays/tests/inputs/2.txt @@ -1,2 +1,2 @@ -2 -1 2 +4 +2 4 8 16 \ No newline at end of file diff --git a/apps/problems/Intersting-Arrays/tests/inputs/3.txt b/apps/problems/Intersting-Arrays/tests/inputs/3.txt index 3b099e5..807628f 100644 --- a/apps/problems/Intersting-Arrays/tests/inputs/3.txt +++ b/apps/problems/Intersting-Arrays/tests/inputs/3.txt @@ -1,2 +1,2 @@ -3 -3 5 6 +4 +3 6 9 12 \ No newline at end of file diff --git a/apps/problems/Intersting-Arrays/tests/inputs/5.txt b/apps/problems/Intersting-Arrays/tests/inputs/5.txt index b10b3e3..9609d7f 100644 --- a/apps/problems/Intersting-Arrays/tests/inputs/5.txt +++ b/apps/problems/Intersting-Arrays/tests/inputs/5.txt @@ -1,2 +1,2 @@ 7 -23 89 23 89 23 89 23 +23 9 23 89 2 89 21 diff --git a/apps/problems/Intersting-Arrays/tests/outputs/1.txt b/apps/problems/Intersting-Arrays/tests/outputs/1.txt index cf45697..3fdfb3d 100644 --- a/apps/problems/Intersting-Arrays/tests/outputs/1.txt +++ b/apps/problems/Intersting-Arrays/tests/outputs/1.txt @@ -1 +1 @@ -No +Yes \ No newline at end of file diff --git a/apps/problems/Intersting-Arrays/tests/outputs/2.txt b/apps/problems/Intersting-Arrays/tests/outputs/2.txt index cf45697..289cc91 100644 --- a/apps/problems/Intersting-Arrays/tests/outputs/2.txt +++ b/apps/problems/Intersting-Arrays/tests/outputs/2.txt @@ -1 +1 @@ -No +No \ No newline at end of file diff --git a/apps/problems/Intersting-Arrays/tests/outputs/4.txt b/apps/problems/Intersting-Arrays/tests/outputs/4.txt index dcd7a5d..289cc91 100644 --- a/apps/problems/Intersting-Arrays/tests/outputs/4.txt +++ b/apps/problems/Intersting-Arrays/tests/outputs/4.txt @@ -1 +1 @@ -Yes +No \ No newline at end of file diff --git a/apps/problems/Merge-Sorted-Arrays/boilerplate-full/function.cpp b/apps/problems/Merge-Sorted-Arrays/boilerplate-full/function.cpp index d9e9f10..768d44e 100644 --- a/apps/problems/Merge-Sorted-Arrays/boilerplate-full/function.cpp +++ b/apps/problems/Merge-Sorted-Arrays/boilerplate-full/function.cpp @@ -15,7 +15,7 @@ file.close(); - list result = mergeSortedArrays(); + std::list result = mergeSortedArrays(); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Reverse-String/boilerplate-full/function.cpp b/apps/problems/Reverse-String/boilerplate-full/function.cpp index 7852d37..9cb6e89 100644 --- a/apps/problems/Reverse-String/boilerplate-full/function.cpp +++ b/apps/problems/Reverse-String/boilerplate-full/function.cpp @@ -16,7 +16,7 @@ file.close(); std::string originalString; std::istringstream(lines[0]) >> originalString; - string result = reverseString(originalString); + std::string result = reverseString(originalString); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/Sort-Array/boilerplate-full/function.cpp b/apps/problems/Sort-Array/boilerplate-full/function.cpp index 00e2632..e9fa674 100644 --- a/apps/problems/Sort-Array/boilerplate-full/function.cpp +++ b/apps/problems/Sort-Array/boilerplate-full/function.cpp @@ -17,11 +17,11 @@ int size_values; std::istringstream(lines[0]) >> size_values; std::vector values(size_values); - if(!size_values==0) { + if(size_values != 0) { std::istringstream iss(lines[1]); - for (int i=0; i < size_arr; i++) iss >> arr[i]; + for (int i=0; i < size_values; i++) iss >> values[i]; } - list result = sortArray(values); + std::list result = sortArray(values); std::cout << result << std::endl; return 0; } diff --git a/apps/problems/max-element/boilerplate-full/function.cpp b/apps/problems/max-element/boilerplate-full/function.cpp index 6cace2b..bfceb54 100644 --- a/apps/problems/max-element/boilerplate-full/function.cpp +++ b/apps/problems/max-element/boilerplate-full/function.cpp @@ -17,11 +17,11 @@ int size_arr; std::istringstream(lines[0]) >> size_arr; std::vector arr(size_arr); - if(!size_arr==0) { + if(size_arr != 0) { std::istringstream iss(lines[1]); for (int i=0; i < size_arr; i++) iss >> arr[i]; } - int result = maxElement(arr); + std::int result = maxElement(arr); std::cout << result << std::endl; return 0; }