Travis build: 452 [cron]

This commit is contained in:
30secondsofcode
2018-09-14 20:10:21 +00:00
parent 7379a789b2
commit d4dc4a1db7
2 changed files with 1919 additions and 1919 deletions

View File

@ -286,24 +286,24 @@
"const password = \"fooBaz\";\nconst data = JSON.stringify(password);\nhttpPut('https://website.com/users/123', data, request => {\n console.log(request.responseText);\n}); // 'Updates a user's password in database'",
"const isArmstrongNumber = digits =>\n (arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)(\n (digits + '').split('')\n );",
"isArmstrongNumber(1634); // true\nisArmstrongNumber(56); // false",
"``` js\nconst isSimilar = (pattern, str) =>\n\t[...str].reduce(\n\t\t(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0\n\t) === pattern.length ? true : false;\n```",
"``` js\nisSimilar('rt','Rohit'); // true\nisSimilar('tr','Rohit'); // false\n```",
"```\n\n</details>\n \n[⬆ Back to top](#table-of-contents)\n\n### levenshteinDistance\n\nCalculates the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between two strings.\n\nCalculates the number of changes (substitutions, deletions or additions) required to convert `string1` to `string2`. \nCan also be used to compare two strings as shown in the second example.\n\n```",
"``` \n\n<details>\n <summary>Examples</summary>\n \n```",
"```\n\n</details>\n \n[⬆ Back to top](#table-of-contents)\n\n### quickSort\n\nQuickSort an Array (ascending sort by default).\n\nUse recursion. \nUse `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it. \nIf the parameter `desc` is truthy, return array sorts in descending order.\n\n```",
"``` \n\n<details>\n <summary>Examples</summary>\n \n```",
"```\n\n</details>\n \n[⬆ Back to top](#table-of-contents)\n\n### removeVowels\n\nReturns all the vowels in a `str` replaced by `repl`.\n\nUse `String.replace()` with a regexp to replace all vowels in `str`.\nOmot `repl` to use a default value of `''`.\n\n```",
"``` \n\n<details>\n <summary>Examples</summary>\n \n```",
"```\n\n</details>\n \n[⬆ Back to top](#table-of-contents)\n\n### solveRPN\n\nSolves the given mathematical expression in [reverse polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation).\nThrows appropriate errors if there are unrecognized symbols or the expression is wrong. The valid operators are :- `+`,`-`,`*`,`/`,`^`,`**` (`^`&`**` are the exponential symbols and are same). This snippet does not supports any unary operators.\n\nUse a dictionary, `OPERATORS` to specify each operator's matching mathematical operation.\nUse `String.replace()` with a regular expression to replace `^` with `**`, `String.split()` to tokenize the string and `Array.filter()` to remove empty tokens.\nUse `Array.forEach()` to parse each `symbol`, evaluate it as a numeric value or operator and solve the mathematical expression.\nNumeric values are converted to floating point numbers and pushed to a `stack`, while operators are evaluated using the `OPERATORS` dictionary and pop elements from the `stack` to apply operations.\n\n```",
"``` \n\n<details>\n <summary>Examples</summary>\n \n```",
"```\n\n</details>\n \n[⬆ Back to top](#table-of-contents)\n\n### howManyTimes\n\nReturns the number of times `num` can be divided by `divisor` (integer or fractional) without getting a fractional answer.\nWorks for both negative and positive integers.\n\nIf `divisor` is `-1` or `1` return `Infinity`.\nIf `divisor` is `-0` or `0` return `0`.\nOtherwise, keep dividing `num` with `divisor` and incrementing `i`, while the result is an integer.\nReturn the number of times the loop was executed, `i`.\n\n```",
"``` \n\n<details>\n <summary>Examples</summary>\n \n```"
"const isSimilar = (pattern, str) =>\n\t[...str].reduce(\n\t\t(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0\n\t) === pattern.length ? true : false;",
"isSimilar('rt','Rohit'); // true\nisSimilar('tr','Rohit'); // false",
"``` js\nconst levenshteinDistance = (string1, string2) => {\n if(string1.length === 0) return string2.length;\n if(string2.length === 0) return string1.length;\n let matrix = Array(string2.length + 1).fill(0).map((x,i) => [i]);\n matrix[0] = Array(string1.length + 1).fill(0).map((x,i) => i);\n for(let i = 1; i <= string2.length; i++) {\n for(let j = 1; j<=string1.length; j++) {\n if(string2[i-1] === string1[j-1]) {\n matrix[i][j] = matrix[i-1][j-1];\n }\n else{\n matrix[i][j] = Math.min(matrix[i-1][j-1]+1, matrix[i][j-1]+1, matrix[i-1][j]+1);\n }\n }\n }\n return matrix[string2.length][string1.length];\n};\n```",
"levenshteinDistance('30-seconds-of-code','30-seconds-of-python-code'); // 7\nconst compareStrings = (string1,string2) => (100 - levenshteinDistance(string1,string2) / Math.max(string1.length,string2.length));\ncompareStrings('30-seconds-of-code', '30-seconds-of-python-code'); // 99.72 (%)",
"const quickSort = ([n, ...nums], desc) =>\n isNaN(n)\n ? []\n : [\n ...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),\n n,\n ...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)\n ];",
"quickSort([4, 1, 3, 2]); // [1,2,3,4]\nquickSort([4, 1, 3, 2], true); // [4,3,2,1]",
"const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi,repl);",
"removeVowels(\"foobAr\"); // \"fbr\"\nremoveVowels(\"foobAr\",\"*\"); // \"f**b*r\"",
"const solveRPN = rpn => {\n const OPERATORS = {\n '*': (a, b) => a * b,\n '+': (a, b) => a + b,\n '-': (a, b) => a - b,\n '/': (a, b) => a / b,\n '**': (a, b) => a ** b\n };\n const [stack, solve] = [\n [],\n rpn\n .replace(/\\^/g, '**')\n .split(/\\s+/g)\n .filter(el => !/\\s+/.test(el) && el !== '')\n ];\n solve.forEach(symbol => {\n if (!isNaN(parseFloat(symbol)) && isFinite(symbol)) {\n stack.push(symbol);\n } else if (Object.keys(OPERATORS).includes(symbol)) {\n const [a, b] = [stack.pop(), stack.pop()];\n stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a)));\n } else {\n throw `${symbol} is not a recognized symbol`;\n }\n });\n if (stack.length === 1) return stack.pop();\n else throw `${rpn} is not a proper RPN. Please check it and try again`;\n};",
"solveRPN('15 7 1 1 + - / 3 * 2 1 1 + + -'); // 5\nsolveRPN('2 3 ^'); // 8",
"const howManyTimes = (num, divisor) => {\n if (divisor === 1 || divisor === -1) return Infinity;\n if (divisor === 0) return 0;\n let i = 0;\n while (Number.isInteger(num / divisor)) {\n i++;\n num = num / divisor;\n }\n return i;\n};",
"howManyTimes(100, 2); // 2\nhowManyTimes(100, 2.5); // 2\nhowManyTimes(100, 0); // 0\nhowManyTimes(100, -1); // Infinity"
],
"tags": []
},
"meta": {
"archived": true,
"hash": "4c776a716fd3fd197ce7d6bf3f18e73e647f0363a8668b72cb980b53d355fe20"
"hash": "1f1d7def5d8b149626518181acb9f0e7fd0b44b31e5b42ce1e2f53e07eb01bc0"
}
},
{

File diff suppressed because it is too large Load Diff