Write a program to input amount and display its annotations.
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
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
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
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.
Sample Input 1
ramisgood
goodforall
Sample Output 1
good
Sample Input 2
finally
restforall
Sample Output 2
No overlapping
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.
Sample Input:1 Sample Input2:
5 4
0 2 0 5
1 3 1 0
2 1 2 10
4 7 3 6
3 6
Output: Output: 6x^3 +10x^2+5
7x^4 + 6x^3 + x^2 + 3x + 2Given two polynomials A and B, write a program that adds the given two polynomials A and B.Input
The first line contains a single integer M.
Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.
After that next line contains a single integer N.
Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.Output
Print the addition of polynomials A and B.
The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is co-efficient and C0 is constant, there will be space before and after the plus or minus sign.
If co-efficient is zero then don't print the term.
If the term with highest degree is negative, the term should be represented as -Cix^Pi.
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.Explana
"6x^3 + 10x^2 + 5"Constraints
N <= 100
0 <= Pi < 1000
-1000 <= Ci <= 1000