• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Cracking code

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Johnny Knoxville

Disabled
Joined
May 29, 2002
i need an algorithm to crack a six digit code ie 101112 min number 10, max number 99
as there are crap loads of combinations i figure using random on the numbers
ie 10 - 99 for 3 sets..

this will be run on java/C++.
 
Just off the top of my head... maybe nested loops with one loop for each digit? Just use the descent into each loop combo to generate possible numbers, so you should be able to try every single combo that way.

I.e., you have 6 nested loops. The innermost one on the first itteration would generate 000000, then 000001, ... , 000009. Then that innermost loop is done, it goes to the parent loop, which iterates itself to 1. So then you are trying out 000010, 000011, ... , 000019, etc.
 
actually, this isnt thaat hard. basically, while it isnt as fast, just have the computer count all the numbers starting from 1 up to 999999, checking after each number if the entire sequence is correct.
 
do want some "leading" code? it might not be perfect(definately not perfect), but here:

for (x=0; x<6;x++)//this counts through the digits of the pass

for (y=1; y<=99;y++) // starting the number at 1, up to 9
{

.........................
}
}

then, when the number is correct just convert your array[x] to what the number is.......
 
If you are running 6 nested for loops, that would take a long time. Wouldnt there be a better algorithm to use? I guess there arent to many things to test, but if there were.
 
Back