Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void solve(){
- int n = field.length;
- int h = (int)Math.pow(n,0.5);
- Cell [] tq = new Cell[n*n];
- int o = 0;
- for(int l = 0; l < h; l++){
- for(int j = 0; j < h; j++){
- for(int m = 0; m < h; m++){
- for(int p = 0; p < h; p++) {
- tq[o] = field[l * h + m][j * h + p];
- o++;
- }
- }
- }
- }
- Cell [][] s = new Cell [n][n];
- o = 0;
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- s[i][j] = tq [o];
- o++;
- }
- }
- Cell [][]field_t = new Cell [n][n];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n; j++){
- field_t[i][j] = field[j][i];
- }
- }
- /*
- String q = "";
- for(Cell[] i: s){
- for(Cell j: i){
- q += j.getValue() + " ";
- }
- q += "\n";
- }
- System.out.println(q);
- String e = "";
- for(Cell[] i: field){
- for(Cell j: i){
- e += j.getValue() + " ";
- }
- e += "\n";
- }
- System.out.println(e);
- String w = "";
- for(Cell[] i: field_t){
- for(Cell j: i){
- w += j.getValue() + " ";
- }
- w += "\n";
- }
- System.out.println(w);
- */
- boolean x = true,y = true,z = true;
- while(x || y || z) {
- for (int i = 0; i < n; i++) {
- x = update(field[i]);
- y = update(field_t[i]);
- z = update(s[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement