0.1.0 • Published 8 years ago

node-algorithms v0.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

Algorithms

A node.js library providing a semantic way for implementing algorithms.

Used to solve project-euler and topcoder problems.

Project Euler

    var testAlgorithm = new Algorithm();
  
    testAlgorithm.prototype.solve = function(limit, multipleOf) {
    
      var multiples = [];
  
      this.iterate({
        start: 1,
        limit: limit
       }).onEach(function(current) {
        if (current.isMultiple(multipleOf)) {
          multiples.push(current.value);
        }
      });
    
    }
    ...
    ...
    console.log(new testAlgorithm().solve(1000, [3, 5]).toString());

Run the problems

./problems/runner.js
Counting summations - total: 175, time: 0.69 s => Check Failed.

Push notifications when problem execution ends

Optionally problems runner supports an extra parameter p that will send a push notification using Pushover. For that reason the package node-pushover-alerts is included in the package.json. You will need to have a ./config/pushover.json file, containing your user and token for authentication.

./problems/runner.js -p
Counting summations - total: 175, time: 0.69 s => Check Failed.
Message sent: {"status":1,"request":"c4efe36f51adf23781e90c33efb96249"}

Example of ./config/pushover.json

{
        "user": "",
        "token": ""
}

Dependencies

big-integer: an arbitrary-length integer library for Javascript. 
https://github.com/peterolson/BigInteger.js