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
/** | |
* Checks if one set is a super set of another set. | |
* | |
* @param {Array} a - The first set. | |
* @param {Array} b - The second set. | |
* @return {boolean} Returns true if the first set is a super set of the second set, otherwise returns false. | |
*/ | |
function superSet(a, b) { | |
const sA = new Set(a) | |
const sB = new Set(b) |
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
CREATE FUNCTION replaceAccentChar (@source as varchar(255)) | |
RETURNS varchar(255) AS | |
BEGIN | |
declare @charList as varchar(20) | |
declare @temp as varchar(255) | |
declare @t asint | |
set @temp = @source | |
set @charList = 'aeioucn' |
ʘ‿ʘ | (`·ω·´) | ( ͡° ͜ʖ ͡°) |
Innocent face | feel perky | 4chan emoticon |
ಠ_ಠ | (╬ ಠ益ಠ) | ಥ_ಥ |
Reddit disapproval face | angry face | crying face |
(╯°□°)╯︵ ┻━┻ | ☜(⌒▽⌒)☞ | ᕙ(⇀‸↼‶)ᕗ |
Table Flip / Flipping Table | excited | flexing |
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
/** | |
* Calculates the standard deviation of an array of numbers. | |
* | |
* @param {Array} arr - The array of numbers. | |
* @param {Boolean} usePopulation - Optional. If true, the function uses the population standard deviation formula. Default is false, which uses the sample standard deviation formula. | |
* @return {Number} - The standard deviation of the array. | |
*/ | |
const standardDeviation = (arr, usePopulation = false) => { | |
const n = arr.length | |
let sum = 0 |
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
// Changed the loop to start from the end of the word string and iterate backwards. | |
// This allows us to avoid unnecessary slicing operations. | |
//Used substring instead of slice since we only need to get the substring starting from i to the end. | |
/** | |
* Finds the longest substring of the word that is a prefix of the text. | |
* | |
* @param {string} text - The text to search for the substring. | |
* @param {string} word - The word to find the substring from. | |
* @return {string|undefined} The longest substring that is a prefix of the text, or undefined if no such substring exists. |
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
// Replaced the split method with the match method, which uses a regular expression to split the string into an array of words. | |
// Also removed the filter(Boolean) call since the match method already returns an array with only the matched words. | |
/** | |
* Returns an array of all words in a given string that match a given pattern. | |
* | |
* @param {string} str - The input string to search for words. | |
* @param {RegExp} pattern - The pattern to match words against. Defaults to /[a-zA-Z-]+/g. | |
* @return {Array} - An array of words that match the given pattern. | |
*/ |
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 given number to a Roman numeral representation. | |
* | |
* @param {number} num - The number to be converted. | |
* @return {string} The Roman numeral representation of the given number. | |
*/ | |
function toRomanNumeral(num) { | |
const lookup = new Map([ | |
[1000, "M"], | |
[900, "CM"], |
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
/** | |
* Calculates the distance between two vectors. | |
* | |
* @param {Array} x - The first vector. | |
* @param {Array} y - The second vector. | |
* @return {number} The distance between the two vectors. | |
*/ | |
function vectorDistance(x, y) { | |
return Math.sqrt(x.reduce((acc, val, i) => acc + (val - y[i]) ** 2, 0)) | |
} |