Mathball is an npm package for competitive programming in JavaScript with a focus on common mathematical utilities being implemented in relevant algorithms & data structures for optimized performance!
JavaScript was never built while keeping competitive coding in mind; let us all agree on that. But, the stuff that we build with it today was not something it was built for either! Back in 1995, Brendan Eich 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.
Based on the notion - JS is everywhere! I also believe that maybe its time to motivate people who are well versed with this language to finally consider it in the realm of competitive programming.
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):
$ npm install mathball --save
-
Number Checkers - isArmstrong() - isAutomorphic() - isKaprekar() - isLucky() - isNeon() - isPalindrome() - isPerfect() - isPrime() - isSmith()
-
Find nth Number - catalan() - factorial() - fibonacci() - magic() - smart()
-
Mathematical Utilities - gcd() - isEven() - isOdd() - lcm() - length() - max() - min() - sort() - sum()
-
Helper Methods - performance() - pipe()
You can access all the utilities via mathball object, M
(or whatever you end up calling it) like so:
let M = require('mathball');
console.log(M.isPalindrome(1551)) //true
console.log(M.isEven(7)) //false
console.log(M.sum([4, 5, 9])) //18
Or, you can directly access an individual function as given below:
let gcd = require('mathball/lib/gcd');
console.log(gcd([12, 18, 24])); //6
- Fork the project. 🍴
- Fix issues & add changes. 🔧
- Follow the guidelines given in CONTRIBUTING.md. 🌟
- Make a PR. 🔨
- Mission Acomplished! 🎉
Mathball has been selected at GirlScript Summer of Code 2019!
The MIT License 2019 - Priyabrata Biswas.