Write a Perl program to test how fast the user can sort fifteen numbers. The numbers are to be sorted into either increasing or decreasing order. The user can select either option by typing "i" or "d" at the first prompt. In either case, the program will display the items on the screen (labeled a, b, c, d, ... n, o) after the user enters "i" or "d". The user must then type the labels of the fifteen items in sorted order, one to a line. If a label is typed out of order, or some other mistake is made, the program should print a brief error message and allow the user to try again. The program should record how long it takes to get each item correct in an array and print the times and the average time at the end.
Details:
The program should generate fifteen different random numbers in the range
10 - 99 inclusive. You can use Perl's sort function, described
in Chapter 3 to put them in order for checking the user's input, but you
should display them in the order they're generated. You should make sure
you don't have any duplicates, generating new values to replace any duplicates.
It's easiest to check for duplicates after the list is sorted.
Get the number of seconds for an item by calling the time() function after the user gets an item correct and subtracting the value returned by time() after the previous item. Note that we're using time(), which gives the wall clock seconds, rather than times(), which gives the amount of CPU time used.
You can display the fifteen numbers in a list:
a) number 1
b) number 2
c) ...
or a 3 x 5 or 5 x 3 grid.