Given two polynomials A and B, write a program that adds the given two polynomials A and B.Input
The first line contains a single integer M. Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.After that next line contains a single integer N. Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.Output Print the addition of polynomials A and B. The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is co-efficient and C0 is constant, there will be space before and after the plus or minus sign. If co-efficient is zero then don't print the term. If the term with highest degree is negative, the term should be represented as -Cix^Pi. For the term where power is 1 represent it as C1x instead of C1x^1.
Given a string, write a program to print a secret message that replaces characters with numbers 'a' with 1, 'b' with 2, ..., 'z' with 26 where characters are separated by '-'.
Note: You need to replace both uppercase and lowercase characters. You can ignore replacing all characters that are not letters.
abcdefghij12345678910
klmnopqr1112131415161718
stuvwxyz1920212223242526Input
The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).Output
The output should be a single line containing the secret message. All characters in the output should be in lower case.Explanation
For example, if the given input is "python", "p" should replaced with "16", similarly"y" with "25","t" with "20","h" with "8","o" with "15","n" with "14". So the output should be "16-25-20-8-15-14".
Given a string, write a program to mirror the characters of the string in alphabetical order to create a secret message.
Note: Mirroring the characters in alphabetical order replacing the letters 'a' with 'z', 'b' with 'y', ... , 'z' with 'a'. You need to mirror both uppercase and lowercase characters. You can ignore mirroring for all characters that are not letters.
abcdefghijklmzyxwvutsrqpon nopqrstuvwxyzmlkjihgfedcbaInput
The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).Output
The output should be a single line containing the secret message. All characters in the output should be in lower case.
Explanation
For example, if the given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So the output should be "kbgslm".
Given a list of numbers, write a program to print the smallest positive integer missing in the given numbers.Input
The input will be a single line containing numbers separated by space.Output
The output should be a single line containing the smallest missing number from given numbers.Explanation
For example, if the input numbers are 3, 1, 2, 5, 3, 7, 7.
The number 1, 2, 3 are present. But the number 4 is not. So 4 is the smallest positive integers that is missing from the given numbers.
Sample Input 1
3 1 2 5 3 7 7
Sample Output 1
4
Sample Input 2
5 5 2 3 1 8 8 4
Sample Output 2
6
Remove Words
Given a string, write a program to remove all the words with K length.Input
The first line of the input will contain a string A.
The second line of the input will contain an integer K.Output
The output should contain a string after removing all the words whose length is equal to K.Explanation
For example, string A is "Tea is good for you", k is 3 then output should be "is good."
Here words "Tea", "for", "you" length is equal to 3, so these words are removed from string.
Sample Input 1
Tea is good for you
3
Sample Output 1
is good
Sample Input 2
A gang stood in front of me
2
Sample Output 2
A gang stood front
Prefix Suffix
Write a program to check the overlapping of one string's suffix with the prefix of another string.Input
The first line of the input will contain a string A.
The second line of the input will contain a string B.Output
The output should contain overlapping word if present else print "No overlapping".Explanation
For example, if the given two strings, A and B, are "ramisgood" "goodforall"
The output should be "good" as good overlaps as a suffix of the first string and prefix of next.
Sample Input 1
ramisgood
goodforall
Sample Output 1
good
Sample Input 2
finally
restforall
Sample Output 2
No overlapping
Hollow Diamond
Given the number of rows N, write a program to print the hallow diamond pattern similar to the pattern shown below.
A
B B
C C
D D
E E
D D
C C
B B
AThe input will be a single line containing a positive integer (N).Output
The output should be (2*N - 1) rows and (2*N - 1) columns containing the alphabet characters in the hollow diamond pattern.Explanation
For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.
A
B B
C C
D D
E E
D D
C C
B B
Anote:left side spaces shouldnt be..
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the teams based on the outcome of the match.
A win earns a team 3 points. A draw earns 1. A loss earns 0.
The following information is expected:
MP: Matches Played
W: Matches Won
D: Matches Drawn (Tied)
L: Matches Lost
P: Points
The team information should be displayed in descending order of points.Input
The first line contains a single integer N, denoting the total no. of matches played.
The following N lines contain outcomes of N matches.
Each of those lines has information on the teams (T1, T2) which played and the outcome (O) in format T1;T2;O.
The outcome (O) is one of 'win', 'loss', 'draw' and refers to the first team listed.
See Sample Input/Output for better understanding.
The team name may contain spaces.Output
For term Cix^Pi, if the coefficient of the term Ci is 1, print x^Pi instead of 1x^Pi.this condititon is not giving result for this code?
This input should be a valid integer and must be between 1 and 15 only. If the user enters invalid input, the default level is Level 10. How would I code this?