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

Sum of Non-Diagonals

Write a program to print the following,


Sample Input1

3

9 8 7

6 5 4

3 2 1

Sample Output1

20


Cards Game

Write a program to print the following,


Input

The only line of input contains three space separated integers M,N and Z.


Output

Print the number representing the person who will get the last card.


Explanation

Given M=3, N=3, and Z=2.

Distribution of cards starts from 2.The final order of persons is 2,3,1.

The last person to get the card is 1.


Sample Input1

3 3 2

Sample Output1

1



Difficult Addition


Arjun is trying to add two numbers. Since he has learned addition recently, an addition which requires a carry is difficult for him. Your task is to print Easy if the addition does not involve a carry, Otherwise print Hard.


Input

The first line of input contains two space separated integers A and B.


Output

If the addition does not involve a carry,print Easy, otherwise print Hard.


Explanation

When calculating 229 + 390, we have a carry from the tens digit to the hundreds digit, so the answer is Hard.


Sample Input1

229 390

Sample Output1

Hard


Sample Input2

123456789 9876543218

Sample Output2

Easy



Number Game


A group of people are playing a game.They are standing and each carring a card with a number on it.These numbers in the list A. A random number S is selected.


Find out the new list of numbers after

  • S people were removed from the left.
  • S people were removed from the right.


Sample Input1

1,2,3

1

Sample Output1

2 3

1 2


Math Quiz


Write a program to print the following,


Sample Input 1

1 3 4 5 6

5

3 5

Sample Output1

12


String Concatenation


Disha has three strings A, B, and C consisting of lowercase letters.She also has a string T consisting only of characters 1, 2 and 3.

She wants to concatenate the three strings according to the characters in T.

Your task is to print the final output string.


Note: Formally, follow the below instructions:

* For each integer i such that 1<=i<=|T|, let the string si be defined as follows:

  • A if Ti = 1.
  • B if Ti = 2.
  • C if Ti = 3.

*Concatenate the strings s1,s2,...,s|T| in this order and print the resulting string.


Sample Input1

mari

to

zzo

1321


Sample Output1

marizzotomari


Find the Password

Joey is playing escape room and to exit the room he has to find the password for the final door.To know the password he is given a sentence G and told to rearrange the sentence by rotating its W words in the right.Can you help joey find the password?


Input

The first line of input is a string G.

The second line of input is an integer W.


Output

The output is a string contains a sentence got by the rearrangement as per above mentioned criteria.


Explanation

In the above example, the sentence is Raju is going to school and W is 3.

Shift the three words in the right,which means the last three words will be moved to the front.

So, the output should be going to school Raju is


Sample Input1

Raju is going to school

3

Sample Output1

going to school Raju is


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



Armstrong numbers between two intervals



Write a program to print all the Armstrong numbers in the given range



A to B(including A and B). An N-digit number is an Armstrong number if the number equals the sum of the Nth power of its digits.



Input



The first line has an integer



A. The second line has an integer B.



Output



Print all Armstrong numbers separated by a space.


If there are no Armstrong numbers in the given range, print



-1.



Explanation



For



A = 150 and B = 200



For example, if we take number 153, the sum of the cube of digits



1, 5, 3 is



13 + 53 + 33 = 153.



So, the output should be



153.



Sample Input 1


150


200


Sample Output 1


153


Sample Input 2


1


3


Sample Output 2


1 2 3


Sample output 3


200


Sample input 3


-1

Pyramids Frequency

These are N pyramids in a line.You are given their heights as space-separated integers.Write a program to print the heights of the pyramids in increasing order along with their frequency.


Input

The first line of input contains space-separated integers.


Output

Each line of output should contain the height of the pyramid and its frequency in the ascending order of the pyramid's height.


Explanation

In the example, The given pyramid heights are 1,5,1,2,5,6.

The frequency of each unique pyramid height is

1 2

2 1

5 2

6 1


Sample Input1

1 5 1 2 5 6

Sample Output1

1 2

2 1

5 2

6 1