Open
Description
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()));
Metadata
Metadata
Assignees
Labels
No labels