Untitled
unknown
javascript
a year ago
460 B
5
Indexable
function isValidWalk(walk) { const limit = 10 const score = { upDown: 0, leftRight: 0 } walk.forEach((step) => { if (step === 'n') { score.upDown += 1 } if (step === 's') { score.upDown -= 1 } if (step === 'e') { score.leftRight += 1 } if (step === 'w') { score.leftRight -= 1 } }) return score.upDown === 0 && score.leftRight === 0 && (walk.length / 4) < 10 }
Editor is loading...
Leave a Comment