@@ -297703,12 +297703,12 @@ var CommandTreeDataProvider = class {
297703297703 this.onDidChangeTreeData = this._onDidChangeTreeData.event;
297704297704 // Mapping of command IDs to their display names, icons, and colors
297705297705 this.extensionCommands = {
297706- "leetcode-cph-helper-by-ashish.fetchLeetCodeTestCases": { label: "Fetch Test Cases", icon: "cloud-download", color: "charts.green" },
297707- "leetcode-cph-helper-by-ashish.runTestCases": { label: "Run Test Cases", icon: "play-circle", color: "charts.blue" },
297708- "leetcode-cph-helper-by-ashish.writeSolutionFile": { label: "Write Solution File", icon: "file-code", color: "charts.yellow" },
297709- "leetcode-test-case-manager.getSolutionFileDirectory": { label: "Get Solution File Directory", icon: "folder", color: "charts.orange" },
297710- "leetcode-cph-helper-by-ashish.getIOFileDirectory": { label: "Get I/O File Directory", icon: "folder", color: "charts.red" },
297711- "leetcode-cph-helper-by-ashish.showLeetCodeProblemLinks": { label: "Show LeetCode Problem Links", icon: "link", color: "charts.purple" }
297706+ "leetcode-cph-helper-by-ashish.fetchLeetCodeTestCases": { label: "Fetch Test Cases(CTRL+1) ", icon: "cloud-download", color: "charts.green" },
297707+ "leetcode-cph-helper-by-ashish.runTestCases": { label: "Run Test Cases(CTRL+5) ", icon: "play-circle", color: "charts.blue" },
297708+ "leetcode-cph-helper-by-ashish.writeSolutionFile": { label: "Write Solution File(CTRL+4) ", icon: "file-code", color: "charts.yellow" },
297709+ "leetcode-test-case-manager.getSolutionFileDirectory": { label: "Get Solution File Directory(CTRL+3) ", icon: "folder", color: "charts.orange" },
297710+ "leetcode-cph-helper-by-ashish.getIOFileDirectory": { label: "Get I/O File Directory(CTRL+2) ", icon: "folder", color: "charts.red" },
297711+ "leetcode-cph-helper-by-ashish.showLeetCodeProblemLinks": { label: "Show LeetCode Problem Links(CTRL+6) ", icon: "link", color: "charts.purple" }
297712297712 };
297713297713 }
297714297714 // Returns a TreeItem representation of the given element
@@ -297851,135 +297851,37 @@ function activate(context2) {
297851297851# Provide the test case number and function name
297852297852#run_test_case(TEST_CASE_NUMBER, FUNCTION_NAME);
297853297853run_test_case()` : `#include <bits/stdc++.h>
297854- #include <filesystem>
297855- #include <functional>
297856- #include <iostream>
297857- #include <sstream>
297858- #include <string>
297859- #include <vector>
297860-
297861297854using namespace std;
297862- namespace fs = std::filesystem;
297863297855
297864- // Parse values from string
297865- template <typename T>
297866- T parseValue(const string& str) {
297867- istringstream iss(str);
297868- T value;
297869- iss >> value;
297870- return value;
297871- }
297856+ //write the code logic here
297872297857
297873- // Template specialization for string
297874- template <>
297875- string parseValue<string>(const string& str) {
297876- // Remove quotes if present
297877- if (str.size() >= 2 && str.front() == '"' && str.back() == '"') {
297878- return str.substr(1, str.size() - 2);
297879- }
297880- return str;
297881- }
297882297858
297883- // Parse arrays from string
297884- template <typename T>
297885- vector<T> parseArray(const string& str) {
297886- vector<T> result;
297887- string trimmedStr = str.substr(1, str.size() - 2); // Remove brackets
297888- istringstream iss(trimmedStr);
297889- string item;
297890- while (getline(iss, item, ',')) {
297891- result.push_back(parseValue<T>(item));
297892- }
297893- return result;
297894- }
297895-
297896- // Function to detect data type from string
297897- template <typename T>
297898- T detectAndParseValue(const string& str) {
297899- if (str.empty()) {
297900- throw runtime_error("Empty input string");
297901- }
297902-
297903- // Check if it's an array
297904- if (str.front() == '[' && str.back() == ']') {
297905- return parseArray<typename T::value_type>(str);
297906- }
297907-
297908- // Check if it's a string (quoted)
297909- if (str.front() == '"' && str.back() == '"') {
297910- return parseValue<T>(str);
297911- }
297912-
297913- // Otherwise treat as numeric or other type
297914- return parseValue<T>(str);
297915- }
297916-
297917- // Generic function to run test cases
297918- template <typename T>
297919- void run_test_case(int test_case_number, const function<void(const T&)>& solution_function) {
297920- fs::path base_directory = fs::path(__FILE__).parent_path().parent_path();
297921- fs::path file_path = base_directory / "test_cases" / ("input_" + to_string(test_case_number) + ".txt");
297922-
297923- try {
297924- ifstream file(file_path);
297925- if (!file.is_open()) {
297926- throw runtime_error("File not found at " + file_path.string());
297927- }
297859+ // Function to run the tes case
297860+ void runTestCase(int n) {
297861+ string filePath = "../test_cases/input_" + to_string(n) + ".txt";
297862+ ifstream file(filePath);
297928297863
297929- string line;
297930- vector<string> lines;
297931- while (getline(file, line)) {
297932- lines.push_back(line);
297933- }
297934-
297935- if (lines.empty()) {
297936- throw runtime_error("Invalid input format");
297937- }
297938-
297939- // Parse input based on type T
297940- T parsed_input = detectAndParseValue<T>(lines[0]);
297941- solution_function(parsed_input);
297942-
297943- } catch (const exception& e) {
297944- cerr << "Error: " << e.what() << endl;
297864+ if (!file.is_open()) {
297865+ cerr << "Error: File not found at " << filePath << ". Check the file path and try again." << endl;
297866+ return;
297945297867 }
297946- }
297947297868
297948- // -------------------- SOLUTION TEMPLATE --------------------
297949- // MODIFY THIS SECTION FOR YOUR SPECIFIC PROBLEM
297869+ // if your input files has vector/array uncomment the below code
297870+ // Read the array from the file
297950297871
297951- void solution(const vector<string>& args) {
297952- // Example parsing different types of inputs
297953- // Modify according to your problem requirements
297954-
297955- // For array input: [1,2,3]
297956- if (!args.empty() && args[0][0] == '[') {
297957- auto arr = parseArray<int>(args[0]);
297958-
297959- }
297960-
297961- // For string input: "hello"
297962- if (args.size() >= 2 && args[1][0] == '"') {
297963- string str = args[1].substr(1, args[1].length() - 2);
297964- }
297965-
297966- // For integer input: 42
297967- if (args.size() >= 3) {
297968- int num = parseValue<int>(args[2]);
297969- }
297970-
297971- // YOUR SOLUTION LOGIC GOES HERE
297972-
297872+ // Call the function and print the result(pass all the varbles that you have read from the file)
297873+ //<data type> result = <function_name>(<variables>);
297973297874
297875+ cout << result << endl;
297974297876}
297975297877
297976297878int main() {
297977- // Run single test case
297978- run_test_case<vector<int>>(1, solution);
297979-
297980-
297879+ // Example usage
297880+ runTestCase(); // Adjust the number as needed for your actual test case
297981297881 return 0;
297982- }`;
297882+ }
297883+
297884+ `;
297983297885 fs8.writeFileSync(filePath, boilerplate, "utf-8");
297984297886 const document2 = await vscode3.workspace.openTextDocument(filePath);
297985297887 await vscode3.window.showTextDocument(document2);
0 commit comments