Rotate Matrix Rings
Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring
M, N = input().split()
M, N = int(M), int(N)
matrix = []
for _ in range(M):
row = [int(x) for x in input().split()]
matrix.append(row)
K = int(input())
values = matrix[0][:-1] + [x[-1] for x in matrix][:-1] + matrix[-1][::-1][:-1] + [x[0] for x in matrix][::-1][:-1]
values = values[-K:] + values[:-K]
output = matrix
idxs = [(0, j) for j in range(N)][:-1] + [(i, N - 1) for i in range(M)][:-1] + [(M - 1, j) for j in range(N)][::-1][:-1] + [(i, 0) for i in range(M)][::-1][:-1]
idx = 0
for i, j in idxs:
output[i][j] = values[idx]
idx += 1
for i in output:
pass
print(i)Input:
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3
Output:
[13, 9, 5, 1]
[14, 6, 7, 2]
[15, 10, 11, 3]
[16, 12, 8, 4]
Here the inner ring is not rotating the given times sir
Write a function even_int that consumes an integer and produces "Even" if it is even and
"Odd" otherwise. You should use if and else for the two cases.
Write a function greeting that consumes a string of length at least three and produces "Hello"
if the first three characters are "Hi!" and produces "Bye" otherwise.
Write a function bigger that consumes two numbers and produces the maximum of the two numbers.
Area of Square
Given an MxN matrix filled with
The first line of input will be containing two space-separated integers, denoting M and N.
The next M lines will contain N space-separated integers, denoting the elements of the matrix.
The output should be a single line containing the area of the maximum square.
For example, if the given M, N and elements of matrix are as the following
4 5
X O X O O
X O X X X
X X O X X
X O O X O
The matrix from indices (1, 3) to (2, 4) has the maximum square with
X. So the output should be the area of the maximum rectangle with X, which is 4.
Sample Input 1
4 5
X O X O O
X O X X X
X X O X X
X O O X O
Sample Output 1
4
Sample Input 2
3 3
O X X
O X X
O O O
Sample Output 2
4
Number to English Words
Write a program to convert a non-negative integer
The input will be a single line containing an integer
The output should be a single line containing the representation of the English words of number
For example, if the given number is 123, your code should print the English words representation, which is
One Hundred Twenty Three
Sample Input 1
123
Sample Output 1
One Hundred Twenty Three
Sample Input 2
10005
Sample Output 2
Ten Thousand Five
Sample Input 3
1234567891
Sample Output 3
One Billion Two Hundred Thirty Four Million Five Hundred Sixty Seven Thousand Eight Hundred Ninety One
for this question you have answered like:
but we are getting "ModuleNotFoundError: No module named 'num2words'"
import num2words
print(num2words.num2words(input()))Area of Rectangle
Given an MxN matrix filled with
The first line of input will be containing two space-separated integers, denoting M and N.
The next M lines will contain N space-separated integers, denoting the elements of the matrix.
The output should be a single line containing the area of the maximum rectangle.
For example, if the given M, N and elements of matrix are as the following
4 5
X O X O O
X O X X X
X X X X X
X O O X O
The matrix from indices (1, 2) to (2, 4) has the maximum rectangle with
X. So the output should be the area of the maximum rectangle with X, which is 6.
Sample Input 1
4 5
X O X O O
X O X X X
X X X X X
X O O X O
Sample Output 1
6
Sample Input 2
3 3
O X X
O X X
O O O
Sample Output 2
4
Smaller Scores
A group of people(
P) are playing an online game. Their scores are stored in order of their entry time in S. Each integer S[i] corresponds to score of person Pi.For each person
The first line contains a single integer
Output should contain
Given
S = 13 12 11Score of
P1 is 13. Score of P2 is 12. Score of P3 is 11.The number of people who played after
P1 and scored less than 13 is 2(12, 11). The number of people who played after P2 and scored less than 12 is 1(11). The number of people who played after P3 and scored less than 11 is 0.The output is
2 1 0.
Sample Input 1
3
13 12 11
Sample Output 1
2 1 0
Sample Input 2
4
4 3 5 2
Sample Output 2
2 1 1 0
# Write a function good_string that consumes a string, produces True if the first character is a
# letter and the second character is either a digit or a blank space and produces False
# otherwise
I would like to seek for experts' help on solving this project question. I've done some of the parts, but I can't solve the minimum heap on delivery date and time. Your help is greatly appreciated and thank you in advance for helping out
Link to the project:
PS: Copy and paste will do, thank you very much
https://docs.google.com/document/d/1zZZlzGsFPKeJRhi7CbEzmtpOr_SZwUHqJdzauReK1Qk/edit?usp=sharing