"No repeats please"

"No repeats please"
0

#1
function permFull(arr) {
    var permClosure = (function() {
        var arrInner = [
            []
        ];
        return function(elem) {
            var tmpArr = [];
            arrInner.forEach(function(item) {
                for (var i = 0; i <= item.length; ++i) {
                    var tmp = item.concat();
                    tmp.splice(i, 0, elem);
                    tmpArr.push(tmp);
                }
            });
            arrInner = tmpArr;
            return tmpArr;
        };
    })();

    var retArr = [];
    arr.forEach(function(elem) {
        retArr = permClosure(elem);
    });
    return retArr;
}

function permAlone(str) {
    var fullPerm = permFull(str.split(""));
    var cnt = 0;
    fullPerm.forEach(function(elem) {
        console.log(elem.join(""), /(.)\1/.test(elem.join("")));
        cnt += /(.)\1/.test(elem.join("")) ? 0 : 1;
    });
    return cnt;
}