// You are playing the following Flip Game with your friend:
// Given a string that contains only these two characters: + and -,
// you and your friend take turns to flip two consecutive "++" into "--".
// The game ends when a person can no longer make a move and therefore the other person will be the winner.

// Write a function to compute all possible states of the string after one valid move.

// For example, given s = "++++", after one move, it may become one of the following states:

// [
//   "--++",
//   "+--+",
//   "++--"
// ]
// If there is no valid move, return an empty list [].

var generatePossibleNextMoves = function(s) {
    var result = [];
    for( var i=0; i<s.length-1; i++ ){
        var string = s.split("");
        for( var j=i; j<s.length; j++ ){
            if( string[j] === '+' && string[j+1]=== '+' ){
                string[j] = '-';
                string[j+1] = '-';
                result.push( string.join("") );
                break;
            }
        }
    }
    result = uniq(result);
    return result;
};

function uniq(arr) {
    var seen = {},
        out = [],
        len = arr.length,
        j = 0;
    for(var i = 0; i < len; i++) {
         var item = arr[i];
         if(seen[item] !== 1) {
               seen[item] = 1;
               out[j++] = item;
         }
    }
    return out;
}

// --------------------------------------

var generatePossibleNextMoves = function(s) {
    var result = [],
        counter = 0,
        i=0;

    while( i<s.length-1){
        var current = check(i);
        if( current ) result.push( current );
        i++;
    }
    function check( index ){
        var string = s.slice().split("");
        for( var j=index; j<s.length; j++ ){
            if( string[j] === '+' && string[j+1]=== '+' ){
                counter++;
                string.splice.apply( string,[j,1].concat( '-'.split('') ) );
                string.splice.apply( string,[j+1,1].concat( '-'.split('') ) );
                return string.join("");
            }
        }
        return false;
    }
    result = result.filter(function(item, pos) {
        return result.indexOf(item) == pos;
    });
    return counter < 1 ? [] : result;
};


@@ -628,32 +628,49 @@
  = function(s) %7B
+ // 99 ms runtime
 %0A    var result 
@@ -717,42 +717,137 @@
 + )%7B
-%0A        var string = s.split(%22%22);
+ // only loop till 2nd last cuz of i+1 check in for loop%0A        var string = s.split(%22%22); // split str so we can relace by index
 %0A   
@@ -934,32 +934,68 @@
 g%5Bj+1%5D=== '+' )%7B
+ // check if + are next to eachother
 %0A               
@@ -1098,31 +1098,103 @@
 ) );
-%0A                break;
+ // join split string and push to result%0A                break; // stop loop if string is found
 %0A   
@@ -1246,16 +1246,42 @@
 result);
+ // remove uniq characters
 %0A    ret

add notees