Because there is no life without coffee
Classic algorithms and data structures in CoffeeScript.
Can be used in either NodeJS (server-side JS) or in the Browser (client-side JS).
Algorithms implemented so far:
- Adjacency List
- Adjacency Matrix
- Binary Search Tree
- Disjoint Set
- Segment Tree
- Breadth First Search
- Cycle Detection
- Depth First Search
- Euclidean Distance
- Karatusba Multiplication
- Knuth Shuffle
- Next Permutation
- Reservoir Sampling
- Binary Search
- Binary Tree Sort
- Heap Sort
- Insertion Sort
- Merge Sort
- Radix Sort
- Selection Sort
- Edit Distance
- Longest Common Subsequence
To use the library on a NodeJS project just install it with
npm -g install algorithms.coffee
or Locally in the project's directory:
npm install algorithms.coffee
And use the require to use the functions.
var myVariable = require('algorithms.coffee'); var sortedArray = myVariable.insertionSort([3, 1, 2]);
Or the minified version
All the library features are available through the global variable algCoffee.
var array = [10, 80, 300, 500, 11, 2, 333]; algCoffee.mergeSort(array); var anotherArray = [30, 20, 1, 3, 99, 667]; var heap = new algCoffee.Heap(anotherArray); heap.buildMaxHeap();
We encourage everybody to contribute with this library. Just try and implement any classic algorithm in CoffeeScript or improve the ones that are already implemented.
You will need to have the following softwares installed on your computer:
Basic Steps to Contribute
On the terminal of your computer clone this repository in the directory where you want it to be:
git clone https://github.com/BrunoRB/algorithms.coffee.git
Install the necessary packages from which the library depends on:
and execute Grunt just to make sure everything is up and running:
From this point on you're good to go and contribute with the library.
Just write your
.coffee code in the appropriate directory in
./src and make sure to write the test code as well.
Also, make sure to follow the Coding Style stated in
the other default options of CoffeeLint.
Before you send a Pull Request, run
grunt again to be sure that everything is OK.