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:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.