A CLIxLibrary for Competitive Programming with JavaScript/Node.js
- Node v12.x or higher (preferably v16.x+)
- Set node modules to path variable to use cli
For the package:
npm i compe
For the cli, you can:
npm i -g compe minify
You can add the prefix npx
after every command as an alternative where you want to avoid installing global package.
Enable intellisense to get the best experience.
Add npx
prefix incase you don't have CLIs installed.
$ compe i <source-file.js> <input-file.txt>: Initialize the source file at source-file.js and the input file at input-file.txt (if input-file is empty then the default is 'input.txt')
$ compe s <source-file.js>: Save the source file directory as default
$ compe i s <source-file.js> <input-file.txt>: Initialize the file and then save to config
$ compe r <source-file.js>: If the config has default source file, source-file can be ignored. Run the source file and build it at source-file-build.js and fully compressed to submit on Online Judges at source-file-comp.js
Make a txt (by default from template, it is "input.txt") file in the same directory with the one you want to run for stdin.
The main
function takes in rd
and wr
as a function to read and write.
Sample code for printing sum of an array at demo.js
after init:
const {
Reader, proc, // IO & Processor
multiArray, vectorArray, // Fast array generators
TreeSet, Deque, DisjointSetUnion, PriorityQueue, // Data structures
Graph, dfs, bfs, minimumSpanningTree, dijkstra // Graph Algorithms
} = require('compe');
// DO NOT EDIT THIS LINE //
function main(rl, wr) {
let rd = new Reader(rl);
// write your code from here
let x = rd.readArray();
let sum = 0;
for (let y of x) {
sum += y;
}
wr(y);
}
proc(main, 'input.txt');
- This project uses TSTL's TreeSet where their documentation is here.
- To Be Updated...
- Leetcode
- Codeforces
- TBA: Atcoder, Hackerrank, ...
- TSTL library
- TSDX
- cp-algorithms
- codeforces archive
- This project is inspired by AtCoder Library.