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

Betas summary #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
86 changes: 32 additions & 54 deletions usacotools.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

/*
* USACOTOOLS-Official version
* This is the official version.
*
*/
import java.util.*;
import java.io.*;
public abstract class usacotools {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand All @@ -317,6 +323,9 @@ public static long slowfib(long num){
}
public static ArrayList<Long> fibmem=new ArrayList<Long>();
public static long ffib(long n){
/*
* Fibonnaci implemented with DP
*/
if(n<=1) {
return n;
}
Expand All @@ -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+" ","");
Expand All @@ -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;
Expand All @@ -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<arr.length;i++) {
temp=arr[i];
if(temp==0 && b) {
b=false;
c++;
}
if(temp==1 && b==false) {
b=true;
}
}
return c;
}
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.");
}
}