Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Numbers.java
- /* This file is part of Number Random.#
- /* Copyright ©2011 - @uthor #Utroz#. */
- import java.util.Scanner;
- public class Numbers {
- private static int count = 0;
- private static Scanner input = new Scanner(System.in);
- private static long totalN = 0;
- public Numbers(){}
- public void simpleBrute(){
- int a = 0, b = 0, c = 0, d = 0;
- for(a = 0; a <= 9; a++){
- for(b = 0; b <= 9; b++){
- for(c = 0; c <= 9; c++){
- for(d = 0; d <= 9; d++){
- ++count;
- System.out.println(""+a+"|"+b+"|"+c+"|"+d+"\t Current Count: "+count+"");
- } // d.
- } // c.
- } // b.
- } // a.
- }
- public void forceBrute(){
- char[] chars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','x','w','y','z'
- ,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','X','W','Y','Z'
- ,'0','1','2','3','4','5','6','7','8','9'};
- int a = 0, b = 0, c = 0, d = 0;
- for(a = 0; a < chars.length; a++){
- for(b = 0; b < chars.length; b++){
- for(c = 0; c < chars.length; c++){
- for(d = 0; d < chars.length; d++){
- ++count;
- System.out.println(""+chars[a]+"|"+chars[b]+"|"+chars[c]+"|"+chars[d]+"\t Current Count: "+count+"");
- } // d.
- } // c.
- } // b.
- }//a.
- }
- public void calculate(){
- int a = 0, b = 0, c = 0, d = 0,e = 0,f = 0;
- long[][] array = new long[5000000][6];
- int index = 1; // current index of array.
- int nRepeat = 0;
- long time = System.currentTimeMillis();
- for(a = 1; a <= 60; a++){
- if(a == b || a == c || a == d || a == e || a == f) continue;
- for(b = 1; b <= 60; b++){
- if(b == a || b == c || b == d || b == e || b == f) continue;
- for(c = 1; c <= 60; c++){
- if(c == a || c == b || c == d || c == e || c == f) continue;
- for(d = 1; d <= 60; d++){
- if(d == a || d == b || d == c || d == e || d == f) continue;
- for(e = 1; e <= 60; e++){
- if(e == a || e == b || e == c || e == d || e == f) continue;
- for(f = 1; f <= 60; f++){
- if(f == a || f == b || f == c || f == d || f == e) continue;
- boolean A_ = false, B_ = false, C_ = false, D_ = false, E_ = false, F_ = false;
- // Start on 1, because cont 0 is correct.
- for(int i = 0; i < array.length; i++){
- A_ = false; B_ = false; C_ = false; D_= false; E_ = false; F_ = false;
- if(count == 0){
- array[0][0] = a; array[0][1] = b; array[0][2] = c; array[0][3] = d; array[0][4] = e; array[0][5] = f;
- break;
- }
- if(array[i][0] == 0) break;
- /* This method is to check if this combination is equal with some other. */
- //check A.
- for(int j = 0; j < 6; j++){
- if(a == array[i][j]) A_ = true;
- }
- //check B.
- for(int j = 0; j < 6; j++){
- if(b == array[i][j]) B_ = true;
- }
- //check C.
- for(int j = 0; j < 6; j++){
- if(c == array[i][j]) C_ = true;
- }
- //check D.
- for(int j = 0; j < 6; j++){
- if(d == array[i][j]) D_ = true;
- }
- //check E.
- for(int j = 0; j < 6; j++){
- if(e == array[i][j]) E_ = true;
- }
- //check F.
- for(int j = 0; j < 6; j++){
- if(f == array[i][j]) F_ = true;
- }
- if(A_ == true && B_ == true && C_ == true && D_ == true && E_ == true && F_ == true) break;
- } // end for.
- long finalTime = System.currentTimeMillis();
- ++totalN;
- /* IF this method to be equals jump to next loop. */
- if(A_ == true && B_ == true && C_ == true && D_ == true && E_ == true && F_ == true) {
- System.out.printf("\t"+a+"|"+b+"|"+c+"|"+d+"|"+e+"|"+f+" |\t Current Count: "+count+" |\t Repeat Numbers :"+nRepeat+" |\t Current Time: %.2f (minutes) |\t Total Number: "+totalN+" |\t ## This combination is repeated! ## \n", (finalTime - time) / 1000f / 60f );
- nRepeat++;
- continue;
- }
- if(count != 0){
- array[index][0] = a; array[index][1] = b; array[index][2] = c; array[index][3] = d; array[index][4] = e; array[index++][5] = f;
- }
- finalTime = System.currentTimeMillis();
- ++count;
- System.out.printf("\t"+a+"|"+b+"|"+c+"|"+d+"|"+e+"|"+f+" |\t Current Count: "+count+" |\t Repeat Numbers :"+nRepeat+" |\t Current Time: %.2f (minutes) |\t Total Number: "+totalN+" |\t ## This combination is available! ## \n", (finalTime - time) / 1000f / 60f );
- } // f.
- } // e.
- } // d.
- } // c.
- } // b.
- }//a.
- }
- public void print(){
- System.out.println("");
- System.out.println("Combinations Amount: "+count+"");
- this.count = 0; // reset count.
- }
- public static void main(String[] args){
- System.out.println("#############################################");
- System.out.println("# Mega-Sena random Numbers by 'Utroz(RSC)'! #");
- System.out.println("#############################################");
- System.out.println("");
- try{
- Numbers num = new Numbers();
- while(true){
- System.out.println(" Main Menu:");
- System.out.println("------------");
- System.out.println("- Mega Sena [0]\n- Force Brute [1]\n- Simple Brute [2]\n\nPlease input a option:");
- int option = input.nextInt();
- int start = 5;
- while(start >= 0){
- Thread.sleep(1200);
- System.out.println("Remaining "+start+" seconds to start system...");
- start--;
- }
- System.out.println("");
- System.out.println("# Starting!... #");
- Thread.sleep(3000);
- long time = System.currentTimeMillis();
- switch(option){
- case 0:
- num.calculate();
- num.print();
- break;
- case 1:
- num.forceBrute();
- num.print();
- break;
- case 2:
- num.simpleBrute();
- num.print();
- break;
- default: System.out.println("Please input a valid option!");
- }
- long finalTime = System.currentTimeMillis();
- System.out.printf("Time used in processing: %.2f seconds.\n", (finalTime - time) / 1000f / 60f );
- }
- } catch(InterruptedException ex){
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement