Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear&Readable solution in Clear category for [old] The Stone Wall by SaintDron
"use strict";
function stoneWall(wall) {
wall = wall.trim().split('\n').map(row => [...row]); // parse
wall = wall[0].map((_, c) => wall.map(row => row[c]) // transpose
.filter(v => v === '#').length);
return wall.indexOf( Math.min(...wall) );
}
var assert = require('assert');
if (!global.is_checking) {
console.log('Example:')
console.log(stoneWall(`
##########
####0##0##
00##0###00
`))
// These "asserts" are used for self-checking and not for an auto-testing
assert.equal(stoneWall(`
##########
####0##0##
00##0###00
`), 4)
assert.equal(stone_wall(`
#00#######
#######0##
00######00
`), 1)
assert.equal(stone_wall(`
#####
#####
#####
`), 0)
console.log("Coding complete? Click 'Check' to earn cool rewards!");
}
Sept. 7, 2018
Comments: