Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. public void solve(){
  2.  
  3.         int n = field.length;
  4.         int h = (int)Math.pow(n,0.5);
  5.  
  6.         Cell [] tq = new Cell[n*n];
  7.         int o = 0;
  8.  
  9.         for(int l = 0; l < h; l++){
  10.             for(int j = 0; j < h; j++){
  11.  
  12.                 for(int m = 0; m < h; m++){
  13.                     for(int p = 0; p < h; p++) {
  14.                         tq[o] = field[l * h + m][j * h + p];
  15.                         o++;
  16.                     }
  17.                 }
  18.             }
  19.         }
  20.  
  21.         Cell [][] s = new Cell [n][n];
  22.         o = 0;
  23.  
  24.         for(int i = 0; i < n; i++){
  25.             for(int j = 0; j < n; j++){
  26.                 s[i][j] = tq [o];
  27.                 o++;
  28.             }
  29.         }
  30.  
  31.         Cell [][]field_t = new Cell [n][n];
  32.         for(int i = 0; i < n; i++){
  33.             for(int j = 0; j < n; j++){
  34.                 field_t[i][j] = field[j][i];
  35.             }
  36.         }
  37.  
  38.         /*
  39.             String q = "";
  40.  
  41.             for(Cell[] i: s){
  42.                 for(Cell j: i){
  43.                     q += j.getValue() + " ";
  44.                 }
  45.                 q += "\n";
  46.             }
  47.  
  48.             System.out.println(q);
  49.  
  50.             String e = "";
  51.  
  52.             for(Cell[] i: field){
  53.                 for(Cell j: i){
  54.                     e += j.getValue() + " ";
  55.                 }
  56.                 e += "\n";
  57.             }
  58.  
  59.             System.out.println(e);
  60.  
  61.             String w = "";
  62.  
  63.             for(Cell[] i: field_t){
  64.                 for(Cell j: i){
  65.                     w += j.getValue() + " ";
  66.                 }
  67.                 w += "\n";
  68.             }
  69.             System.out.println(w);
  70.         */
  71.  
  72.         boolean x = true,y = true,z = true;
  73.  
  74.         while(x || y || z) {
  75.             for (int i = 0; i < n; i++) {
  76.                 x = update(field[i]);
  77.                 y = update(field_t[i]);
  78.                 z = update(s[i]);
  79.             }
  80.         }
  81.  
  82.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement