You're decorating a room with balloons for your friend's birthday party. There are balloons of K different colors, and you have access to infinite amount of balloons of any color. You want to arrange N balloons in a row, with the only condition that no two adjacent balloons can be of the same color, because your friend will dislike it.
How many ways are there to arrange the balloons?
Since the answer can be very large, print it modulo 10^9+7.
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
Max Profit
You given a list of prices where prices[i] is the price of a given stock o the i th day write a program to print the maximum profit by choosing a single day to buy a stock and choosing a different day in the future to sell that stock if these is no profit that can be achieved return 0.
Input
The input is a single line containing space seperated integers.
Output
The output should be a single line integer.
Explanation
In the example the given prices are 7 1 5 3 6 4.
buying stocks on day two having price 1 and selling them on the fifth day having price 6 would give the maximum profit which is 6 - 1
so the output should be 5.
Sample Input1
1 2 1 3 6 7 4
Sample Output1
6
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.
Input
The first line of input containing the positive integer.
The second line of input containing the positive integer.
The next N lines of input space-separated integers.
Explanation
The input should be
3
4
1 2 3 4
5 6 7 8
9 10 11 12
The output should be 1+2+3+4+8+12+11+10+9+5 = 65
Sample Input1
3
4
1 2 3 4
5 6 7 8
9 10 11 12
Sample Output1
65
Write a program to print a parallelogram pattern with * characters. The size N represents the length (the number of * characters in each line)& breadth ( the number of lines) of the parallelogram.
The slope of the parallelogram T represents the number of extra spaces a line should have in the beginning compared to its next line. The last line of the pattern does not have any spaces in the beginning.
Explanation:
Given N=3 and T=2
Each line should have 3 star(*) characters.
The last line should have 0 spaces at the beginning.
Each line has 2 extra spaces characters when compared to its next line.
Sample Input1
2
2
Sample Output1
**
**
Sample Input2
3
2
Sample Output2
***
***
***
Akshya is given a list of N integers. Each number in the list appears exactly for one number. help akshya by identifying the numbers which appeared exactly once in the list.
Input
The input contains a single-line comma-separated integers.
Output
The output contains a single-line comma-separated integers.
Sample Input1
8,9,5,8,5,6
Sample Output1
9,6
Sample Input2
1,2,3,4,5,1,2,3,4
Sample Output2
5
Andy has the word W and he wants to print the unique characters in the word in the order of their occurrence.write a program to help Andy print the unique characters as described above.
NOTE : consider lower and upper case letters as different
Input
The input is a single line containing the word W.
Output
The output should be a single line containing space separated characters.
Explanation
In the example, the word is MATHEMATICS
The unique characters in the given word are M, A, T, H, E, I, C, S, in the order of occurrence.so the output should be M A T H E I C S.
Sample Input1
MATHEMATICS
Sample Output1
M A T H E I C S
Sample Input2
banana
Sample Output2
b a n
Write a Python program that asks the user to enter a series of 20 numbers. The program should store the numbers in a list. It should have the following functions:
The program should call the functions mentioned above and display the lowest, highest and total values in the list. It should also calculate and display the average of the numbers in the list
def mystery1(x):
return x + 2
def mystery2(a, b = 7):
return a + b
#MAIN
n = int(input("Enter a number:"))
ans = mystery1(n) * 2 + mystery2 (n * 3)
print(ans)
What is output when the user enters 3?
Write a program to accept an integer amount from user and tell minimum number of notes needed for representing that amount.