Tags

,


Here is the solution for the puzzle #1 that I’ve posted some days back.

Let’s divide total 10000 numbers into 1000 series, and label them from 000 to 999. For example, 000th series will have 0001, 0002, 0003, … 0000. 345th series will have 3451, 3452, 3453, … 3450. In a given xyzth series, the number xyz0 is kept at the end in order to continue looping to other series.

Let’s say I am starting with a 4 digit number wxyz. The next number that follows will be xyz*. That means, I have to select a number which belongs to xyz series, i.e, between xyz1 to xyz0. Everytime I have to select a number from a new series xyz, I will start with the first number available in that series, i.e, xyz1. Next time I come to this series, I will select xyz2, and so on. This procedure ensures that we will traverse through all the numbers in a loop. For example, if my starting number is 0001, next number belongs to 001 series. I will select 0011. Next series is 011, I will select 0111. Next series is 111, I will select 1111. Next series is again 111, and the next available number in this series is 1112. This goes on, and loops the whole set of 4-digit numbers.

If you want to try this logic manually, you can first assume that the password length is 2, and there will be 10 series, each containing 10 numbers. Maintaining a mental list for this (or scanning a string of 102 digits) is easier. Start with 01 as your first number, and do the above procedure. A pattern can be recognized.

If you want to try this logic on computer, use the following c++ code. For reference, I am also pasting the output of this code for a password length of 4.  Note that this code can be used for password length varying from 2 to 10.

Download the c++ code, and output for password length of 4.

PS: One of my colleagues has solved this in a different way. I will post that answer when time permits.

Advertisements