Last active
November 1, 2019 16:53
-
-
Save adamatti/8add6be656f1d6e99a1d44064e9a7860 to your computer and use it in GitHub Desktop.
Resultado DOJO de node - 20/04/2017 #dojo
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
const assert = require('assert') | |
it ("primeiro caso - R2", () => { | |
assert.equal ( pula('R2') , 2 ) | |
}) | |
it ("segundo caso - R3", () => { | |
assert.equal ( pula('R3') , 3 ) | |
}) | |
it ("caso - dois pulos R3 R4", () => { | |
assert.equal ( pula('R3, R4') , 7 ) | |
}) | |
it ("caso - tres pulos direita R2 R2 R2", () => { | |
assert.equal ( pula('R2, R2, R2') , 2 ) | |
}) | |
function pula(comandos){ | |
var comando = comandos.split(',') | |
var x = 0 | |
var y = 0 | |
var distanciaFinal = 0 | |
for(var i = 0; i < comando.length; i++) { | |
distanciaFinal += parseInt(comando[i].trim().substr(1)) | |
} | |
return distanciaFinal | |
} | |
function identificaDirecao (direcao) { | |
if(direcao == "R") { | |
} else { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment