Skip to content

Commit

Permalink
Merge pull request #42 from vishalmishraa/butify-problem-page
Browse files Browse the repository at this point in the history
fix problem
  • Loading branch information
vishalmishraa authored Sep 5, 2024
2 parents 8f706f6 + 38bb487 commit fdc3f1b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export default function generateFullCpp({
const inputReads = inputFields
.map((field, index) => {
if (field.type.startsWith("list<")) {
return `int size_${field.name};\n std::istringstream(lines[${index}]) >> size_${field.name};\n ${makeType.ToCpp(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 }`;
return `int size_${field.name};\n istringstream(lines[${index}]) >> size_${field.name};\n ${makeType.ToCpp(field.type)} ${field.name}(size_${field.name});\n if(size_${field.name} != 0) {\n \tistringstream iss(lines[${index + 1}]);\n \tfor (int i=0; i < size_${field.name}; i++) iss >> ${field.name}[i];\n }`;
} else {
return `${makeType.ToCpp(field.type)} ${field.name};\n std::istringstream(lines[${index}]) >> ${field.name};`;
return `${makeType.ToCpp(field.type)} ${field.name};\n istringstream(lines[${index}]) >> ${field.name};`;
}
})
.join("\n ");
const outputType = outputFields[0].type;
const functionCall = `${outputType} result = ${functionName}(${inputFields.map((field) => field.name).join(", ")});`;
const outputWrite = `std::cout << result << std::endl;`;
const outputWrite = `cout << result << endl;`;

return ` #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
Expand Down Expand Up @@ -116,10 +116,10 @@ export default function generateFullCpp({
##USER_CODE_HERE##
int main() {
std::ifstream file("${process.env.PV_DIR_PATH}/${problemName.replace(" ", "-")}/tests/inputs/##INPUT_FILE_INDEX##.txt");
std::vector<std::string> lines;
std::string line;
while (std::getline(file, line)) lines.push_back(line);
ifstream file("${process.env.PV_DIR_PATH}/${problemName.replace(" ", "-")}/tests/inputs/##INPUT_FILE_INDEX##.txt");
vector<string> lines;
string line;
while (getline(file, line)) lines.push_back(line);
file.close();
${inputReads}
Expand Down
2 changes: 1 addition & 1 deletion apps/problems/Reverse-String/tests/inputs/3.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
A man a plan a canal Panama
letgoo
1 change: 1 addition & 0 deletions apps/problems/Reverse-String/tests/inputs/4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yup

0 comments on commit fdc3f1b

Please sign in to comment.