Untitled
unknown
javascript
a year ago
369 B
7
Indexable
function isValidWalk(walk) { const score = walk.reduce((acc, step) => { if (step === 'n') acc.upDown += 1; if (step === 's') acc.upDown -= 1; if (step === 'e') acc.leftRight += 1; if (step === 'w') acc.leftRight -= 1; return acc }, { upDown: 0, leftRight: 0 }) return score.upDown === 0 && score.leftRight === 0 && walk.length === 10 }
Editor is loading...
Leave a Comment