@@ -15,6 +15,7 @@ public abstract class usacotools {
1515 public static ArrayList <Exception > console =new ArrayList <Exception >();
1616 public static String error ="Error" ;
1717 public static int debugcode =-1 ;
18+ public static boolean DEBUG =false ;
1819 public static boolean isrect (int [][] map ,int x ,int y ) {
1920 int cachedsize =-1 ;
2021 int cachey =-1 ;
@@ -135,6 +136,24 @@ public static int binarySearch(int arr[], int l, int r, int x)
135136
136137 return -1 ;
137138 }
139+ public static int [][] copy2D (int [][] a ){
140+ int [][] b =new int [a .length ][];
141+ for (int i =0 ;i <a .length ;i ++) {
142+ b [i ]=new int [a [i ].length ];
143+ for (int j =0 ;j <a [i ].length ;j ++) {
144+ b [i ][j ]=a [i ][j ];
145+ }
146+ }
147+ return b ;
148+ }
149+ public static int [] copyarr (int [] a ) {
150+ int [] b =new int [a .length ];
151+
152+ for (int i =0 ;i <a .length ;i ++) {
153+ b [i ]=a [i ];
154+ }
155+ return b ;
156+ }
138157 public static int ebs (int arr [], int l , int r , int x ) {
139158 Arrays .sort (arr );
140159 return binarySearch (arr , l , r , x );
@@ -256,7 +275,7 @@ public static int[][] rotate90cw(int[][] map) {
256275 * 90 degree clockwise
257276 */
258277 int N =map .length ;
259- int [][] n =new int [N ][N ];
278+ int [][] n =new int [map [ 0 ]. length ][N ];
260279 for (int i =0 ;i <N ;i ++) {
261280 for (int j =0 ;j <N ;j ++) {
262281 n [j ][N -1 -i ]=map [i ][j ];
@@ -339,26 +358,46 @@ public static void main(String[] args) throws Exception{
339358 print ("Welcome to the demo" );
340359 print (">" ,"" );
341360 int val ;
361+ /*
362+ int[][] testarray= {
363+ {1,1,2,7,7,1,1,1},
364+ {1,1,4,0,7,1,2,2},
365+ {0,3,6,9,1,0,0,0},
366+ {0,3,0,1,0,0,0,0},
367+ {0,3,0,0,0,0,0,0},
368+ {1,1,5,1,3,1,1,1},
369+ {1,1,1,1,3,1,1,1},
370+ };
371+ */
342372 int [][] testarray = {
343- {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
344- {1 ,1 ,1 ,0 ,0 ,1 ,1 ,2 },
345- {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
346- {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
347- {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
348- {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
349- {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
373+ {1 ,2 ,3 ,1 },
374+ {4 ,5 ,6 ,2 },
375+ {7 ,8 ,9 ,3 },
376+ {10 ,69 ,1 ,4 }
377+
350378 };
351- print ("Roation of 90 degrees\n Before \n \n \n \n " );
379+ print ("Roation of 90 degrees\n Before \n " );
352380 show2Darr (testarray );
353381 print ("After \n " );
354382 show2Darr (rotate90cw (testarray ));
383+ print ("BEFORE:" );
384+ int [][] ii = {
385+ {1 ,1 ,2 ,3 },
386+ {1 ,0 ,2 ,1 },
387+ {1 ,1 ,1 ,1 },
388+ {1 ,2 ,3 ,4 }
389+ };
390+ show2Darr (ii );
391+ print ("After H reflect:" );
392+ show2Darr (reverseh (ii ));
393+
355394 try {
356395 val =sc .nextInt ();
357396 }catch (Exception e ) {
358397 print ("Oops that did not go well please rerun and choose a INTEGER" );
359398 val =-1 ;
360399 report (e );
361- print ("How about we test erro reporting" );
400+ print ("How about we test error reporting" );
362401 console ();
363402 }
364403 if (1 ==val ) {
0 commit comments