diff --git a/README.md b/README.md index f479297..00af099 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ 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/ +# Beta 2 SHA-256 verifacation(new) +521EF445C6333947B399629D0F9F52A27BB0D58F00750CFD90B6A4902856CC15 diff --git a/usacotools.java b/usacotools.java index 95548ad..78183d3 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 { @@ -105,6 +109,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 { @@ -309,6 +314,7 @@ public static int classify(char x,char off,char on) { } public static long slowfib(long num){ + //Slow recursion fibonnaci if(num<=1) { return num; } @@ -317,6 +323,9 @@ public static long slowfib(long num){ } public static ArrayList fibmem=new ArrayList(); public static long ffib(long n){ + /* + * Fibonnaci implemented with DP + */ if(n<=1) { return n; } @@ -335,6 +344,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 +354,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 +377,29 @@ 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