@@ -34,6 +34,38 @@ public static boolean isrect(int[][] map,int x,int y) {
34
34
}
35
35
return true ;
36
36
}
37
+ public static Set <String > sclones (Set <String > k ) {
38
+ return (new HashSet <String >(k ));
39
+ }
40
+ public static Set <Integer > sclone (Set <Integer > k ) {
41
+
42
+ return (new HashSet <Integer >(k ));
43
+ }
44
+ public static Set <Long > sclonel (Set <Long > k ) {
45
+ return (new HashSet <Long >(k ));
46
+ }
47
+ public static boolean smartequals (int [] a ,int [] b ) {
48
+ if (a .length !=b .length ) {
49
+ return false ;
50
+ }
51
+ for (int i =0 ;i <a .length ;i ++) {
52
+ if (a [i ]!=b [i ]) {
53
+ return false ;
54
+ }
55
+ }
56
+ return true ;
57
+ }
58
+ public static boolean smartequals2D (int [][] a ,int [][] b ) {
59
+ if (a .length !=b .length ) {
60
+ return false ;
61
+ }
62
+ for (int i =0 ;i <a .length ;i ++) {
63
+ if (smartequals (a [i ],b [i ])) {
64
+ return false ;
65
+ }
66
+ }
67
+ return true ;
68
+ }
37
69
public static void report (Exception e ) {
38
70
console .add (e );
39
71
ERRORS ++;
@@ -232,6 +264,32 @@ public static int[][] rotate90cw(int[][] map) {
232
264
}
233
265
return n ;
234
266
}
267
+ public static int [][] morph (int [][] map ,int a ,int b ){
268
+ for (int i =0 ;i <map .length ;i ++) {
269
+ for (int j =0 ;j <map [i ].length ;j ++) {
270
+ if (map [i ][j ]==a ) {
271
+ map [i ][j ]=b ;
272
+ }
273
+ }
274
+ }
275
+ return map ;
276
+ }
277
+ public static int classify (char x ,char off ,char on ) {
278
+ /*
279
+ * Method to classify X is off value or on value
280
+ * Returns -1 if neither
281
+ *
282
+ */
283
+ if (x ==off ){
284
+ return 0 ;
285
+ }else if (x ==on ) {
286
+ return 1 ;
287
+ }else {
288
+ return -1 ;
289
+ }
290
+
291
+ }
292
+
235
293
public static void main (String [] args ) throws Exception {
236
294
/*
237
295
* Short demo of stuff
0 commit comments