barretlee / algorithms

All algorithms writing with javascript in the book 'Algorithms Fourth Edition'.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Algorithms in JavaScript

Detail & Discusion (讨论和细节)

All algorithms writing with JavaScript in book 'Algorithms Fourth Edition'.

Usage

Run generator/create.js to generate code template.

# create a file with `file.xtpl` at `chapter/chapter-1-xxx/1.2-xxx/test.js`
node generator/create 1.2/test

# delete file `chapter/chapter-1-xxx/1.2-xxx/test.js` if exists
node generator/create 1.2/test -d

The template is:

console.log('<%- fileName %>:')
/* input start */
var input = require('../../../generator/index').getRandomNumbers();
/* input end */
console.log('> input: ' + input);


// <%- fileName %>
function <%- fileName %>(input) {
  var output;
  return output;
}


/* output start */
console.log('> output: ' + <%- fileName %>(input));
/* output end */

There are many functions in genetator/index for generating data. such as:

var input = require('./generator/index').getRandomNumbers();
// -> [random numbers which length is default 20 between 0 to 1E5]

License

The MIT License (MIT)

Copyright (c) 2016 小胡子哥

About

All algorithms writing with javascript in the book 'Algorithms Fourth Edition'.

License:MIT License


Languages

Language:JavaScript 100.0%