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

Minimal Absolute Difference

There are N pyramids in a line.You are given their heights as a list of integers.Write a program to find the minimum absolute difference between the heights of any two different pyramids.


Input

The input is a single line containing space-separated integers.


Output

The output should be a single line containing the minimum absolute difference of any two different pyramid heights.


Explaanation

Given Pyramid heights are 7 1 5.

The absolute difference between the heights of any two different pyramids are



Matrix Triangle Sum

You are given a square matrix of size NxN, write a program to print the sum of upper and lower triangular elements.

Upper triangle consists of elements on the anti-diagonal and above it. The lower triangle consists of elements on the anti-diagonal and below it.


Explanation:

In the example,if the given matrix is

1 2 3

4 5 6

7 8 9

The upper triangle consists of elements on the anti-diagonal and above on it.

1 2 3

4 5

7

The sum of upper triangle elements is (1+2+3+4+5+7) equal to 22.


The lower triangle consists of elements on the anti-diagonal and below to it.

3

5 6

7 8 9

The sum of lower triangle elements is (3+5+6+7+8+9) equal to 38.

So the output should be

22

38


Sample Input

3 3

1 2 3

4 5 6

7 8 9


Unique Matrix

You are given a N*N matrix. write a program to check if the matrix is unique or not. A unique Matrix is a matrix if every row and column of the matrix contains all the integers from 1 to N


Input:

The first line contains an integer N.

The next N lines contains N space separated values of the matrix.


Output:

The output contains a single line and should be True if the matrix is unique matrix and False otherwise.


Sample Input1

4

1 2 3 4

2 3 4 1

3 4 1 2

4 1 2 3

Sample Output1

True


Sample Input2

4

1 2 3 3

2 3 4 1

3 4 1 2

4 1 2 3

Sample Output2

False



Minimal Absolute Difference

There are N pyramids in a line.You are given their heights as a list of integers.Write a program to find the minimum absolute difference between the heights of any two different pyramids.


Input

The input is a single line containing space-separated integers.


Output

The output should be a single line containing the minimum absolute difference of any two different pyramid heights.


Explaanation

Given Pyramid heights are 7 1 5.

The absolute difference between the heights of any two different pyramids are



you are given an m*n matrix.write a program to compute the perimeter of the matrix and print the result.perimeter of a matrix is defined as the sum of all elements of the four edges of the matrix



m = no of rows



n = no of columns



Ex: [1 2 3 4



5 6 7 8



9 10 11 12]



Perimeter : 1+2+3+4+8+12+11+10+9+5 = 65



Note: take input from the user.

A group of people playing a game They are standing in a line each carrying a card with a number on it. this numbers or given in the list A. A random number S is selected


Product of the String

You are given an alphanumeric string S.Write a program to multiply all the charcters(except trailing zeroes) in S and print the output.


Rules for multiplication:

  • If the character is digit, multiply its value.
  • If the character is an alphabetic character, multiply the product of digits of its ASCII value.

Input

The first line contains a string S.


Output

The output should be a integer denoting the product of characters.


Explanation

For N = 123a4

ASCII value of a is 97.

Product of digits of ASCII value of a is 9 *7 = 63.

Therefore the product of characters is 1*2*3*4*63*4 = 1512.


Sample Input1

123a4

Sample Output1

1512



Product of the String

You are given an alphanumeric string S.Write a program to multiply all the charcters(except trailing zeroes) in S and print the output.


Rules for multiplication:

  • If the character is digit, multiply its value.
  • If the character is an alphabetic character, multiply the product of digits of its ASCII value.


Input

The first line contains a string S.


Output

The output should be a integer denoting the product of characters.


Explanation

For N = 123a4


ASCII value of a is 97.

Product of digits of ASCII value of a is 9 *7 = 63.

Therefore the product of characters is 1*2*3*4*63*4 = 1512.


Sample Input1

123a4

Sample Output1

1512


Product of the String

You are given an alphanumeric string S.Write a program to multiply all the charcters(except trailing zeroes) in S and print the output.


Rules for multiplication:

  • If the character is digit, multiply its value.
  • If the character is an alphabetic character, multiply the product of digits of its ASCII value.

Input

The first line contains a string S.


Output

The output should be a integer denoting the product of characters.


Explanation

For N = 123a4


ASCII value of a is 97.

Product of digits of ASCII value of a is 9 *7 = 63.

Therefore the product of characters is 1*2*3*4*63*4 = 1512.


Sample Input1

123a4

Sample Output1

1512



First and last digit



Input


5


30

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS