Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Trapezium Order

You are given an integer

N. Print N rows starting from 1 in the trapezium order as shown in the output of the below examples.Input

The input contains an integer

N.Output

The output should have

N lines. Each of the N lines should have space-separated integers as per the trapezium order.


      


The output should contain N space-separated integers representing the number of people who played after the person and scored less than the person.

def smaller_scores(L:list, N:int):

s = [0 for i in range(N)]

for i in range(N-1):

for j in range(i+1,N):

if L[i] > L[j]:

s[i] += 1

print(*s)

while True:

try:

N = int(input())

L = list(map(int,input().split()))

if len(L) != N:

raise ValueError

except ValueError:

print('incorect input, try again')

continue

smaller_scores(L,N)


The above program throws an error:

  N = int(input())

EOFError: EOF when reading a line

COuld you please help me to get an expected output?


Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.
Consider two classes to store the names of people. Class NAME will store the name in upper case and Class name will store in lower case. Write a program to convert the uppercase name to a lowercase name.

Consider two classes to store the names of people. Class NAME will store the name in upper case and Class name will store in lower case. Write a program to convert the uppercase name to a lowercase name. 


Area of Rectangle
Given an MxN matrix filled with 
X's and O's, find the largest rectangle containing only X's and return its area. If there are no Xs in the entire matrix print 0.
Input
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.
Output
The output should be a single line containing the area of the maximum rectangle.
Explanation
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
Rotate Words In Sentence

Given a sentence and an integer N, write a program to rotate letters of the sentence among the words without changing the length of those words and positions of the spaces.

Input

The first line of input will be a sentence.
The second line of input will be an integer N.

Output

The output should be a single line containing the sentence by rotating the letters among the words without changing the length of the words and positions of the spaces.

Explanation

For example, if the given sentence and N are

Welcome to your first problem
5

Rotate the sentence 5 letters towards right side without changing the length of the words and position of spaces in the original sentence.
So the output should be

oblemWe lc omet oyour firstpr
Sample Input 1
Welcome to your first problem
5
Sample Output 1
oblemWe lc omet oyour firstpr

Sample Input 2
All the best
2
Sample Output 2
stA llt hebe


Concatenate Word Pairs
Given a sentence and an integer L, write a program to concatenate word pairs so that the concatenated word has the length L.
Input
The first line of input will be a sentence.
The second line of input will be an integer L.
Output
The output should be containing the unique concatenated word pairs each in a line in the lexicographical order.
Explanation
For example, if the given sentence and L are
Welcome to your exam
6
The words which can be paired so that they make concatenated word with length 6 are
Word1	Word2
to	your
to	exam
exam	to
your	to
So the output should be printing each concatenated word in a line in the lexicographical order
examto
toexam
toyour
yourto
Sample Input 1
Welcome to your exam
6
Sample Output 1
examto
toexam
toyour
yourto

Sample Input 2
My parents and I went to a movie
9
Sample Output 2
Myparents
moviewent
parentsMy
parentsto
toparents
wentmovie
Balanced Brackets

You are given an expression string S which contains expressions that are made of bracket characters {, }, (, ), [, ]. Each expression in the string is separated by space.
Two brackets are considered to be a matched pair if an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matched pairs of brackets: [], {}, and ().
A matching pair of brackets is not balanced if the set of brackets it encloses are not matched. For example, 
{[(])} is not balanced because the contents in between { and } are not balanced. The pair of square brackets enclose a single, unbalanced opening bracket, (, and the pair of brackets enclose a single, unbalanced closing square bracket, ].
Write a program to examine whether each expression in 
S is balanced.
Input
The first line contains a string S with space-separated bracket expressions.
Sample Input 1
{()} ({}
Sample Output 1
YES
NO
Sample Input 2
{}[] [({})] {}
Sample Output 2
YES
YES
YES
Smaller Scores
A group of people(P) are playing an online game. Their scores are stored in the order of their entry time in S. Each integer S[i] corresponds to the score of the person Pi.
For each person 
Pi you have to report the number of people who played after the person and scored less than the person.
Input
The first line contains a single integer 
N. The second line contains N space-separated integers representing the score S[i] of person Pi.
Output
The output should contain 
N space-separated integers representing the number of people who played after the person and scored less than the person.
Explanation
Given 
S = 13 12 11
Score 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
LATEST TUTORIALS
APPROVED BY CLIENTS