Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear&Readable solution in Clear category for [old] Compass, Map and Spyglass by SaintDron
"use strict";
function navigation(seaside) {
const distToY = (coord) => Math.max(Math.abs(coord[0] - coords.Y[0]), Math.abs(coord[1] - coords.Y[1]));
let coords = {};
seaside.forEach((row, r) => {
row.forEach((v, c) => {
if (v) coords[v] = [r, c];
});
});
return distToY(coords.C) + distToY(coords.M) + distToY(coords.S);
}
var assert = require('assert');
if (!global.is_checking) {
console.log('Example:')
console.log(navigation([['Y', 0, 0, 0, 'C'],
[ 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0],
['M', 0, 0, 0, 'S']]))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(navigation([['Y', 0, 0, 0, 'C'],
[ 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0],
['M', 0, 0, 0, 'S']]), 11)
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
Sept. 5, 2018
Comments: