Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean isSuccessful(){
- //Your code here
- if (this.isReady()){
- for (int i = 0; i< h; i++){
- for (int j = 0; j<w; j++){
- this.duplicate[i][j]= false;
- }
- }
- if (this.w == 2 && this.h == 2){
- if (this.duplicate[0][0] || this.duplicate[1][1]){
- this.duplicate[0][1] = !(this.duplicate[0][1]);
- this.duplicate[1][0] = !(this.duplicate[1][0]);
- }
- if (this.duplicate[0][1] || this.duplicate[1][0]){
- this.duplicate[0][0] = !(this.duplicate[0][0]);
- this.duplicate[1][1] = !(this.duplicate[1][1);
- }
- }
- else if (this.w = 2 && this.h == 1){
- if (this.duplicate[0][0]){
- this.duplicate[0][1] = !(this.duplicate[0][1]);
- }
- if (this.duplicate[0][1]){
- this.duplicate[0][0] = !(this.duplicate[0][0]);
- }
- }
- else if (this.w = 1 && this.h == 2){
- if (this.duplicate[0][0]){
- this.duplicate[1][0] = !(this.duplicate[1][0]);
- }
- if (this.duplicate[1][0]){
- this.duplicate[0][0] = !(this.duplicate[0][0]);
- }
- }else if(this.w >= 2 && this.h >= 2){
- for (int i = 0; i< h; i++){
- for (int j = 0; j<w; j++){
- boolean left = true;
- boolean right = true;
- boolean up = true;
- boolean down = true;
- if (this.sol[i][j] && (i==0 && j == 0) && (this.w == 1 && this.h == 1) ){
- return true;
- }
- /*
- if (i == h-1 && j == 0){
- left = false;
- down = false;
- }
- if (i == 0 && j == w-1){
- right = false;
- up = false;
- }
- if (i == h-1 && j == w-1){
- right = false;
- down = false;
- }
- */
- if (i == 0){
- up = false;
- }
- if (j == 0){
- left = false;
- }
- if (i == h-1){
- down = false;
- }
- if (j == w-1){
- right = false;
- }
- if (this.sol[i][j]){
- int adder = 0;
- this.duplicate[i][j] = !(this.duplicate[i][j]);
- adder++;
- if (left){
- this.duplicate[i][j-1] = !(this.duplicate[i][j-1]);
- adder++;
- }
- if (right){
- this.duplicate[i][j+1] = !(this.duplicate[i][j+1]);
- adder++;
- }
- if (up){
- this.duplicate[i-1][j] = !(this.duplicate[i-1][j]);
- adder++;
- }
- if (down){
- this.duplicate[i+1][j] = !(this.duplicate[i+1][j]);
- adder++;
- }
- count[i][j] = adder;
- } //end of sol check
- }
- }
- }
- for (int i = 0; i< h; i++){
- for (int j = 0; j<w;j++){
- if (duplicate[i][j] == false){
- return false;
- }
- }
- }
- }
- else{
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement