1- Method to return elements of the matrix in spiral order.
2- Using TCL programming Language, write a TCL script to solve the following:
-
A TCL script that reads a file on the filesystem ( input.txt ), the script should process each line using the below rules:
-
lines start with string characters, print the line as is without any changes.
-
lines that present a Prime integer value, divide the value with 2 and print it.
-
lines that present an Non Prime integer value, multiply the value with 3.25 and print it.
-
after printing all lines, print a small report with a number of lines that are found to be containing string, Prime number, non Prime number, or invalid.
-
print the summation of the first 2 integer values occurring in the file.
-
print the concatenation of the first 3 lines starting with the string characters.
-
print all lines with the length of each line.
-
print a line with maximum integer value found in the file, and the minimum length of "non-empty string" in the whole file.
-
Rules:
- Consider floats as a string.
- Any line that doesn't apply to any previous rule, print "INVALID LINE" message.
- You must run your code in a TCL interpreter, you should deliver a running and a "syntax errors" free script.
3- Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h,k), where h is the height of the person and k is the number of people in front of this person who has a height greater than or equal to h. Write an algorithm to reconstruct the queue.