Created
November 12, 2017 19:15
-
-
Save ldco2016/13fce0c5fc31b98819bb32e96d7c44c3 to your computer and use it in GitHub Desktop.
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 main() { | |
var S = readLine(); | |
const expectedSignal = 'SOS'; | |
let errorCount = 0; | |
for (i = 0, len = S.length; i <len; i += 3) { | |
const currentSignal = S.slice(i, i + 3); | |
if (currentSignal === expectedSignal) continue; | |
if (currentSignal[0] !== expectedSignal[0]) errorCount += 1; | |
if (currentSignal[1] !== expectedSignal[1]) errorCount += 1; | |
if (currentSignal[2] !== expectedSignal[2]) errorCount += 1; | |
} | |
console.log(errorCount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment