Balanced brackets: Difference between revisions

Line 2,761:
return errorIndex(strBrackets.split(''), 0, 0);
}
}
}
// GENERIC
 
Line 2,774 ⟶ 2,775:
 
// TESTING AND FORMATTING OUTPUT
 
// nreps :: String -> Int -> String
function nreps(s, n) {
var o = '';
if (n < 1) return o;
while (n > 1) {
if (n & 1) o += s;
n >>= 1;
s += s;
}
return o + s;
}
 
var lngPairs = 6,
strPad = nrepsArray(' ', lngPairs * 2 + 34).join(' ');
 
return range(0, lngPairs)
Line 2,799 ⟶ 2,788:
return "'" + s + "'" + strPad.slice(w + 2) +
(blnOK ? 'OK' : 'problem') +
(blnOK ? '' : '\n' + nrepsArray(' ', i + 12).join(' ') + '^');
})
.join('\n');
})();</lang>
</lang>
 
Sample output:
9,659

edits