This file contains hidden or 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
function CaesarSolver(str) { | |
let alphabet = 'abcdefghijklmnopqrstuvwxyz'; | |
str = str.toLowerCase(); | |
let words = str.split(/\s+/); | |
let permutations = []; | |
for (let j = 0; j < alphabet.length; j++) { | |
let list = []; | |
for (let i = 0; i < words.length; i++) { | |
let word = ""; | |
let letters = words[i].split(''); |
This file contains hidden or 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
function findBestPayoffSequence(loans) { | |
return loans.reduce(function (a, b) { | |
b.effeciencyScore = (b.monthlyPayment / b.amountLeft) * 100 | |
a.push(b) | |
return a | |
}, []).sort(function (a, b) { return a.effeciencyScore >= b.effeciencyScore }) | |
} | |
function createDebtKillingPlan(loans) { |
This file contains hidden or 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
/** | |
* Create multi-dimensional array | |
* @name multiDimensionalArray | |
* @function | |
* @param {number[]} d the depth of each dimension | |
* @example | |
* // create 3 dimensional array, 10 cells deep in every direction (10 by 10 by 10) | |
* multiDimensionalArray([10,10,10]); | |
*/ | |
const multiDimensionalArray = (()=>{ |
This file contains hidden or 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
function similarity(text1, text2) { | |
text1 = text1.split(/\s+/); | |
text2 = text2.split(/\s+/); | |
let wordsInCommon = []; | |
let similarWordCount = 0; | |
for (var i = 0; i < text1.length; i++) { | |
let word = text1[i]; | |
if (text2.includes(word)) { | |
similarWordCount++; | |
if (!wordsInCommon.includes(word)) { |
This file contains hidden or 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
function getSyllables(word) { | |
return word.replace(/e$/,'').match(/tion|sion|[aeiou]{3,}|[aeou]+|[aeiou]/g).length; | |
} |
This file contains hidden or 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
function PromptGenerator() { | |
var self = this; | |
function pos(a) { | |
if (Array.isArray(a)) { | |
if (!('d' in pos)) pos.d = {}; | |
for (var i = 0, p = null; i < a.length; i++) { | |
(pos.d[p] ? pos.d[p] : pos.d[p] = []).push(p = a[i]); | |
} | |
} else if ("number" == typeof a) { |
This file contains hidden or 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
function buildMapWithPath(H, W, L) { | |
let A = [], p = [0,0]; | |
for (let Y = 0; Y < H; Y++) { | |
A[Y] = []; | |
for (let X = 0; X < W; X++) { | |
A[Y].push(0); | |
} | |
} | |
function mark(p) { | |
A[p[0]][p[1]] = 1; |
This file contains hidden or 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
/** | |
* Machine learning algorithm that learns underlying patterns in sequences and replicates them using frequency analysis. | |
* AKA a markov chain XD | |
* @function | |
* @param {Array|Number} a A sequence or the length of a sequence to return | |
* @example | |
* // feed it a sequence to learn from | |
* m([1,1,2,3,3,2,1]); | |
* // have it generate a sequence 7 items long | |
* m(7); |
This file contains hidden or 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
// generate character mind model | |
function MindModel() { | |
this.id = personality.id + ':' + intelligence.id; | |
this.personality = generatePersonality(); | |
this.intelligence = generateIntelligence(); | |
} | |
// 32 fundimental personality types with a total of 1,048,576 (16^5) variations. | |
// that's 32,768 variations per personality type | |
function generatePersonality() { | |
// variable declarations |
This file contains hidden or 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
<?php | |
/* | |
// EXAMPLE USE | |
// construct web token manager | |
$jwt = new JWT("SecretKey"); | |
// ^ init JWT with a server side secret key ^ |
NewerOlder