Stale Ingredients
Yasoda went to a store to buy Ingredients to make a boul of soup.While billing the order,salesperson found that some ingredients are stale.So, he wants to separate the stale ingredients from the rest.You are given the prices of the ingredients,where a negative price value indicates a stale ingredient.Write a program to help the sales person to move the prices of all the stale ingredients to left without changing the relative order of the ingredients.
Input
The first line of input contains space-separated integers.
Explanation
In the example, there are 6 ingredients with prices 11,-12,13,-14,15,16 respectively.
The prices of the stale ingredients in the given list are -12 and -14 in the order of occurence.
So, the output is -12 -14 11 13 15 16.
Sample Input1
11 -12 13 -14 15 16
Sample Output1
-12 -14 11 13 15 16
Sample Input2
21 11 -3 -2 9
Sample Output2
-3 -2 21 11 9
Write a python program to design a class representing complex numbers and having the functionality of performing addition & multiplication of two complex numbers using operator overloading
Highest Sum of Scores
The students in the class were divided into groups of three.Each student was given a T-shirt for a game.Later they were asked to calculate the score of their group by adding the jersey numbers on the T-shirt of every member.Find the group with the highest scores and print the jersey numbers on the T-shirts of every group member.
Input
The first line of the input contains an integer N that denotes the number of groups.
The next N lines of input contains the scores of students in the group separated by comma.
Output
The output contains the scores of the students of the group with maximum sum separated by space.
Explanation
Given the input lists are [[0,1,2],[3,1,0]].
The sum of the scores is highest in the group[3,1,0] i.e., 4.So the output should be 3 1 0.
Sample Input1
2
0,1,2
3,1,0
Sample Output1
3 1 0
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
You are given space separated integers as input.
Write the program to print the maximum number among the given numbers
Algorithm,flow chart and pseudocode for sequence of comma separated numbers
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 . .
What the code in python
Find perimeter of a matrix without using numpy
Input1:
1 2 3
4 5 6
7 8 9
Output: 40
Input2:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Output: 102
Write a python program that prints a rectangle of size M (height/line numbers) and N (length/column numbers) using incrementing numbers where M and N will be given as input. Please look at the examples below for clarification.
Hint: You may need to use nested loops and print the loop counter variable in one of the loops.
==========================================================
Sample Input 1:
4
6
Sample Output 1:
123456
123456
123456
123456