<awangdev>Flip Game II_5.java
public static boolean checkP1Win(String str, int x, boolean isP1) {
        String s = str.substring(0,x) + "--" + str.substring(x + 2);
        if (s.indexOf("++") == -1) {
            return isP1;
        } 
        if (isP1) {
        	String temp = s;
		    for (int i = temp.indexOf("++"); i >= 0 && i < temp.length() - 1; i = temp.indexOf("++")) {
		        if (checkP1Win(s, i, !isP1)) {
		            return true;
		        }
		        temp = temp.substring(0, i) + "-" + temp.substring(i + 1);
		    } 
		    return false;
	    } else {
	    	String temp = s;
	    	for (int i = temp.indexOf("++"); i >= 0 && i < temp.length() - 1; i = temp.indexOf("++")) {
		        if (!checkP1Win(s, i, !isP1)) {
		            return false;
		        }
		        temp = temp.substring(0, i) + "-" + temp.substring(i + 1);
		    } 
		    return true;
	    }
    }
public static boolean sample_funcname ( String str , int x , boolean isP1 ) {
  String s = str . substring ( 0 , x ) + "--" + str . substring ( x + 2 ) ;
  if ( s . indexOf ( "++" ) == - 1 ) {
    return isP1 ;
  }
  if ( isP1 ) {
    String temp = s ;
    for ( int i = temp . indexOf ( "++" ) ;
    i >= 0 && i < temp . length ( ) - 1 ;
    i = temp . indexOf ( "++" ) ) {
      if ( checkP1Win ( s , i , ! isP1 ) ) {
        return true ;
      }
      temp = temp . substring ( 0 , i ) + "-" + temp . substring ( i + 1 ) ;
    }
    return false ;
  }
  else {
    String temp = s ;
    for ( int i = temp . indexOf ( "++" ) ;
    i >= 0 && i < temp . length ( ) - 1 ;
    i = temp . indexOf ( "++" ) ) {
      if ( ! checkP1Win ( s , i , ! isP1 ) ) {
        return false ;
      }
      temp = temp . substring ( 0 , i ) + "-" + temp . substring ( i + 1 ) ;
    }
    return true ;
  }
}
