Last active
March 26, 2018 17:47
-
-
Save jonopens/99cd13064477844a0be2e6a8af85f8db to your computer and use it in GitHub Desktop.
Codility Challenge for EPAM: review
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 solution(S) { | |
let total = 0; | |
for(var i = 0; i < S.length; i++){ | |
for(var c = S.length; c > i; c--){ | |
total += uniScore(S.slice(i, c)) | |
} | |
} | |
return total | |
} | |
function uniScore(string){ | |
let score = 0; | |
for(var i = 0; i < string.length; i++){ | |
let count = 0 | |
for(var c = 0; c < string.length; c++){ | |
if(string[i] === string[c]){ | |
count++ | |
} | |
} | |
if(count === 1){ | |
score++ | |
} | |
} | |
return score; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changes: