Name: Anonymous 2007-07-29 14:38 ID:hgb5ar6O
I need a Java application that will allow me to brute force in Java, if you have one, or can make one, it would be much appreciated.
public static void main() {
int x = 10000;
int guess;
do {
guess = new java.util.Random().nextInt();
} while (guess * guess != x);
System.out.println("Sqrt(" + x ") = " + guess);
}
while(FALSE) { printf("this part is ignored\n") }
do { printf("this part is not ignored until the expression in while() is evaluated"); } while(FALSE);
import java.util.*;
class Hankx {
public static void main(String [] arg) throws Exception {
for(int i=1; i<=arg[0].length(); i++) {
for(Iterator j = sCr(arg[0],i).iterator(); j.hasNext(); ) {
Set s = allperm((String)j.next());
for(Iterator k = s.iterator(); k.hasNext(); )
System.out.println(k.next());
}
}
}
public static List sCr(String s,int r) {
List result = new ArrayList();
if(r>0 && s.length()>0 && r<=s.length()) {
for(Iterator j = sCr(s.substring(1),r-1).iterator(); j.hasNext();)
result.add(s.charAt(0) + (String) j.next());
result.addAll(sCr(s.substring(1),r));
}
return r==0 ? Collections.singletonList("") : result;
}
public static Set allperm(String s) {
Set result = new HashSet();
for(int i=0; i<s.length(); i++)
for(Iterator j = allperm(s.substring(0,i)+s.substring(i+1)).iterator(); j.hasNext();)
result.add(s.charAt(i) + (String) j.next());
return result.size()==0 ? Collections.singleton("") : result;
}
}