This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This function will flatten an array of arbitrarily nested | |
arrays of integers into a flat array of integers | |
it returns an array of flattened items | |
SETUP INSTRUCTIONS | |
make sure you have nodejs >= V6.0 installed | |
in your terminal make a new folder with mkdir flatten | |
navigate to the newly created folder with cd flatten | |
make a new file with touch index.js | |
install mocha and chai using npm install mocha chai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HashID = {}; | |
HashID.generate = () => { | |
const alphabet = '23456789abdegjkmnpqrvwxyz'; | |
const idLength = 9; | |
let result = ''; | |
for (let index = 0; index < idLength; index += 1) { | |
result += alphabet.charAt(Math.floor(Math.random() * alphabet.length)); | |
} | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
0: 'about', | |
1: 'abuse', | |
2: 'access', | |
3: 'account', | |
4: 'accounts', | |
5: 'acme', | |
6: 'activate', | |
7: 'activities', | |
8: 'activity', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates a range of values from `from` to `to`. | |
* @param {number} from - The starting value of the range. | |
* @param {number} to - The ending value of the range. | |
* @returns {function} - A generator function that produces values in the range. | |
*/ | |
const fromTo = (from, to) => { | |
let array = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts a word into a bitmask. | |
* @param {string} word - The word to convert. | |
* @returns {number} The bitmask representing the word. | |
*/ | |
const wordToBitmask = (word) => { | |
let bitmask = 0; | |
for (let char of word) { | |
bitmask |= 1 << (char.charCodeAt(0) - 'a'.charCodeAt(0)); |