<awangdev>Flip Game II_4.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;
        } 
	    for (int i = s.indexOf("++"); i >= 0 && i < s.length() - 1; i = s.indexOf("++")) {
	        if (checkP1Win(s, i, !isP1)) {
	            return true;
	        }
	        s = s.substring(0, i) + "-" + s.substring(i + 1);
	    } 
	    return false;
    }
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 ;
  }
  for ( int i = s . indexOf ( "++" ) ;
  i >= 0 && i < s . length ( ) - 1 ;
  i = s . indexOf ( "++" ) ) {
    if ( checkP1Win ( s , i , ! isP1 ) ) {
      return true ;
    }
    s = s . substring ( 0 , i ) + "-" + s . substring ( i + 1 ) ;
  }
  return false ;
}
