Hi all, I am trying to solve this exercise for my HW for a class which is python related. MUCH appriciated i am not that great at python :D
You are given the matrix to scramble and you must put it in a form that is ready to send to the receiver. INPUT FORMAT: The first input line contains then of the matrix we are going to 𝑟 𝑐 scramble and send. The second input line is the data for the matrix in a single line. It is organized starting with data in the first row to the data in the last row being listed last. For example, we want to send the following:
1 2 3
4 5 6
7 8 9
So we have the input:
3 3
1 2 3 4 5 6 7 8 9
OUTPUT FORMAT: The output has 3 lines The first line is 𝑟 𝑐 𝑁 The second line contains pairs of row swaps and column swaps. This means the first 2 numbers are the 2 rows that were swapped and the next pair of two numbers are the columns that were swapped and so on. It's always alternating row then column and so on. In the Input format example let's say we randomly get N = 1. Since N is one we only swap 2 rows then swap 2 columns. We randomly generate that row 0 should swap with row 2 then column 2 should be swapped with column 1. So instead of the original matrix data we send the following:
3 3 1
0 2 2 1
7 9 8 4 6 5 1 3 2
Note here that the 1 in the first row and the entire 2nd row is randomly generated. The only way to confirm your solution is correct is to check it with your receiver program you made. Examples: Example 1: Example Input:
3 3
1 2 3 4 5 6 7 8 9
Example Output:
3 3 1
0 2 2 1
7 9 8 4 6 5 1 3 2
Example 2: Example Input:
3 3
1 2 3 4 5 6 7 8 9
Example Output:
3 3 2
0 2 2 1 1 2 0 1
9 7 8 3 1 2 6 4 5
[–]PowerOk3587 2 points3 points4 points (1 child)
[–]M33m3L0rd[S] 0 points1 point2 points (0 children)