This git repository will serve to store generic algorithms for programming problems and contests. Feel free to modify anything, as long as it is productive and purposeful, and help out when possible.
The repository is structured how it is to make the build process easier. All code for the algorithms should go under the main/ directory in the appropriate directory. Any code for testing the algorithms should be placed under test/ in the correct corresponding directory.
The code is built using an ant build script. Here are a few useful commands:
ant cleanant allant compileant testsant [algorithm directory]ant [specific algorithm]
If you add or remove something, please make sure the build script is up to date. When the build script is run all algorithms and test code should go to the appropriate directory under target/.
To run a specific test, you will have to set the classpath, cd into the
target directory or use run.sh:
cd target; java test.Math.PrimeFactorization.TestTrialDivisionjava -classpath target/ test.Math.PrimeFactorization.TestTrialDivision./run.sh TestTrialDivision
Bash is capable of tab completing the fully qualified class name in the first two examples.
To run all the tests, a runtests.sh script has been provided. It will run
all tests that have been built, and only report failures. The return code
indicates the number of tests that have failed.
If you pass any argument to it, it will also indicate which tests have passed.
If that is all you're interested in, try
./runtests.sh show_success | grep ^SUCCESS
Currently, we have several sections for different types of algorithms:
- Backtracking
- Branch & Bound
- Brute Force
- Combinations / Permutations
- Divide & Conquer
- Graph
- Greedy
- Recursive
Please use Markdown for formatting any documentation for algorithms or any related projects. It's cool and easy to use.
You can easily add code markup by surrounding code in tick marks (`), such
as, int var = 0;.
Or, you can just add your code on a new tab and type code freely.
public static void main(String[] args) {
System.out.println("Hello, world!");
}
Pretty and syntactically correct mathematical equations can be generated by following this How To.