Hack the mobile
All submissions for this problem are available.
"Hack the mobile" was an event conducted to the growing crackers in one of the leading colleges. All the crackers were given a mobile device which was locked with a N digit password verified dynamically (no enter button).
The task was to unlock the mobile. They were also given a hint that there was a flaw in the system that made passing through easier. The flaw was that the input buffer always held the last N-1 digits entered of the previous unsuccessful attempt. Once, the last N digits entered, matched with the password, the device would be unlocked.
For example, Consider N = 4, and the password is "2345". If the user enters "1234", The status would be "incorrect" and the buffer would store "234" (last N-1 digits). In the successive attempt, if the user enters "5678", the device would open as soon as "5" was entered as the last N digits matched the passowrd. In contrary, if he would have entered "6789", the status would be "incorrect" again, and the buffer will now contain "789".
The naive approach to solve this problem is to try out all the possibilities and store it as a string sequence whose length will be (10N)*N digits.
But when N is large, even a super computer today would take millions of years to generate such a sequence. It is
possible to reduce the length by choosing a good digit sequence which would contain all the possibilities in length 10N + N - 1. Your task is to help them find such a sequence.
Newbies, please refer to Codechef sample solution before starting to code,
The first line of input contains an integer T denoting the number of test cases.
The next T lines a single integer N, which is the length of the password
Output T lines, each line containing a sequence of 10N + N - 1 digits that contains each N-digit sequence exactly once.
- 0 ≤ T, N < 7
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.