Browse Source

allow custom template and add guide in readme

Marcelo Fornet 6 years ago
parent
commit
d29b54d8c5
5 changed files with 80 additions and 17 deletions
  1. 61 0
      README.md
  2. 9 1
      package.json
  3. 7 1
      src/core.ts
  4. 1 13
      src/static/sol.cpp
  5. 2 2
      todo.md

+ 61 - 0
README.md

@@ -11,3 +11,64 @@
 * Smart veredict reporting (OK, WA, RTE, TLE, CE)
 * Stressing solution against brute using a generator (Useful to find corner cases)
 * (WIP) Automatic generator creation from inputs/outputs structure
+
+## How am I supposed to use **acmX**
+
+**acmX** have been designed to run automatically boilerplate actions [I](https://codeforces.com/profile/marX) repeat often in competitive programming. This is the expected pipeline to interact with it.
+
+* Create a contest calling `New Contest` or maybe a single problem calling `New Problem`. Testcases are downloaded automatically :)
+
+* Start coding awesome solution inside file `sol.cpp`. Right now solutions are only available in C++.
+
+* After you finish the code call `Run` and automatically your program will be compiled and run against every testcases. If the solutions seems to be ok, it will be reported otherwise you will see failing testcase in a *cool layout*. You can always go back to original layout calling `View: Code`.
+
+* Add more testcases than provided in statement using `Add Test Case`, or modify and see existing testcases by calling `Open Test Case`.
+
+* If your solution keep failing you can stress it using a generator and a brute solution. Call `Upgrage` to create both generator (`attic/gen.py`) and correct (`brute.cpp`) programs. Right now generator must be written in python, and correct program must be written in C++. After both codes are ready just call `Stress` and your original code will be tested on random test cases from generator against correct solution.
+
+The environment structure is the following:
+
+```file
+    contest/
+        problemA/
+            sol.cpp
+            brute.cpp
+            attic/
+                sol
+                brout
+                gen.py
+            testcases/
+                1.in
+                1.out
+                1.real
+                ...
+        problemB/...
+        problemC/...
+        problemD/...
+        problemE/...
+```
+
+Certainly **acmX** can be (and hopefully will be) extended so that it fits everyones pipeline. If **acmX** almost fit yours, feel free to improve it and make a PR! I'll be happy to hear from you and give you support.
+
+## Default template is awful, how can I change it
+
+Create a file with your template. In settings change `acmx.configuration.templatePath` to the path of your templates file.
+
+## Commands
+
+* acmx.addProblem (**New Problem**):
+* acmx.addContest (**New Contest**):
+* acmx.runSolution (**Run**):
+* acmx.openTestcase (**Open Test Case**):
+* acmx.addTestcase (**Add Test Case**):
+* acmx.coding (**View: Code**):
+* acmx.stress (**Stress**):
+* acmx.upgrade (**Upgrade**):
+* acmx.compile (**Compile**):
+
+## Settings
+
+* **acmx.configuration.templatePath**: Path to template file. Leave empty to use default template.
+* **acmx.run.timetimeLimit**: Maximum time limit in seconds to run the program on each test case.
+* **acmx.execution.compileCpp**: Command to compile C++ programs. Refer to the code as $PROGRAM, and output file as $OUTPUT.
+* **acmx.execution.pythonPath**: Path to python executable. This will be used to run generator.

+ 9 - 1
package.json

@@ -10,7 +10,7 @@
         "vscode": "^1.30.0"
     },
     "author": {
-		"name": "marx"
+		"name": "Marcelo Fornet"
 	},
     "categories": [
         "Other"
@@ -39,6 +39,7 @@
 						"description": "Maximum time limit in seconds to run the program on each test case.",
 						"scope": "resource"
                     },
+
 					"acmx.execution.compileCpp": {
                         "type": "string",
 						"default": "g++ -std=c++11 $PROGRAM -o $OUTPUT",
@@ -50,6 +51,13 @@
 						"default": "/usr/bin/python3",
 						"description": "Path to python executable.",
 						"scope": "resource"
+                    },
+
+					"acmx.configuration.templatePath": {
+                        "type": "string",
+						"default": "",
+						"description": "Path to template file. Leave empty to use default template.",
+						"scope": "resource"
 					}
 				}
             }

+ 7 - 1
src/core.ts

@@ -109,7 +109,13 @@ export function newArena(path: string){
     let attic = join(path, ATTIC);
     createFolder(attic);
 
-    copyFileSync(join(SRC, 'static', 'sol.cpp'), join(path, 'sol.cpp'));
+    let templatePath: string | undefined = vscode.workspace.getConfiguration('acmx.configuration').get('templatePath');
+
+    if (templatePath! === ""){
+        templatePath = join(SRC, 'static', 'sol.cpp');
+    }
+
+    copyFileSync(templatePath!, join(path, 'sol.cpp'));
     copyFileSync(join(SRC, 'static', 'checker'), join(path, ATTIC, 'checker'));
 }
 

+ 1 - 13
src/static/sol.cpp

@@ -1,20 +1,8 @@
-#include <bits/stdc++.h>
+#include <iostream>
 
 using namespace std;
 
-#define endl '\n'
-
-typedef long long int64;
-typedef pair<int,int> pii;
-typedef vector<int> vi;
-
-const double eps = 1e-9;
-const int oo = 0x3f3f3f3f;
-const int mod = 1000000007;
-
 int main(){
-    ios_base::sync_with_stdio(0);
-    cin.tie(0);
 
 
     return 0;

+ 2 - 2
todo.md

@@ -4,9 +4,9 @@
 * **WOW** Use this tool: [caide-cpp-inliner](https://github.com/slycelote/caide-cpp-inliner).  Suggestion from jcg
 * When a new view is activated (after run or view:code) close all open tabs. (also (maybe) collapse everything not related to the problem)
 * Allow programming in other languages than c++
-* Allow stopping a running program (such as sol.cpp/brute.cpp/gen.py/etc...)
 
 * [005](/src/core.ts): Restrict brute in time, and capture errors
+  * Allow stopping a running program (such as sol.cpp/brute.cpp/gen.py/etc...)
 * [007](/src/extension.ts): How can I have access to new proccess created using `openFolder`?
 
 ## Settings
@@ -14,7 +14,7 @@
 Global settings
 
 * [x] Time Limit
-* [ ] Template file
+* [X] Template file
 * [X] Line to execute C++ (Upgrade this line, by increasing stack and making optimizations by default)
 * [X] Line to execute Python