Advertisement
Guest User

MMMMM jackobits

a guest
Feb 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.10 KB | None | 0 0
  1. public boolean isSuccessful(){
  2.         //Your code here
  3.         if (this.isReady()){
  4.              for (int i = 0; i< h; i++){
  5.                 for (int j = 0; j<w; j++){
  6.                     this.duplicate[i][j]= false;
  7.                 }
  8.              }
  9.              if (this.w == 2 && this.h == 2){
  10.                  if (this.duplicate[0][0] || this.duplicate[1][1]){
  11.                    this.duplicate[0][1] = !(this.duplicate[0][1]);
  12.                    this.duplicate[1][0] = !(this.duplicate[1][0]);
  13.                  }
  14.                  if (this.duplicate[0][1] || this.duplicate[1][0]){
  15.                    this.duplicate[0][0] = !(this.duplicate[0][0]);
  16.                    this.duplicate[1][1] = !(this.duplicate[1][1);
  17.                  }
  18.              }
  19.              else if (this.w = 2 && this.h == 1){
  20.                if (this.duplicate[0][0]){
  21.                  this.duplicate[0][1] = !(this.duplicate[0][1]);
  22.                }
  23.                if (this.duplicate[0][1]){
  24.                  this.duplicate[0][0] = !(this.duplicate[0][0]);
  25.                }
  26.              }
  27.              else if (this.w = 1 && this.h == 2){
  28.                if (this.duplicate[0][0]){
  29.                  this.duplicate[1][0] = !(this.duplicate[1][0]);
  30.                }
  31.                if (this.duplicate[1][0]){
  32.                  this.duplicate[0][0] = !(this.duplicate[0][0]);
  33.                }
  34.              }else if(this.w >= 2 && this.h >= 2){
  35.  
  36.             for (int i = 0; i< h; i++){
  37.                 for (int j = 0; j<w; j++){
  38.                     boolean left = true;
  39.                     boolean right = true;
  40.                     boolean up = true;
  41.                     boolean down = true;
  42.  
  43.                     if (this.sol[i][j] && (i==0 && j == 0) && (this.w == 1 && this.h == 1) ){
  44.                         return true;
  45.                     }
  46.                    
  47.                     /*
  48.                     if (i == h-1 && j == 0){
  49.                         left = false;
  50.                         down = false;
  51.  
  52.                     }
  53.                     if (i == 0 && j == w-1){
  54.                         right = false;
  55.                         up = false;
  56.                     }
  57.  
  58.                     if (i == h-1 && j == w-1){
  59.                         right = false;
  60.                         down = false;
  61.  
  62.                     }
  63.                     */
  64.  
  65.                     if (i == 0){
  66.                         up = false;
  67.  
  68.                     }
  69.  
  70.                     if (j == 0){
  71.                         left = false;
  72.  
  73.                     }
  74.  
  75.                     if (i == h-1){
  76.                         down = false;
  77.  
  78.                     }
  79.  
  80.                     if (j == w-1){
  81.                         right = false;
  82.  
  83.                     }
  84.  
  85.                     if (this.sol[i][j]){
  86.                         int adder = 0;
  87.                         this.duplicate[i][j] = !(this.duplicate[i][j]);
  88.                         adder++;
  89.  
  90.                         if (left){
  91.                             this.duplicate[i][j-1] = !(this.duplicate[i][j-1]);
  92.                             adder++;
  93.                         }
  94.  
  95.                         if (right){
  96.                             this.duplicate[i][j+1] = !(this.duplicate[i][j+1]);
  97.                             adder++;
  98.                         }
  99.  
  100.                         if (up){
  101.                             this.duplicate[i-1][j] = !(this.duplicate[i-1][j]);
  102.                             adder++;
  103.                         }
  104.  
  105.                         if (down){
  106.                             this.duplicate[i+1][j] = !(this.duplicate[i+1][j]);
  107.                             adder++;
  108.                         }
  109.                             count[i][j] = adder;
  110.  
  111.                     } //end of sol check
  112.                 }
  113.               }
  114.             }
  115.  
  116.         for (int i = 0; i< h; i++){
  117.                     for (int j = 0; j<w;j++){
  118.                         if (duplicate[i][j] == false){
  119.                             return false;
  120.                         }
  121.                     }
  122.               }
  123.         }
  124.  
  125.         else{
  126.             return false;
  127.         }
  128.         return true;
  129.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement