Hack-Attack =========== Ring! ... Ring! (3:36am - who is that?) Ring! "Yeah?" "Alice, the servers are down!" Agg! It's times like this that you really hate your sys-admin job, but this is why you get paid the big bucks... "Okay, Bob, I'm on it." Time to get to work. With a few pings from home, you see you're going to have to go in. When you get there you discover the machines are hung on boot-up. After getting them up in a limited state you discover that the files in several key directories have had their names garbled. With more examination you decide this was a malicious hacker attack from a hacker with a sense of humor. The files all seem to be intact, but their names have been scrambled. Each filename still has the same characters of its original file name, but they have been randomly rearranged. Your last back-up is a month old. Instead of losing all the modifications to these files, you come up with another plan. You retrieve the file-lists from the back-up and you start writing a program that will generate a shell-script to rename the files back to their original names. Input ----- The first line of the input file will contain a number representing the number of directories you will processes. This will be followed by directory data. The first line of the directory data specifies how many filenames you will be processing. There will be at least 1 and at most 100 files per directory. Following this line will be all the original filenames, in random order, one per line. After that there will be all the garbled filenames, again in a random order, one per line. There will be no ambiguities - each filename will contain a different set of characters. Filenames will consist solely of uppercase or lowercase letters, the 10 digits, period (.) or underscore (_). In other words, each character will match the following regex pattern: [A-Za-z._]. Each filename will be at least one character long and at most 80. Output ------ For each input directory you will start out by outputting the following standard shell-script-line: #!/usr/bin/tcsh The second line will contain a comment with the directory number. This directory number will start out at 1 for the first directory in the input file and increment by 1 for each following directory. The formatting is as follows: #Directory [DirectoryNumber] After that you will output a series of move (mv) statements to rename the hacked filenames to the correct filenames. The move statements will be alphabetically sorted by the correct-filename. The formatting is: mv [HackedFileName] [CorrectFileName] Sample Input ------------ 2 3 inetd.conf resolv.conf passwd oofscrl.vne ssdapw ctoif.nden 8 examples.ans hack.cpp s extremestest.dat a.out hackfix.cpp t examples.dat aesmpela.xns ak.phcpc s l.emtasxepad rettmaeettxseds. t tau.o xcakpfhpc.i Sample Output ------------- #!/usr/bin/tcsh #Directory 1 mv ctoif.nden inetd.conf mv ssdapw passwd mv oofscrl.vne resolv.conf #!/usr/bin/tcsh #Directory 2 mv tau.o a.out mv aesmpela.xns examples.ans mv l.emtasxepad examples.dat mv rettmaeettxseds. extremestest.dat mv ak.phcpc hack.cpp mv xcakpfhpc.i hackfix.cpp mv s s mv t t