Created
February 2, 2018 20:17
-
-
Save LionRoar/3f744ab908a37562cea0799667f6f3a3 to your computer and use it in GitHub Desktop.
NoRepeatsPlease Inclusion_Exclusiond
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
//factorial | |
function f(number){ | |
let $ = 1 , _ = 1; | |
while($<=number){ | |
_*=$; | |
$++; | |
} | |
return _; | |
} |
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
function getRepeatedLetters(str){ | |
let reg = /([a-zA-Z]).*(\1)/gm; | |
let repeats = {}; | |
for(let x =0 ; x<str.length;x++){ | |
var l = str.charAt(x); | |
repeats[l] = (isNaN(repeats[l]) ? 1 : repeats[l] + 1); | |
} | |
let reTotal = 0; | |
for(let k in repeats){ | |
if(repeats[k]<=1) | |
delete repeats[k]; | |
else reTotal+=repeats[k]; | |
} | |
return { | |
repeats, | |
length:Object.keys(repeats).length, | |
totalRepeated:reTotal | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment