Added Colors + worked on deep
This commit is contained in:
21
src/main/java/me/trouper/Data/ANSI.java
Normal file
21
src/main/java/me/trouper/Data/ANSI.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package me.trouper.Data;
|
||||
|
||||
public class ANSI {
|
||||
public static final String RESET = "\u001B[0m";
|
||||
public static final String BLACK = "\u001B[30m";
|
||||
public static final String RED = "\u001B[31m";
|
||||
public static final String GREEN = "\u001B[32m";
|
||||
public static final String YELLOW = "\u001B[33m";
|
||||
public static final String BLUE = "\u001B[34m";
|
||||
public static final String PURPLE = "\u001B[35m";
|
||||
public static final String CYAN = "\u001B[36m";
|
||||
public static final String WHITE = "\u001B[37m";
|
||||
public static final String BLACK_BACKGROUND = "\u001B[40m";
|
||||
public static final String RED_BACKGROUND = "\u001B[41m";
|
||||
public static final String GREEN_BACKGROUND = "\u001B[42m";
|
||||
public static final String YELLOW_BACKGROUND = "\u001B[43m";
|
||||
public static final String BLUE_BACKGROUND = "\u001B[44m";
|
||||
public static final String PURPLE_BACKGROUND = "\u001B[45m";
|
||||
public static final String CYAN_BACKGROUND = "\u001B[46m";
|
||||
public static final String WHITE_BACKGROUND = "\u001B[47m";
|
||||
}
|
||||
@@ -5,36 +5,30 @@ import java.util.Random;
|
||||
import static me.trouper.Functions.Eval.eval;
|
||||
|
||||
public class Complexers {
|
||||
public static String divide(int i) {
|
||||
public static String divide(int i, boolean deep) {
|
||||
Random random = new Random();
|
||||
int factor = random.nextInt(9)+1;
|
||||
int doubled = i * factor;
|
||||
String result = "(" + doubled + "/" + factor + ")";
|
||||
|
||||
String result;
|
||||
if (deep) {
|
||||
result = "(" + Increasers.multiply(doubled,1,false) + "/" + Increasers.multiply(factor,1,false) + ")";
|
||||
} else {
|
||||
result = "(" + doubled + "/" + factor + ")";
|
||||
}
|
||||
if (eval(result) == i) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
|
||||
public static String multiply(int i, int factor) {
|
||||
String result = "(" + i + "*" + factor + ")";
|
||||
if (eval(result) == i * factor) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
public static String power(int i, int exp) {
|
||||
String result = "(" + i + "^" + exp + ")";
|
||||
if (eval(result) == Math.pow(i,exp)) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
|
||||
public static String root(int i) {
|
||||
public static String root(int i, boolean deep) {
|
||||
int squared = (int) Math.pow(i,2);
|
||||
String result = "sqrt(" + squared + ")";
|
||||
String result;
|
||||
if (deep) {
|
||||
result = "sqrt(" + Increasers.power(i,1,false) + ")";
|
||||
} else {
|
||||
result = "sqrt(" + squared + ")";
|
||||
}
|
||||
if (eval(result) == i){
|
||||
return result;
|
||||
}
|
||||
|
||||
30
src/main/java/me/trouper/Functions/Increasers.java
Normal file
30
src/main/java/me/trouper/Functions/Increasers.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package me.trouper.Functions;
|
||||
|
||||
import static me.trouper.Functions.Eval.eval;
|
||||
|
||||
public class Increasers {
|
||||
public static String multiply(int i, int factor, boolean deep) {
|
||||
String result;
|
||||
if (deep) {
|
||||
result = "(" + Complexers.divide(i,false) + "/" + Complexers.divide(factor,false) + ")";
|
||||
} else {
|
||||
result = "(" + i + "*" + factor + ")";
|
||||
}
|
||||
if (eval(result) == i * factor) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
public static String power(int i, int exp, boolean deep) {
|
||||
String result;
|
||||
if (deep) {
|
||||
result = "(" + Complexers.root(i,false) + "^" + Complexers.root(exp,false) + ")";
|
||||
} else {
|
||||
result = "(" + i + "^" + exp + ")";
|
||||
}
|
||||
if (eval(result) == Math.pow(i,exp)) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package me.trouper;
|
||||
|
||||
import me.trouper.Data.ANSI;
|
||||
import me.trouper.Functions.Complexers;
|
||||
import me.trouper.Functions.Increasers;
|
||||
import me.trouper.Functions.Utils;
|
||||
|
||||
import java.util.Random;
|
||||
@@ -12,6 +14,7 @@ import static me.trouper.Functions.Utils.verbose;
|
||||
public class Main {
|
||||
public static boolean verbose;
|
||||
public static boolean deep;
|
||||
private static final StringBuilder formattedExp = new StringBuilder();
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
boolean doCopy = false;
|
||||
@@ -34,10 +37,10 @@ public class Main {
|
||||
|
||||
System.out.println("\nTarget Integer: " + target);
|
||||
if (output == target) {
|
||||
System.out.println("Expression Verified Correct: \n" + expression);
|
||||
System.out.println(ANSI.GREEN_BACKGROUND + "Expression Verified Correct:" + ANSI.RESET + " \n" + formattedExp);
|
||||
if (doCopy) Utils.copyToClip(expression);
|
||||
} else {
|
||||
System.out.println("!!!! INCORRECT !!!! \n" + expression);
|
||||
System.out.println(ANSI.RED_BACKGROUND + ANSI.BLACK + "!!!! INCORRECT !!!! \n" + ANSI.RESET + formattedExp);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Exiting the program.");
|
||||
@@ -51,11 +54,14 @@ public class Main {
|
||||
public static String obfInt(int target, boolean deep) {
|
||||
if (deep) System.out.println("Deep Obfuscation is still in development!");
|
||||
StringBuilder expression = new StringBuilder();
|
||||
formattedExp.setLength(0);
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
int initializer = random.nextInt(9)+1;
|
||||
verbose("Initializing Expression: " + initializer);
|
||||
expression.append(initializer);
|
||||
formattedExp.append(ANSI.GREEN).append(initializer).append(ANSI.RESET);
|
||||
|
||||
int cubeCount = 0;
|
||||
int factorCount = 0;
|
||||
@@ -89,6 +95,7 @@ public class Main {
|
||||
perfectCount++;
|
||||
verbose("PERFECT SQUARE TIME! (" + perfectCount+ ")");
|
||||
expression.insert(0,"sqrt(").append(")");
|
||||
formattedExp.insert(0,ANSI.YELLOW_BACKGROUND + "sqrt(").append(")" + ANSI.RESET);
|
||||
eval = (int) eval(expression.toString());
|
||||
}
|
||||
|
||||
@@ -96,11 +103,11 @@ public class Main {
|
||||
mult = true;
|
||||
cubeCount++;
|
||||
verbose("Enormous than (" + cubeCount + ")");
|
||||
expression.append("+").append(Complexers.power(ri,3));
|
||||
expression.append("+").append(Increasers.power(ri,3,deep));
|
||||
} else if (target - eval > 100) {
|
||||
factorCount++;
|
||||
verbose("Large than (" + factorCount + ")");
|
||||
expression.append("+").append(Complexers.multiply(ri,10));
|
||||
expression.append("+").append(Increasers.multiply(ri,10,deep));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -111,7 +118,7 @@ public class Main {
|
||||
} else {
|
||||
rootCount++;
|
||||
}
|
||||
expression.append((mult) ? "*" : "+").append((op == 0) ? Complexers.divide(ri) : Complexers.root(ri));
|
||||
expression.append((mult) ? "*" : "+").append((op == 0) ? Complexers.divide(ri,deep) : Complexers.root(ri,deep));
|
||||
verbose("Less than (" + addCount + ")");
|
||||
}
|
||||
|
||||
@@ -124,7 +131,7 @@ public class Main {
|
||||
}
|
||||
expression.insert(0,"(").append(")");
|
||||
|
||||
expression.append("-").append((op == 0) ? Complexers.divide(ri) : Complexers.root(ri));
|
||||
expression.append("-").append((op == 0) ? Complexers.divide(ri,deep) : Complexers.root(ri,deep));
|
||||
verbose("Greater than (" + subCount + ")");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user