Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Uncategorized category for Follow Instructions by vvm70
import assert from "assert";
function follow(instr) {
return [eval(instr.replace(/[r]/g, '1').replace(/[l]/g, '-1')
.replace(/[fb]/g, '0').split('').join('+')),
eval(instr.replace(/[f]/g, '1').replace(/[b]/g, '-1')
.replace(/[lr]/g, '0').split('').join('+'))];
}
console.log('Example:');
console.log(follow('fflff'));
// These "asserts" are used for self-checking
assert.deepEqual(follow('fflff'), [-1, 4]);
assert.deepEqual(follow('ffrff'), [1, 4]);
assert.deepEqual(follow('fblr'), [0, 0]);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
Jan. 6, 2021