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

Commit ffe6dbf

Browse files
authored
Add files via upload
1 parent 8cb0d1d commit ffe6dbf

File tree

1 file changed

+26
-53
lines changed

1 file changed

+26
-53
lines changed

usacotools.java

Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ public static int classify(char x,char off,char on) {
309309

310310
}
311311
public static long slowfib(long num){
312+
//Slow recursion fibonnaci
312313
if(num<=1) {
313314
return num;
314315
}
@@ -317,6 +318,9 @@ public static long slowfib(long num){
317318
}
318319
public static ArrayList<Long> fibmem=new ArrayList<Long>();
319320
public static long ffib(long n){
321+
/*
322+
* Fibonnaci implemented with DP
323+
*/
320324
if(n<=1) {
321325
return n;
322326
}
@@ -335,6 +339,7 @@ public static void setupfib() {
335339
fibmem.add((long) 0);fibmem.add((long)1);fibmem.add((long)1);fibmem.add((long)2);
336340
}
337341
public static void show2Darr(int[][] a) {
342+
//Print out a 2D array for you
338343
for(int[] b:a) {
339344
for(int c:b) {
340345
print(c+" ","");
@@ -344,6 +349,7 @@ public static void show2Darr(int[][] a) {
344349
}
345350
}
346351
public static void showarr(int[] a) {
352+
//Print out a array for you
347353
for(int x:a) {print(x+" ");}
348354
}
349355
public static int[][] dpcache;
@@ -366,62 +372,29 @@ public static int ks(int W,int[] wt,int[] val,int n) {
366372
public static void kssetup(int n,int W) {
367373
dpcache=new int[n+1][W+1];
368374
}
369-
public static void main(String[] args) throws Exception{
375+
public static int count(int[] arr) {
370376
/*
371-
* Short demo of stuff
372-
* Making an error would also demo error reporting
373-
*
377+
* Number of groups of 1s
378+
* Modify for other purposes if needed
379+
* Example
380+
* 1111000111
381+
* Returns 2
374382
*
375383
*/
376-
System.out.println("Running demo");
377-
Scanner sc=getsysscan();
378-
print("Welcome to the demo");
379-
print(">","");
380-
int val;
381-
/*
382-
int[][] testarray= {
383-
{1,1,2,7,7,1,1,1},
384-
{1,1,4,0,7,1,2,2},
385-
{0,3,6,9,1,0,0,0},
386-
{0,3,0,1,0,0,0,0},
387-
{0,3,0,0,0,0,0,0},
388-
{1,1,5,1,3,1,1,1},
389-
{1,1,1,1,3,1,1,1},
390-
};
391-
*/
392-
int[][] testarray= {
393-
{1,2,3,1},
394-
{4,5,6,2},
395-
{7,8,9,3},
396-
{10,69,1,4}
397-
398-
};
399-
print("Roation of 90 degrees\n Before \n ");
400-
show2Darr(testarray);
401-
print("After \n");
402-
show2Darr(rotate90cw(testarray));
403-
print("BEFORE:");
404-
int[][] ii= {
405-
{1,1,2,3},
406-
{1,0,2,1},
407-
{1,1,1,1},
408-
{1,2,3,4}
409-
};
410-
show2Darr(ii);
411-
print("After H reflect:");
412-
show2Darr(reverseh(ii));
413-
414-
try {
415-
val=sc.nextInt();
416-
}catch(Exception e) {
417-
print("Oops that did not go well please rerun and choose a INTEGER");
418-
val=-1;
419-
report(e);
420-
print("How about we test error reporting");
421-
console();
422-
}
423-
if(1==val) {
424-
384+
boolean b=false;int c=0;int temp;
385+
for(int i=0;i<arr.length;i++) {
386+
temp=arr[i];
387+
if(temp==0 && b) {
388+
b=false;
389+
c++;
390+
}
391+
if(temp==1 && b==false) {
392+
b=true;
393+
}
425394
}
395+
return c;
396+
}
397+
public static void main(String[] args) throws Exception{
398+
print("the demo has been removed do to lack of support. Instead we display info about the library.");
426399
}
427400
}

0 commit comments

Comments
 (0)