Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Pawn Brotherhood by Sim0000
"use strict";
function safePawns(data) {
count = 0
for(pawn of data){
pawn_left = String.fromCharCode(pawn.charCodeAt(0) - 1, pawn.charCodeAt(1) - 1)
pawn_right = String.fromCharCode(pawn.charCodeAt(0) + 1, pawn.charCodeAt(1) - 1)
if(data.indexOf(pawn_left) >= 0 || data.indexOf(pawn_right) >= 0) count++
}
return count
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(safePawns(["b4", "d4", "f4", "c3", "e3", "g5", "d2"]), 6, "First");
assert.equal(safePawns(["b4", "c4", "d4", "e4", "f4", "g4", "e5"]), 1, "Second");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
July 7, 2016
Comments: