Matrix Rotations
You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.
Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction.
The angle of rotation(S) will always be in multiples of 90 degrees. Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.
After the update, all the previous rotation operations have to be applied to the updated initial matrix. Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A.
Input Next N lines contain N space-separated integers Aij Next lines contain various operations on the array.
Each operation on each line (Beginning either with R, U or Q). -1 will represent the end of input
Amend or edit given code PaySlip.java so that if the input file does not exist, the program handles the FileNotFoundException, outputs an appropriate message, and terminates normally.
Programming challenge/seatwork. Modify the program using the discussed sample program that will give the following output and use a function with parameter and no return type.
Use this to view the picture:
https://drive.google.com/file/d/1EG50edwQCKgXSWM8adkhe08w9gAWw2Sp/view?usp=sharing
Modify the codes of the given output that will use a function on sum using a function with return type and with parameter.
Use this to view the picture: https://drive.google.com/file/d/1dkhqu95SBESide89FVr9yMUO6x-M7vrm/view?usp=sharing
you answered like this:
def X_Only(Matrix:list):
for row in Matrix:
for cell in row:
# check if value is not X
if cell!='X':
return False
return True
def sub_size(lent:int):
for start in range(lent):
for stop in range(start+1, lent+1):
yield(start, stop)
def squareAreaWithX(matr:list, M:int, N:int):
maximum_area = 0
for begin_x, stop_x in sub_size(M):
for begin_y, stop_y in sub_size(N):
temp_matrix = [i[begin_y:stop_y] for i in matr[begin_x:stop_x]]
if X_Only(temp_matrix):
x= stop_x-begin_x
y= stop_y-begin_y
if maximum_area < x*y:
maximum_area=x*y
print(maximum_area)
while True:
s = input()
M, N = [int(i) for i in s.split()]
matrix = list([] for i in range(N))
for i in range(M):
matrix[i]=list(input().split())
squareAreaWithX(matrix, M, N)we are getting IndexError: list assignment index out of range error when input is:
8 6
X X X X X X
X X X X X X
X X X X X X
X X X X X X
X X X X X X
X X X X X X
X X X X X X
X X X X X X
Use composition of transformations to find the composite matrix to convert the
object With the points : (2,1), (4,1), (4,3), (2,3)
into the object with the points : ( -3,11), (-2,10), (2,14), (0,15)
Polynomial
Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0 format.Input
The first line contains a single integer N.
Next N lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes coefficient of Pi.Output
Print the polynomial in the format Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is coefficient, and C0 is constant. There will be space before and after the plus or minus sign.
If the coefficient is zero, then don't print the term.
If the term with the highest degree is negative, the term should represent -Cix^Pi.
For the term where power is 1, represent it as C1x instead of C1x^1.
If the polynomial degree is zero and the constant term is also zero, then print 0 to represent the polynomial.
For term Cix^Pi, if the coefficient of the term Ci is 1, print x^Pi instead of 1x^Pi.
Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0 format.
where Pi's are powers in decreasing order, Ci is coefficient, and C0 is constant. There will be space before and after the plus or minus sign.If the coefficient is zero, then don't print the term.
If the term with the highest degree is negative, the term should represent -Cix^Pi.
For the term where power is 1, represent it as C1x instead of C1x^1.
For term Cix^Pi, if the coefficient of the term Ci is 1, print x^Pi instead of 1x^Pi.
Explanation
If N = 4 If N = 5
For power 0, the coefficient is 5 For power 0, the coefficient is 2
For power 1, the coefficient is 0 For power 1, the coefficient is 3
For power 2, the coefficient is 10 For power 2, the coefficient is 2
For power 3, the coefficient is 6. For power 3, the coefficient is 6.
For power 4, the coefficient is 7.
polynomial represents "6x^3+10x^2+5" polynomial represents "7x^4+6x^3+x^2+3x+2"Write a program to check the overlapping of one string's suffix with the prefix of another string.Input
The first line of the input will contain a string A.
The second line of the input will contain a string B.Output
The output should contain overlapping word if present else print "No overlapping".Explanation
For example, if the given two strings, A and B, are "ramisgood" "goodforall"
The output should be "good" as good overlaps as a suffix of the first string and prefix of next.
input:
ramisgood
godforall
output:
good
input-2:
finally
restforall
output:
No overlapping