Stupid Programmer at work! - Page 2
Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Stupid Programmer at work!

  1. #11
    Senior Member
    Join Date
    May 2003
    Posts
    226
    Code:
    public class Test {
        private int start = 33;
        private int end = 126;
    
        public void generateCombo() {
            for (int a = start; a <= end; ++a) {
                for (int b = start; b <= end; ++b) {
                    for (int c = start; c <= end; ++c) {
                        for (int d = start; d <= end; ++d) {
                            for (int e = start; e <= end; ++e) {
                                for (int f = start; f <= end; ++f) {
                                    for (int g = start; g <= end; ++g) {
                                        for (int h = start; h <= end; ++h) {
                                            System.out.println((char) a + "" +
                                                (char) b + "" + (char) c + "" +
                                                (char) d + "" + (char) e + "" +
                                                (char) f + "" + (char) g + "" +
                                                (char) h);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    
        public static void main(String[] args) {
            Test test = new Test();
            test.generateCombo();
        }
    }
    Well, this is what i have coded. I heard of recursion and some other algorithms would be able to do the job as well. Hope someone can shed some light on me lol

  2. #12
    Banned
    Join Date
    Sep 2004
    Posts
    305
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() {
    
        char pw[6];
    
        int MAXVAL = 126;
        int MINVAL = 33;
    
        // Set the string to be the first password
        for (int i = 0; i < 6; i++) {
            pw[i] = MINVAL;
        }
    
        int pwCount = pow(MAXVAL - MINVAL, 6);
    
        for (i = 0; i < pwCount; i++) {
            if (++pw[5] >= MAXVAL) {
                pw[5] = MINVAL;
    
                if (++pw[4] >= MAXVAL) {
                    pw[4] = MINVAL;
    
                    if (++pw[3] >= MAXVAL) {
                        pw[3] = MINVAL;
    
                        if (++pw[2] >= MAXVAL) {
                            pw[2] = MINVAL;
    
                            if (++pw[1] >= MAXVAL) {
                                pw[1] = MINVAL;
                                pw[0]++;
                            }
                        }
                    }
                }
            }
        }
                
    }
    ZeroCool, and I with the help of another online friend were able to pull this from our asses... yes, yes, it's C++ but it runs a lot faster than Java so you can use the concept and convert it to Java.

    Just curious, what would you use this for? In the end this comes to hundreds of gb of data...

  3. #13
    Senior Member
    Join Date
    May 2003
    Posts
    226
    Originally posted here by ;TT
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() {
    
        char pw[6];
    
        int MAXVAL = 126;
        int MINVAL = 33;
    
        // Set the string to be the first password
        for (int i = 0; i < 6; i++) {
            pw[i] = MINVAL;
        }
    
        int pwCount = pow(MAXVAL - MINVAL, 6);
    
        for (i = 0; i < pwCount; i++) {
            if (++pw[5] >= MAXVAL) {
                pw[5] = MINVAL;
    
                if (++pw[4] >= MAXVAL) {
                    pw[4] = MINVAL;
    
                    if (++pw[3] >= MAXVAL) {
                        pw[3] = MINVAL;
    
                        if (++pw[2] >= MAXVAL) {
                            pw[2] = MINVAL;
    
                            if (++pw[1] >= MAXVAL) {
                                pw[1] = MINVAL;
                                pw[0]++;
                            }
                        }
                    }
                }
            }
        }
                
    }
    ZeroCool, and I with the help of another online friend were able to pull this from our asses... yes, yes, it's C++ but it runs a lot faster than Java so you can use the concept and convert it to Java.

    Just curious, what would you use this for? In the end this comes to hundreds of gb of data...
    Well, this is my assignment in school haha. Just curious about ways and ways of solving a problem =p

  4. #14
    Banned
    Join Date
    Jun 2003
    Posts
    1,302
    Death_Knight type out the entire specifications for your project for school. I am looking at what everyone is giving you and wondering first what the hell. Second, I don't truly understand what your professor wants you to do.

  5. #15
    Senior Member
    Join Date
    May 2003
    Posts
    226
    Originally posted here by whizkid2300
    Death_Knight type out the entire specifications for your project for school. I am looking at what everyone is giving you and wondering first what the hell. Second, I don't truly understand what your professor wants you to do.
    Sorry, i didn't specify my requirements properly and pardon me for my bad english. Anyway i have solved my problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides