Coder Social home page Coder Social logo

aadamsx / algorithms.coffee Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brunorb/algorithms.coffee

0.0 1.0 0.0 845 KB

Classic algorithms and data structures in coffeescript. Making the World a better place, with coffee.

License: MIT License

algorithms.coffee's Introduction

algorithms.coffee

Build Status

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).

It uses Mocha as the Testing Framework, Chai as the Assertion Library and CoffeeLint as the Style Checker Library.

Algorithms implemented so far:

Data Structures:

  • Adjacency List
  • Adjacency Matrix
  • Binary Search Tree
  • Disjoint Set
  • Heap
  • Segment Tree

Graph:

  • Bellman-Ford
  • Breadth First Search
  • Cycle Detection
  • Depth First Search
  • Edmonds-Karp
  • Floyd-Warshall
  • Kosaraju
  • Kruskal

Math:

  • Euclidean Distance
  • Karatusba Multiplication
  • Knuth Shuffle
  • Next Permutation
  • Reservoir Sampling

Search:

  • Binary Search

Sorting:

  • Binary Tree Sort
  • Heap Sort
  • Insertion Sort
  • Merge Sort
  • Radix Sort
  • Selection Sort

String:

  • Edit Distance
  • Knuth-Morris-Pratt
  • Longest Common Subsequence
  • Karp-Rabin

Getting Started

Users

NodeJS

To use the library on a NodeJS project just install it with npm:

Globally:

npm -g install algorithms.coffee

or Locally in the project's directory:

npm install algorithms.coffee

And use the require to use the functions.

Example:

var myVariable = require('algorithms.coffee');
var sortedArray = myVariable.insertionSort([3, 1, 2]);

Browser

To use the library in standard client-side JavaScript just download the js file contained in the ./dist/ then include it like any other .js.

<script src="algorithms.coffee.js"></script>

Or the minified version

<script src="algorithms.coffee.min.js"></script>

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();

Contributors

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.

Basic Requirements

You will need to have the following softwares installed on your computer:

  • NodeJS: version 0.10.0 or higher;
  • npm: latest version;
  • git: latest version;

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:

npm install

and execute Grunt just to make sure everything is up and running:

grunt

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 coffeelint.json and the other default options of CoffeeLint.

Before you send a Pull Request, run grunt again to be sure that everything is OK.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.