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

how to sort the m*n matrix elements in ascending order


Product of Elements in the List

You are given a space-separated list of integers as input. Write a program to print the product of these numbers.

Input

The first line of input contains space-separated integers.

Explanation

In the example, there are

6 numbers, 1, 2, 3, 4, 5, 6.The product of list elements is

1 x 2 x 3 x 4 x 5 x 6 So, the output should be 720.

Sample Input :

1 11 13 21 19

Sample Output:

57057


Average of Given Numbers

You are given space-separated integers as input. Write a program to print the average of the given numbers.

Input

The first line of input contains space-separated integers.

Output

The output should be a float value rounded up to two decimal places.

Explanation

In the example, input is

1, 0, 2, 5, 9, 8. The sum of all numbers present in the list is 25, and their average is 25/6.So, the output should be

4.17.


First Prime Number

You are given 

N inputs. Write a program to print the first prime number in the given inputs.

Input

The first line of input is an integer 

N. The next N lines each contain an integer.

Explanation

In the given example of 

5 integers

1 
10 
4
3
2

The output should be 

3.

Sample Input 1
5
1
10
4
3
2
Sample Output 1
3
Sample Input 2
4
2
3
5
7
Sample Output 2
2

Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.Input


The first line of input will contain two space-separated integers, denoting the M and N.

The next M following lines will contain N space-separated integers, denoting the elements of each list.Output


The output should be M lines containing the ordered matrix.

Note: There is a space at the end of each line.Explanation


For example, if the given M is 3 and N is 3, read the inputs in the next three lines if the numbers given in the next three lines are the following.

1 20 3
30 10 2
5 11 15


By ordering all the elements of the matrix in increasing order, the ordered matrix should be

1 2 3
5 10 11
15 20 30

Sample Input 1

3 3
1 20 3
30 10 2
5 11 15

sample out:

1 2 3 
5 10 11 
15 20 30 

INPUT 2

2 5
-50 20 3 25 -20
88 17 38 72 -10

sample output 2

-50 -20 -10 3 17 
20 25 38 72 88 





Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.

Input


The input will be a single line containing a string.

Output


The output should contain the sum and average of the numbers that appear in the string.



 Note: Round the average value to two decimal places.


Explanation

For example, if the given string is "I am 25 years and 10 months old", 

the numbers are 25, 10. Your code should print the sum of the numbers(35)

and the average of the numbers(17.5) in the new line.

Sample Input 1

I am 25 years and 10 months old

output:

35

17.5

sample Input 2

Lear4 python7

output:

11

5.5

sample Input 3

Anjali25 is python4 Expert

output:

29

14.5 



Acronyms

You are given some abbreviations as input. Write a program to print the acronyms separated by a dot(

.) of those abbreviations.

Input

The first line of input contains space-separated strings.

Explanation

Consider the given abbreviation, 

Indian Administrative Service. We need to consider the first character in each of the words to get the acronym. We get the letter I from the first string Indian, we get the letter A from the second word Administrative, and we get the letter S from the third word Service. So, the final output should be I.A.S.

Sample Input 1
Indian Administrative Service
Sample Output 1
I.A.S
Sample Input 2
Very Important Person
Sample Output 2
V.I.P

Replacing Characters of Sentence

You are given a string 

S. Write a program to replace each letter of the string with the next letter that comes in the English alphabet.

Note: Ensure that while replacing the letters, uppercase should be replaced with uppercase letters, and lowercase should be replaced with lowercase letters.

Input

The first line of input is a string.

Explanation

In the given example, 

Hello World.

If we replace each letter with the letter that comes next in the English alphabet, 

H becomes I, e becomes f and so on ... So, the output should be Ifmmp Xpsme.

Sample Input 1
Hello World
Sample Output 1
Ifmmp Xpsme
Sample Input 2
Something is better than Nothing
Sample Output 2
Tpnfuijoh jt cfuufs uibo Opuijoh

Roots of a quadratic equation

You are given cofficients 

a, b and c of a quadratic equation ax2 + bx + c = 0. Find the roots r1, r2 of the equation.

Note: 

r1 and r2 should be rounded upto 2 decimal places.

Input

The first line of input is an integer 

a. The second line of input is an integer b. The third line of input is an integer c.

Explanation

In the given example, a = 1, b = -5, c = 6. Then the equation is x2 - 5x + 6 = 0

r1 = (-b + (b^2 - 4*a*c)^0.5)/2*a 
r1 = (5 + (25 - 24))/2
r1 = 3
 

and 

r2 = (-b - (b^2 - 4*a*c)^0.5)/2*a
r2 = (5 - (25 - 24))/2
r2 = 2
 

So, the output should be 

3
2
Sample Input 1
1
-5
6
Sample Output 1
3.0
2.0
Sample Input 2
-1
1
6
Sample Output 2
-2.0
3.0

Diamond

Given an integer value 

N, write a program to print a number diamond of 2*N -1 rows as shown below.

Input

The first line of input is an integer 

N.

Explanation

In the given example, the number of rows in the diamond is 

5.

So, the output should be

. . . . 0 . . . . 
. . . 0 0 0 . . . 
. . 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0
. 0 0 0 0 0 0 0 . 
. . 0 0 0 0 0 . . 
. . . 0 0 0 . . . 
. . . . 0 . . . .
Sample Input 1
5
Sample Output 1
. . . . 0 . . . . 
. . . 0 0 0 . . . 
. . 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0 
. 0 0 0 0 0 0 0 . 
. . 0 0 0 0 0 . . 
. . . 0 0 0 . . . 
. . . . 0 . . . .
Sample Input 2
4
Sample Output 2
. . . 0 . . . 
. . 0 0 0 . . 
. 0 0 0 0 0 . 
0 0 0 0 0 0 0 
. 0 0 0 0 0 . 
. . 0 0 0 . . 
. . . 0 . . .

LATEST TUTORIALS
APPROVED BY CLIENTS