Navigation Menu

Skip to content

Commit

Permalink
make the compressor not kill itself occasionally
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaima committed Jun 15, 2019
1 parent 3d52944 commit 2551391
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions compiler/compression/compress.pde
Expand Up @@ -185,25 +185,25 @@ ArrayList<int[]> compressSmart(String s) {
//if (box)
try {
ArrayList<int[]> c = compress(s, true, 3);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
try {
ArrayList<int[]> c = compress(s, true, 0);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
try {
ArrayList<int[]> c = compress(s, true, 2);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
try {
ArrayList<int[]> c = compress(s, true, 4);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
Expand Down
2 changes: 1 addition & 1 deletion compiler/compression/compression.pde
Expand Up @@ -169,7 +169,7 @@ String pre (String s, int amo, String p) {
}
BigDecimal[] toBaseBD (BigDecimal base, BigDecimal b) {
ArrayList<BigDecimal> o = new ArrayList<BigDecimal>();
while (!b.equals(BigInteger.ZERO)) {
while (!b.equals(BigDecimal.ZERO)) {
BigDecimal[] t = b.divideAndRemainder(base);
o.add(t[1]);
b = t[0];
Expand Down
1 change: 1 addition & 0 deletions compiler/compression/decompress.pde
Expand Up @@ -7,6 +7,7 @@ String decompress(String s) {
}
int pos;
String decompb(BigInteger inpbi) {
if (inpbi.compareTo(BigInteger.ZERO) < 0) throw new Error("invalid input!");
//println(in);
pos = 0;
decompressable = inpbi;
Expand Down
11 changes: 6 additions & 5 deletions compression/compiled.pde
Expand Up @@ -185,25 +185,25 @@ ArrayList<int[]> compressSmart(String s) {
//if (box)
try {
ArrayList<int[]> c = compress(s, true, 3);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
try {
ArrayList<int[]> c = compress(s, true, 0);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
try {
ArrayList<int[]> c = compress(s, true, 2);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
try {
ArrayList<int[]> c = compress(s, true, 4);
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1||bc.equals(""))) {
if (s.equals(decompb(toNum(c))) && (toNum(c).compareTo(toNum(bc))==-1 || bc.size()==0)) {
bc = c;
}
}catch(Exception e){}
Expand Down Expand Up @@ -547,7 +547,7 @@ String pre (String s, int amo, String p) {
}
BigDecimal[] toBaseBD (BigDecimal base, BigDecimal b) {
ArrayList<BigDecimal> o = new ArrayList<BigDecimal>();
while (!b.equals(BigInteger.ZERO)) {
while (!b.equals(BigDecimal.ZERO)) {
BigDecimal[] t = b.divideAndRemainder(base);
o.add(t[1]);
b = t[0];
Expand All @@ -568,6 +568,7 @@ String decompress(String s) {
}
int pos;
String decompb(BigInteger inpbi) {
if (inpbi.compareTo(BigInteger.ZERO) < 0) throw new Error("invalid input!");
//println(in);
pos = 0;
decompressable = inpbi;
Expand Down

0 comments on commit 2551391

Please sign in to comment.