From 4e9ad0283b07396508d72186af9bd7406ac9e27e Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Mon, 7 May 2018 19:53:44 -0700 Subject: [PATCH 01/23] Add files via upload --- usacotools.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/usacotools.java b/usacotools.java index 2edc111..c44c11a 100644 --- a/usacotools.java +++ b/usacotools.java @@ -34,6 +34,38 @@ public static boolean isrect(int[][] map,int x,int y) { } return true; } + public static Set sclones(Set k) { + return (new HashSet(k)); + } + public static Set sclone(Set k) { + + return (new HashSet(k)); + } + public static Set sclonel(Set k) { + return (new HashSet(k)); + } + public static boolean smartequals(int[] a,int[] b) { + if(a.length!=b.length) { + return false; + } + for(int i=0;i Date: Sun, 13 May 2018 12:48:49 -0700 Subject: [PATCH 02/23] Update usacotools.java --- usacotools.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/usacotools.java b/usacotools.java index c44c11a..33876ea 100644 --- a/usacotools.java +++ b/usacotools.java @@ -289,7 +289,29 @@ public static int classify(char x,char off,char on) { } } - + public static long slowfib(long num){ + if(num<=1) { + return num; + } + + return slowfib(num-1)+slowfib(num-2); + } + public static ArrayList fibmem=new ArrayList(); + public static long ffib(long n){ + if(n<=1) { + return n; + } + + if(fibmem.size()>n) { + return fibmem.get((int) n-1)+fibmem.get((int) n-2); + }else { + fibmem.add(ffib(n-1)+ffib(n-2)); + return fibmem.get((int) n); + } + } + public static void setupfib() { + fibmem.add((long) 0);fibmem.add((long)1);fibmem.add((long)1);fibmem.add((long)2); + } public static void main(String[] args) throws Exception{ /* * Short demo of stuff From ebcb81345ad33aa8fe608178552f70d514b3090c Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 13 May 2018 13:02:44 -0700 Subject: [PATCH 03/23] Add files via upload --- usacotools.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usacotools.java b/usacotools.java index 33876ea..8b05817 100644 --- a/usacotools.java +++ b/usacotools.java @@ -321,7 +321,7 @@ public static void main(String[] args) throws Exception{ */ System.out.println("Running demo"); Scanner sc=getsysscan(); - print("Welcome to the demo\nYou have many choices \n1} Run help \n2} Check for a update \n3}Run demo to see features"); + print("Welcome to the demo\nYou have many choices \n1} Run help \n \n2}Run demo to see features"); print(">",""); int val; try { From 31f7fe9e2552baa551e9adb5696a20d5e7b30992 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 13 May 2018 13:04:25 -0700 Subject: [PATCH 04/23] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 526e9b1..d9b5a39 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# Java \ No newline at end of file +# Java +DON'T use download +USE RELEASES From c599626f36b9c58cdec307edb1e508acec3274e5 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Mon, 14 May 2018 19:46:15 -0700 Subject: [PATCH 05/23] Update usacotools.java --- usacotools.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usacotools.java b/usacotools.java index 8b05817..7c6050c 100644 --- a/usacotools.java +++ b/usacotools.java @@ -227,9 +227,9 @@ public static int[] reverse(int[] a) { } return a; } - public static int[][] reverseh(int[][] a) { + public static int[][] reversev(int[][] a) { /* - * Reverse 2D array horizontal + * Reverse 2D array */ int[] temp; for(int i = 0; i < a.length / 2; i++) @@ -240,9 +240,9 @@ public static int[][] reverseh(int[][] a) { } return a; } - public static int[][] reversev(int[][] a) { + public static int[][] reverseh(int[][] a) { /* - * Reverse 2D array vertically + * Reverse 2D array */ int[][] newa=new int[a.length][a[0].length]; for(int i=0;i Date: Mon, 14 May 2018 19:57:56 -0700 Subject: [PATCH 06/23] Add files via upload --- usacotools.java | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/usacotools.java b/usacotools.java index 7c6050c..1748451 100644 --- a/usacotools.java +++ b/usacotools.java @@ -309,8 +309,23 @@ public static long ffib(long n){ return fibmem.get((int) n); } } + public static void print() { + System.out.println(); + } public static void setupfib() { fibmem.add((long) 0);fibmem.add((long)1);fibmem.add((long)1);fibmem.add((long)2); + } + public static void show2Darr(int[][] a) { + for(int[] b:a) { + for(int c:b) { + print(c+" ",""); + } + print(); + + } + } + public static void showarr(int[] a) { + for(int x:a) {print(x+" ");} } public static void main(String[] args) throws Exception{ /* @@ -321,9 +336,22 @@ public static void main(String[] args) throws Exception{ */ System.out.println("Running demo"); Scanner sc=getsysscan(); - print("Welcome to the demo\nYou have many choices \n1} Run help \n \n2}Run demo to see features"); + print("Welcome to the demo"); print(">",""); int val; + int[][] testarray= { + {1,1,1,1,1,1,1,1}, + {1,1,1,0,0,1,1,2}, + {0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0}, + {1,1,1,1,1,1,1,1}, + {1,1,1,1,1,1,1,1}, + }; + print("Roation of 90 degrees\n Before \n\n\n\n"); + show2Darr(testarray); + print("After \n"); + show2Darr(rotate90cw(testarray)); try { val=sc.nextInt(); }catch(Exception e) { From 496239974ffb2e69b0db0c08c99eb29e9bcea6da Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Wed, 16 May 2018 19:59:32 -0700 Subject: [PATCH 07/23] Add files via upload --- usacotools.java | 59 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/usacotools.java b/usacotools.java index 1748451..91e84f7 100644 --- a/usacotools.java +++ b/usacotools.java @@ -15,6 +15,7 @@ public abstract class usacotools { public static ArrayList console=new ArrayList(); public static String error="Error"; public static int debugcode=-1; + public static boolean DEBUG=false; public static boolean isrect(int[][] map,int x,int y) { int cachedsize=-1; int cachey=-1; @@ -135,6 +136,24 @@ public static int binarySearch(int arr[], int l, int r, int x) return -1; } + public static int[][] copy2D(int[][] a){ + int[][] b=new int[a.length][]; + for(int i=0;i",""); int val; + /* + int[][] testarray= { + {1,1,2,7,7,1,1,1}, + {1,1,4,0,7,1,2,2}, + {0,3,6,9,1,0,0,0}, + {0,3,0,1,0,0,0,0}, + {0,3,0,0,0,0,0,0}, + {1,1,5,1,3,1,1,1}, + {1,1,1,1,3,1,1,1}, + }; + */ int[][] testarray= { - {1,1,1,1,1,1,1,1}, - {1,1,1,0,0,1,1,2}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {0,0,0,0,0,0,0,0}, - {1,1,1,1,1,1,1,1}, - {1,1,1,1,1,1,1,1}, + {1,2,3,1}, + {4,5,6,2}, + {7,8,9,3}, + {10,69,1,4} + }; - print("Roation of 90 degrees\n Before \n\n\n\n"); + print("Roation of 90 degrees\n Before \n "); show2Darr(testarray); print("After \n"); show2Darr(rotate90cw(testarray)); + print("BEFORE:"); + int[][] ii= { + {1,1,2,3}, + {1,0,2,1}, + {1,1,1,1}, + {1,2,3,4} + }; + show2Darr(ii); + print("After H reflect:"); + show2Darr(reverseh(ii)); + try { val=sc.nextInt(); }catch(Exception e) { print("Oops that did not go well please rerun and choose a INTEGER"); val=-1; report(e); - print("How about we test erro reporting"); + print("How about we test error reporting"); console(); } if(1==val) { From d6e6ae275863b54c1f6c57ed9da6c9962060ec73 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 20 May 2018 12:46:22 -0700 Subject: [PATCH 08/23] Update usacotools.java --- usacotools.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/usacotools.java b/usacotools.java index 91e84f7..95548ad 100644 --- a/usacotools.java +++ b/usacotools.java @@ -346,6 +346,26 @@ public static void show2Darr(int[][] a) { public static void showarr(int[] a) { for(int x:a) {print(x+" ");} } + public static int[][] dpcache; + public static int ks(int W,int[] wt,int[] val,int n) { + int result; + if(dpcache[n][W]!=0) {return dpcache[n][W];} + if(n==0||W==0) { + result=0; + }else if(wt[n-1]>W) { + result=ks(W,wt,val,n-1); + + + + }else { + result=Math.max(val[n-1]+ks(W-wt[n-1],wt,val,n-1),ks(W,wt,val,n-1)); + } + dpcache[n][W]=result; + return result; + } + public static void kssetup(int n,int W) { + dpcache=new int[n+1][W+1]; + } public static void main(String[] args) throws Exception{ /* * Short demo of stuff From c9bfe358b3abbf12fffe117be0f8d65e5e83f150 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Wed, 20 Jun 2018 22:49:44 -0700 Subject: [PATCH 09/23] Add files via upload --- debuggableapp.java | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 debuggableapp.java diff --git a/debuggableapp.java b/debuggableapp.java new file mode 100644 index 0000000..1431b80 --- /dev/null +++ b/debuggableapp.java @@ -0,0 +1,70 @@ +import java.io.*; +import java.util.*; +class Var { + private Object object; + public Var() { + this.object=null; + } + public Var(Object o) { + this.object=o; + } + public void set(Object object) { this.object = object; } + public Object get() { return object; } +} +public class debuggableapp { + public static PrintWriter debug; + public static HashMap db=new HashMap(); + public static void setup() { + try { + debug=new PrintWriter(new BufferedWriter(new FileWriter("programdebug.info"))); + }catch(Exception e) { + e.printStackTrace(); + System.out.println("WARNING:Log file cannot be initliazed, redirecting to stdout! This may be a restrcited system!"); + debug=new PrintWriter(System.out); + + } + debug.println("Setup completed"); + } + public static void session() { + debug.println("Session started"); + System.out.println("Debug 1.0 Session\nPress enter to stop\nWarning timing this program will be messed up!"); + String text=">"; + Scanner sc=new Scanner(System.in); + while(!(text.equals(""))) { + System.out.print(">"); + text=sc.nextLine(); + if(db.containsKey(text)) { + show(db.get(text)); + } + } + } + public static void show(Var x) { + debug.println(x.getClass()); + if(x.getClass().getName().contains((CharSequence) "List")) { + System.out.println("WARNING this is a list"); + debug.println("WARNING this is a list"); + } + System.out.println(x.get()); + } + public static void add(Var x,String friendlyname) { + db.put(friendlyname, x); + } + public static void set(Var x,String friendlyname) { + db.put(friendlyname, x); + + + + } + public static void main(String[] args) { + setup(); + String x="test"; + Var a=new Var("Testing"); + add(a,x); + session(); + a.set("sync test"); + Var a2=new Var(new ArrayList()); + add(a2,"arr"); + session(); + } + +} From c9749917c4667f7ed505945b7e63f7cbe0440690 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 22 Jul 2018 14:47:21 -0700 Subject: [PATCH 10/23] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d9b5a39..9dd9fef 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Java -DON'T use download -USE RELEASES +Useful library for usaco and other purposes. +. Use releases when possible otherwise download usacotools.java. From 14af3c5ca6895f619f688d89969d681c15c41a9e Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 22 Jul 2018 14:52:19 -0700 Subject: [PATCH 11/23] Create index.html --- index.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..92424de --- /dev/null +++ b/index.html @@ -0,0 +1,2 @@ +

Next update release

+

Should be at 8/1/2018

From 445bcdc8b54ca7806c0bed6d30b333c2153e68e5 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 5 Aug 2018 13:39:59 -0700 Subject: [PATCH 12/23] Set theme jekyll-theme-slate --- _config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c741881 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-slate \ No newline at end of file From 8cb0d1d4ec5f460c6125b43bcdc56c42fd0310e7 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 5 Aug 2018 13:41:02 -0700 Subject: [PATCH 13/23] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9dd9fef..f479297 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Java Useful library for usaco and other purposes. . Use releases when possible otherwise download usacotools.java. +# Release dates and more +Find release dates at https://javaarchive.github.io/Java/ From c63730c4ff011de89a50f87396bc4daacfaf661f Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 5 Aug 2018 14:28:15 -0700 Subject: [PATCH 14/23] Add files via upload --- compilestandard.java | 28 +++++++++++ usacotools.java | 109 ++++++++++++++++++++++--------------------- 2 files changed, 83 insertions(+), 54 deletions(-) create mode 100644 compilestandard.java diff --git a/compilestandard.java b/compilestandard.java new file mode 100644 index 0000000..efd15c2 --- /dev/null +++ b/compilestandard.java @@ -0,0 +1,28 @@ +import java.io.*; +public class compilestandard extends usacotools { + + public static void main(String[] args) throws IOException{ + // TODO Auto-generated method stub + BufferedReader f; + if(args.length==1) { + if(args[0].equals("eclipse")) { + f=mreader("src/usacotools.java"); + }else { + f=mreader("usacotools.java"); + } + + }else { + f=mreader("usacotools.java"); + } + + print("build"); + + String st; + String full=""; + + while ((st = f.readLine()) != null) { + full=full+st+"\n"; + } + print(full.replace("if(!(lock)) {return null;}", "")); + } +} diff --git a/usacotools.java b/usacotools.java index 95548ad..abd0f8a 100644 --- a/usacotools.java +++ b/usacotools.java @@ -1,4 +1,8 @@ - +/* + * USACOTOOLS-Official version + * This is the official version. + * + */ import java.util.*; import java.io.*; public abstract class usacotools { @@ -16,6 +20,11 @@ public abstract class usacotools { public static String error="Error"; public static int debugcode=-1; public static boolean DEBUG=false; + public static boolean lock; + public static boolean IO=true; + public static void blockio() { + IO=false; + } public static boolean isrect(int[][] map,int x,int y) { int cachedsize=-1; int cachey=-1; @@ -105,6 +114,7 @@ public static String changen(int position, char ch, String str){ return new String(charArray); } public static BufferedReader mreader(String filen) throws IOException { + //Make a reader return new BufferedReader(new FileReader(filen)); } public static PrintWriter mwriter(String filen) throws IOException { @@ -137,6 +147,7 @@ public static int binarySearch(int arr[], int l, int r, int x) return -1; } public static int[][] copy2D(int[][] a){ + if(!(lock)) {return null;} int[][] b=new int[a.length][]; for(int i=0;i arr) { + if(!(lock)) {return null;} int[] stuff=new int[arr.size()]; for(int i=0;i arr) { } public static String[] toArrays(ArrayList arr) { + if(!(lock)) {return null;} String[] stuff=new String[arr.size()]; for(int i=0;i fibmem=new ArrayList(); public static long ffib(long n){ + /* + * Fibonnaci implemented with DP + */ if(n<=1) { return n; } @@ -335,6 +357,7 @@ public static void setupfib() { fibmem.add((long) 0);fibmem.add((long)1);fibmem.add((long)1);fibmem.add((long)2); } public static void show2Darr(int[][] a) { + //Print out a 2D array for you for(int[] b:a) { for(int c:b) { print(c+" ",""); @@ -344,6 +367,7 @@ public static void show2Darr(int[][] a) { } } public static void showarr(int[] a) { + //Print out a array for you for(int x:a) {print(x+" ");} } public static int[][] dpcache; @@ -366,62 +390,39 @@ public static int ks(int W,int[] wt,int[] val,int n) { public static void kssetup(int n,int W) { dpcache=new int[n+1][W+1]; } - public static void main(String[] args) throws Exception{ + public static int count(int[] arr) { /* - * Short demo of stuff - * Making an error would also demo error reporting - * + * Number of groups of 1s + * Modify for other purposes if needed + * Example + * 1111000111 + * Returns 2 * */ - System.out.println("Running demo"); - Scanner sc=getsysscan(); - print("Welcome to the demo"); - print(">",""); - int val; - /* - int[][] testarray= { - {1,1,2,7,7,1,1,1}, - {1,1,4,0,7,1,2,2}, - {0,3,6,9,1,0,0,0}, - {0,3,0,1,0,0,0,0}, - {0,3,0,0,0,0,0,0}, - {1,1,5,1,3,1,1,1}, - {1,1,1,1,3,1,1,1}, - }; - */ - int[][] testarray= { - {1,2,3,1}, - {4,5,6,2}, - {7,8,9,3}, - {10,69,1,4} - - }; - print("Roation of 90 degrees\n Before \n "); - show2Darr(testarray); - print("After \n"); - show2Darr(rotate90cw(testarray)); - print("BEFORE:"); - int[][] ii= { - {1,1,2,3}, - {1,0,2,1}, - {1,1,1,1}, - {1,2,3,4} - }; - show2Darr(ii); - print("After H reflect:"); - show2Darr(reverseh(ii)); - - try { - val=sc.nextInt(); - }catch(Exception e) { - print("Oops that did not go well please rerun and choose a INTEGER"); - val=-1; - report(e); - print("How about we test error reporting"); - console(); - } - if(1==val) { - + boolean b=false;int c=0;int temp; + for(int i=0;i Date: Sun, 26 Aug 2018 04:27:13 +0000 Subject: [PATCH 15/23] Add files via upload --- compilestandard.java | 13 +- usacotools.java | 2 + utools.java | 431 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 445 insertions(+), 1 deletion(-) create mode 100644 utools.java diff --git a/compilestandard.java b/compilestandard.java index efd15c2..1cdc7c0 100644 --- a/compilestandard.java +++ b/compilestandard.java @@ -23,6 +23,17 @@ public static void main(String[] args) throws IOException{ while ((st = f.readLine()) != null) { full=full+st+"\n"; } - print(full.replace("if(!(lock)) {return null;}", "")); + String text=full.replace("if(!(lock)) {return null;}", ""); + text=text.replace("public abstract class usacotools","public abstract class utools"); + print(text); + PrintWriter pw=mwriter("utools.java"); + if(args[0].equals("eclipse")) { + pw=mwriter("src/utools.java"); + }else { + + } + pw.println(text); + pw.close(); + } } diff --git a/usacotools.java b/usacotools.java index abd0f8a..e96cb75 100644 --- a/usacotools.java +++ b/usacotools.java @@ -422,7 +422,9 @@ public static void LOCK() { public static void UNLOCK() { if(!(_lock)) {lock=false;} } + public static void main(String[] args) throws Exception{ print("the demo has been removed do to lack of support. Instead we display info about the library."); } + } diff --git a/utools.java b/utools.java new file mode 100644 index 0000000..6de21a9 --- /dev/null +++ b/utools.java @@ -0,0 +1,431 @@ +/* + * USACOTOOLS-Official version + * This is the official version. + * + */ +import java.util.*; +import java.io.*; +public abstract class utools { + public static final String ANSI_RESET = "\u001B[0m"; + public static final String ANSI_BLACK = "\u001B[30m"; + public static final String ANSI_RED = "\u001B[31m"; + public static final String ANSI_GREEN = "\u001B[32m"; + public static final String ANSI_YELLOW = "\u001B[33m"; + public static final String ANSI_BLUE = "\u001B[34m"; + public static final String ANSI_PURPLE = "\u001B[35m"; + public static final String ANSI_CYAN = "\u001B[36m"; + public static final String ANSI_WHITE = "\u001B[37m"; + public static int ERRORS=0; + public static ArrayList console=new ArrayList(); + public static String error="Error"; + public static int debugcode=-1; + public static boolean DEBUG=false; + public static boolean lock; + public static boolean IO=true; + public static void blockio() { + IO=false; + } + public static boolean isrect(int[][] map,int x,int y) { + int cachedsize=-1; + int cachey=-1; + for(int i=x;icachedsize) { + return false; + } + for(int j=y;jcachey) { + return false; + } + } + } + return true; + } + public static Set sclones(Set k) { + return (new HashSet(k)); + } + public static Set sclone(Set k) { + + return (new HashSet(k)); + } + public static Set sclonel(Set k) { + return (new HashSet(k)); + } + public static boolean smartequals(int[] a,int[] b) { + if(a.length!=b.length) { + return false; + } + for(int i=0;i touching(int[][] map,int x,int y){ + ArrayList out=new ArrayList(); + try { + out.add(map[x-1][y]); + }catch(Exception e) { + + } + try { + out.add(map[x+1][y]); + }catch(Exception e) { + + } + try { + out.add(map[x][y-1]); + }catch(Exception e) { + + } + try { + out.add(map[x][y+1]); + }catch(Exception e) { + + } + return out; + + } + public static String repeat(int count, String with) { + return new String(new char[count]).replace("\0", with); + } + public static String changen(int position, char ch, String str){ + char[] charArray = str.toCharArray(); + charArray[position] = ch; + return new String(charArray); + } + public static BufferedReader mreader(String filen) throws IOException { + //Make a reader + return new BufferedReader(new FileReader(filen)); + } + public static PrintWriter mwriter(String filen) throws IOException { + return new PrintWriter(new BufferedWriter(new FileWriter(filen))); + } + public static Scanner getsysscan() { + return new Scanner(System.in); + } + public static int binarySearch(int arr[], int l, int r, int x) + { + /* + * Binary Search + * + */ + if (r>=l) + { + int mid = l + (r - l)/2; + + + if (arr[mid] == x) + return mid; + + if (arr[mid] > x) + return binarySearch(arr, l, mid-1, x); + + return binarySearch(arr, mid+1, r, x); + } + + + return -1; + } + public static int[][] copy2D(int[][] a){ + + int[][] b=new int[a.length][]; + for(int i=0;i arr) { + + int[] stuff=new int[arr.size()]; + for(int i=0;i arr) { + + String[] stuff=new String[arr.size()]; + for(int i=0;i fibmem=new ArrayList(); + public static long ffib(long n){ + /* + * Fibonnaci implemented with DP + */ + if(n<=1) { + return n; + } + + if(fibmem.size()>n) { + return fibmem.get((int) n-1)+fibmem.get((int) n-2); + }else { + fibmem.add(ffib(n-1)+ffib(n-2)); + return fibmem.get((int) n); + } + } + public static void print() { + System.out.println(); + } + public static void setupfib() { + fibmem.add((long) 0);fibmem.add((long)1);fibmem.add((long)1);fibmem.add((long)2); + } + public static void show2Darr(int[][] a) { + //Print out a 2D array for you + for(int[] b:a) { + for(int c:b) { + print(c+" ",""); + } + print(); + + } + } + public static void showarr(int[] a) { + //Print out a array for you + for(int x:a) {print(x+" ");} + } + public static int[][] dpcache; + public static int ks(int W,int[] wt,int[] val,int n) { + int result; + if(dpcache[n][W]!=0) {return dpcache[n][W];} + if(n==0||W==0) { + result=0; + }else if(wt[n-1]>W) { + result=ks(W,wt,val,n-1); + + + + }else { + result=Math.max(val[n-1]+ks(W-wt[n-1],wt,val,n-1),ks(W,wt,val,n-1)); + } + dpcache[n][W]=result; + return result; + } + public static void kssetup(int n,int W) { + dpcache=new int[n+1][W+1]; + } + public static int count(int[] arr) { + /* + * Number of groups of 1s + * Modify for other purposes if needed + * Example + * 1111000111 + * Returns 2 + * + */ + boolean b=false;int c=0;int temp; + for(int i=0;i Date: Sun, 26 Aug 2018 04:35:11 +0000 Subject: [PATCH 16/23] Add files via upload --- compilestandard.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/compilestandard.java b/compilestandard.java index 1cdc7c0..1b31cf1 100644 --- a/compilestandard.java +++ b/compilestandard.java @@ -1,6 +1,17 @@ import java.io.*; +import java.security.MessageDigest; +import java.security.*; public class compilestandard extends usacotools { - + public static String sha256(String input) throws NoSuchAlgorithmException { + MessageDigest mDigest = MessageDigest.getInstance("SHA-256"); + byte[] result = mDigest.digest(input.getBytes()); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < result.length; i++) { + sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1)); + } + + return sb.toString(); + } public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader f; @@ -34,6 +45,13 @@ public static void main(String[] args) throws IOException{ } pw.println(text); pw.close(); + print("utools.java is the one you should copy into your code but usacotools is the one you should extend"); + try{ + print("utools.java SHA256: "+sha256(text)); + print("usacotools.java SHA256: "+sha256(full)); + }catch(Exception e) { + e.printStackTrace(); + } } } From 642b81171ec9dfee12a0418b493dafec6f002a1a Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 26 Aug 2018 04:40:24 +0000 Subject: [PATCH 17/23] Add files via upload --- usacotools.java | 22 ++++++++++++++++++++++ utools.java | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/usacotools.java b/usacotools.java index e96cb75..483c2d1 100644 --- a/usacotools.java +++ b/usacotools.java @@ -4,7 +4,9 @@ * */ import java.util.*; + import java.io.*; +import java.security.*; public abstract class usacotools { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; @@ -422,6 +424,26 @@ public static void LOCK() { public static void UNLOCK() { if(!(_lock)) {lock=false;} } + public static String sha256(String input) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + byte[] result = md.digest(input.getBytes()); + StringBuffer s = new StringBuffer(); + for (int i = 0; i < result.length; i++) { + s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1)); + } + + return s.toString(); + } + public static String sha(String input,String type) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance(type); + byte[] result = md.digest(input.getBytes()); + StringBuffer s = new StringBuffer(); + for (int i = 0; i < result.length; i++) { + s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1)); + } + + return s.toString(); + } public static void main(String[] args) throws Exception{ print("the demo has been removed do to lack of support. Instead we display info about the library."); diff --git a/utools.java b/utools.java index 6de21a9..58c8058 100644 --- a/utools.java +++ b/utools.java @@ -4,7 +4,9 @@ * */ import java.util.*; + import java.io.*; +import java.security.*; public abstract class utools { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; @@ -422,6 +424,26 @@ public static void LOCK() { public static void UNLOCK() { if(!(_lock)) {lock=false;} } + public static String sha256(String input) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + byte[] result = md.digest(input.getBytes()); + StringBuffer s = new StringBuffer(); + for (int i = 0; i < result.length; i++) { + s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1)); + } + + return s.toString(); + } + public static String sha(String input,String type) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance(type); + byte[] result = md.digest(input.getBytes()); + StringBuffer s = new StringBuffer(); + for (int i = 0; i < result.length; i++) { + s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1)); + } + + return s.toString(); + } public static void main(String[] args) throws Exception{ print("the demo has been removed do to lack of support. Instead we display info about the library."); From 60c33960303ce2ff0a8ea8fc68f920764fe00df8 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sun, 26 Aug 2018 18:17:55 -0700 Subject: [PATCH 18/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f479297..11cc11e 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Useful library for usaco and other purposes. . Use releases when possible otherwise download usacotools.java. # Release dates and more -Find release dates at https://javaarchive.github.io/Java/ +Find release dates at https://javaarchive.github.io/Java/. Moved to https://github.com/javaarchive/Java/wiki From 7e7b4932e9ae27861a2dc7ea58d31296f4780f1a Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Fri, 7 Sep 2018 20:24:14 -0700 Subject: [PATCH 19/23] Rename index.html to index.htm --- index.htm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 index.htm diff --git a/index.htm b/index.htm new file mode 100644 index 0000000..393a061 --- /dev/null +++ b/index.htm @@ -0,0 +1,27 @@ + + + + + + + + + + +Code Speed + + + + + + + +

Which runs faster on java

+ + + + + + From ccf7e8ba554d472f37c229b20d784f1568dfbce1 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Fri, 7 Sep 2018 20:24:59 -0700 Subject: [PATCH 20/23] Delete index.html --- index.html | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 index.html diff --git a/index.html b/index.html deleted file mode 100644 index 92424de..0000000 --- a/index.html +++ /dev/null @@ -1,2 +0,0 @@ -

Next update release

-

Should be at 8/1/2018

From 410be72c38b9f4c609479dcba7a5888f6851e0f3 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Fri, 7 Sep 2018 20:43:19 -0700 Subject: [PATCH 21/23] Set theme jekyll-theme-cayman --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index c741881..c419263 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-slate \ No newline at end of file +theme: jekyll-theme-cayman \ No newline at end of file From c402dd53b5281a4fabf6dc55e66773627f84244d Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sat, 8 Sep 2018 03:57:07 +0000 Subject: [PATCH 22/23] Add files via upload --- usacotools.java | 42 ++++++++++++++++++++++++++++++++++++++---- utools.java | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/usacotools.java b/usacotools.java index 483c2d1..7794c79 100644 --- a/usacotools.java +++ b/usacotools.java @@ -3,10 +3,22 @@ * This is the official version. * */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Queue; +import java.util.Scanner; +import java.util.Set; import java.util.*; - -import java.io.*; -import java.security.*; +import java.util.regex.*; public abstract class usacotools { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; @@ -444,9 +456,31 @@ public static String sha(String input,String type) throws NoSuchAlgorithmExcepti return s.toString(); } + public static double cos(double a) {return Math.cos(a);} + public static double sin(double a) {return Math.sin(a);} + public static double abs(double a) {return Math.abs(a);} + public static double floor(double a) {return Math.floor(a);} + public static double ceil(double a) {return Math.ceil(a);} public static void main(String[] args) throws Exception{ + System.out.println("Running"); + $1(); print("the demo has been removed do to lack of support. Instead we display info about the library."); + $1(); + System.out.println($r()); + } + public static Queue speedqueue=new LinkedList(); + public static long prevtime=0; + public static void $1() { + long time=System.currentTimeMillis(); + if(prevtime==0) { + prevtime=time; + }else { + speedqueue.add((long) abs(time-prevtime)); + prevtime=0; + } + } + public static long $r() { + return speedqueue.poll().longValue(); } - } diff --git a/utools.java b/utools.java index 58c8058..f250dc4 100644 --- a/utools.java +++ b/utools.java @@ -3,10 +3,22 @@ * This is the official version. * */ +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Queue; +import java.util.Scanner; +import java.util.Set; import java.util.*; - -import java.io.*; -import java.security.*; +import java.util.regex.*; public abstract class utools { public static final String ANSI_RESET = "\u001B[0m"; public static final String ANSI_BLACK = "\u001B[30m"; @@ -444,10 +456,32 @@ public static String sha(String input,String type) throws NoSuchAlgorithmExcepti return s.toString(); } + public static double cos(double a) {return Math.cos(a);} + public static double sin(double a) {return Math.sin(a);} + public static double abs(double a) {return Math.abs(a);} + public static double floor(double a) {return Math.floor(a);} + public static double ceil(double a) {return Math.ceil(a);} public static void main(String[] args) throws Exception{ + System.out.println("Running"); + $1(); print("the demo has been removed do to lack of support. Instead we display info about the library."); + $1(); + System.out.println($r()); + } + public static Queue speedqueue=new LinkedList(); + public static long prevtime=0; + public static void $1() { + long time=System.currentTimeMillis(); + if(prevtime==0) { + prevtime=time; + }else { + speedqueue.add((long) abs(time-prevtime)); + prevtime=0; + } + } + public static long $r() { + return speedqueue.poll().longValue(); } - } From de533860eceee96e736b4cf4a02070ceaf359bd1 Mon Sep 17 00:00:00 2001 From: Raymond <20248577+javaarchive@users.noreply.github.com> Date: Sat, 8 Sep 2018 04:05:13 +0000 Subject: [PATCH 23/23] Add files via upload --- usacotools.java | 7 +++++++ utools.java | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/usacotools.java b/usacotools.java index 7794c79..f7ed572 100644 --- a/usacotools.java +++ b/usacotools.java @@ -483,4 +483,11 @@ public static void main(String[] args) throws Exception{ public static long $r() { return speedqueue.poll().longValue(); } + public static boolean $r$smatch(String a,String b) { + return Pattern.matches(a, b); + } + public static boolean $r$match(String a,String b) throws Exception{ + //WIP + throw new Exception("Not implemented"); + } } diff --git a/utools.java b/utools.java index f250dc4..83bfe5f 100644 --- a/utools.java +++ b/utools.java @@ -483,5 +483,12 @@ public static void main(String[] args) throws Exception{ public static long $r() { return speedqueue.poll().longValue(); } + public static boolean $r$smatch(String a,String b) { + return Pattern.matches(a, b); + } + public static boolean $r$match(String a,String b) throws Exception{ + //WIP + throw new Exception("Not implemented"); + } }