This repository contains my solutions, templates, and utilities for competitive programming in Java.
src/solutions— Solution code, organized by site/category.src/test/— Unit tests for problems (optional).templates/— Java templates for quick problem setup.lib/— External libraries (e.g., JUnit).input/andoutput/— Sample input/output files for local testing.pom.xml— Maven build file for dependency management.
Copy a template from templates/Template.java to start a new problem quickly.
- Configure the following lines at the top of your ProblemName.java file and set LOCAL to true to allow for local testing:
boolean LOCAL = true;
BufferedReader br;
PrintWriter out;
if (LOCAL) {
br = new BufferedReader(new FileReader("src/input/problemname.in"));
out = new PrintWriter(new FileWriter("src/output/problemname.out"));
} else {
br = new BufferedReader(new FileReader("problemname.in"));
out = new PrintWriter(new FileWriter("problemname.out"));
}-
Create the
problemname.infile in thesrc/inputdir and leave your emptyproblemname.outfile in thesrc/output -
Run your
problemname.javafile and check theproblemname.outfile for results
Prerequisites: Maven installed, Debugger for Java Extension installed (this is a VSCode setup)
-
Create a
[problemname]Test.javafile inside thesrc/test/javadir -
Copy and paste the template from
src/main/java/templates/TestTemplate.javaand configure it to your liking -
Run the test using the Testing sidebar or:
mvn test- Clone the repository:
git clone <repo-url> cd competitive-programming
- Compile a solution:
javac src/solutions/path/to/ProblemName.java
- Run a solution:
java -cp src/main/java path.to.ProblemName
Contributions are welcome! Please follow the existing structure and naming conventions. Submit a pull request with your changes.
This project is licensed under the MIT License.