mathball
Version:
A JavaScript library for Competitive Programming
99 lines (72 loc) • 5.78 kB
Markdown
# Introduction
[](https://badge.fury.io/js/mathball) [](https://travis-ci.org/pbiswas101/Mathball) [](https://snyk.io/test/github/pbiswas101/Mathball?targetFile=package.json) [](https://codecov.io/gh/pbiswas101/Mathball) [](https://www.codacy.com/app/pbiswas101/Mathball?utm_source=github.com&utm_medium=referral&utm_content=pbiswas101/Mathball&utm_campaign=Badge_Grade)  [](http://makeapullrequest.com)  [](https://opensource.org/licenses/MIT)

**Mathball** is a JavaScript library for competitive programming, implementing optimized algorithms for faster execution.
JavaScript was never built while keeping competitive coding in mind; let us all agree on that. Back in 1995, [Brendan Eich][1] developed JavaScript only for adding interactivity to web pages like handling a mouse click. Today, we can build _servers_, _games_, _mobile apps_, _IoT apps_ and even _machine learning_ in the browser is possible with JavaScript.
> "Any application that can be written in JavaScript, will eventually be written in JavaScript." -- Atwood's Law.
Hence, I believe maybe its time for people who are well versed with this particular language to finally consider using it in the realm of competitive programming as well.
## Installation
You can download the package in your working directory by simply typing in the **terminal** (for Mac/Linux users) or **command prompt** (for Windows users):
```bash
$ npm install mathball --save
```
## Features
- **Numbers' Problem** - [Complex Number][2], [Find nth Number][3], [Number Checker][4], [Range of Number][5]
- **Helper Functions** - [Performance][6] - [Pipe][7]
- **Core Tools** - [Absolute][8] - [Add][9] - [Average][10] - [Binomial Coeff][11] - [Convert][12] - [Count][13] - [Divide][14] - [Euler's Totient][15] - [Modular Exponent][16] - [GCD][17] - [LCM][18] - [Length][19] - [Maximum][20] - [Median][21] - [Minimum][22] - [Modular Inverse][23] - [Multiply][24] - [Permute][25] - [Set Bits][26] - [Sort][27] - [Subtract][28] - [Sum][29]
- **Data Structures** - [Graph][30] - [Matrix][31] - [Priority Queue][32] - [Stack][33]
## Examples
You can access all the functions via **mathball** object, `M` (or whatever you end up calling it) like so:
```js
let M = require('mathball');
console.log(M.check('palindrome')(1551)); /* true */
console.log(M.check('even')(7)); /* false */
console.log(M.sum([4, 5, 9])); /* 18 */
```
## Contribution
1. Fork the project. :fork_and_knife:
2. Fix issues & add changes. :wrench:
3. Follow the guidelines given in [CONTRIBUTING.md][34]. :star2:
4. Make a PR. :hammer:
5. Mission Acomplished! :tada:
## Important Notice
> **Mathball** has been selected at [GirlScript Summer of Code 2019][35]!

## License
The MIT License 2019 - [Priyabrata Biswas][36].
[1]: https://en.wikipedia.org/wiki/Brendan_Eich
[2]: https://github.com/pbiswas101/Mathball/blob/master/docs
[3]: https://github.com/pbiswas101/Mathball/blob/master/docs
[4]: https://github.com/pbiswas101/Mathball/blob/master/docs
[5]: https://github.com/pbiswas101/Mathball/blob/master/docs
[6]: https://github.com/pbiswas101/Mathball/blob/master/docs
[7]: https://github.com/pbiswas101/Mathball/blob/master/docs
[8]: https://github.com/pbiswas101/Mathball/blob/master/docs
[9]: https://github.com/pbiswas101/Mathball/blob/master/docs
[10]: https://github.com/pbiswas101/Mathball/blob/master/docs
[11]: https://github.com/pbiswas101/Mathball/blob/master/docs
[12]: https://github.com/pbiswas101/Mathball/blob/master/docs
[13]: https://github.com/pbiswas101/Mathball/blob/master/docs
[14]: https://github.com/pbiswas101/Mathball/blob/master/docs
[15]: https://github.com/pbiswas101/Mathball/blob/master/docs
[16]: https://github.com/pbiswas101/Mathball/blob/master/docs
[17]: https://github.com/pbiswas101/Mathball/blob/master/docs
[18]: https://github.com/pbiswas101/Mathball/blob/master/docs
[19]: https://github.com/pbiswas101/Mathball/blob/master/docs
[20]: https://github.com/pbiswas101/Mathball/blob/master/docs
[21]: https://github.com/pbiswas101/Mathball/blob/master/docs
[22]: https://github.com/pbiswas101/Mathball/blob/master/docs
[23]: https://github.com/pbiswas101/Mathball/blob/master/docs
[24]: https://github.com/pbiswas101/Mathball/blob/master/docs
[25]: https://github.com/pbiswas101/Mathball/blob/master/docs
[26]: https://github.com/pbiswas101/Mathball/blob/master/docs
[27]: https://github.com/pbiswas101/Mathball/blob/master/docs
[28]: https://github.com/pbiswas101/Mathball/blob/master/docs
[29]: https://github.com/pbiswas101/Mathball/blob/master/docs
[30]: https://github.com/pbiswas101/Mathball/blob/master/docs
[31]: https://github.com/pbiswas101/Mathball/blob/master/docs
[32]: https://github.com/pbiswas101/Mathball/blob/master/docs
[33]: https://github.com/pbiswas101/Mathball/blob/master/docs
[34]: https://github.com/pbiswas101/Mathball/blob/master/CONTRIBUTING.md
[35]: https://www.gssoc.tech/
[36]: https://github.com/pbiswas101