Skip to content

Instantly share code, notes, and snippets.

@le0m
le0m / gist:971d068eb0d7e56b842248d7c69ef141
Last active October 12, 2018 03:35
Programmin Challenges - October 2018
const CorrectPath = (str) => {
const size = 5;
let chars = str.split('');
let dir = { l: -1, r: 1, u: -1, d: 1 };
let pos = chars.reduce((acc, char) => {
if (['l', 'r'].indexOf(char) !== -1) { acc.x += dir[char]; }
else if (['u', 'd'].indexOf(char) !== -1) { acc.y += dir[char]; }
return acc;