Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 4e9ad02

Browse files
authored
Add files via upload
1 parent dde52ec commit 4e9ad02

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

usacotools.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,38 @@ public static boolean isrect(int[][] map,int x,int y) {
3434
}
3535
return true;
3636
}
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+
}
3769
public static void report(Exception e) {
3870
console.add(e);
3971
ERRORS++;
@@ -232,6 +264,32 @@ public static int[][] rotate90cw(int[][] map) {
232264
}
233265
return n;
234266
}
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+
235293
public static void main(String[] args) throws Exception{
236294
/*
237295
* Short demo of stuff

0 commit comments

Comments
 (0)