You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function ChessboardTraveling(str) {
const splittedString = str.split('')
const x = Number(splittedString[1]), y = Number(splittedString[3])
const a = Number(splittedString[6]), b = Number(splittedString[8])
const rightPath = a - x, upPath = b - y
const totalPath = rightPath + upPath
const totalStepPermutation = travel(totalPath)
const upPathPermutation = travel(upPath)
const rightPathPermutation = travel(rightPath)
const possibleSteps = Number(totalStepPermutation / (upPathPermutation * rightPathPermutation))
return possibleSteps;
}
const travel = (num) =>{
let result = 1
for (let i = 1; i<num+1; i++) {
result = result * i
}
return result
}
// keep this function call here
console.log(ChessboardTraveling(readline()));
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: