Write a program for first and last digits
Write a program for elements of anti diagonal
Write a program for interleave strings
Write a program to print max contiguous subarray
Write a program to print the sum of all prime numbers in the list of integers
Write a program for mean,median,mode
A Pythagorean triplet is a set of three integers a, b, and c such that a2+ b2 = c2. In the given limit L, find the number of Pythagorean triplets R that can be formed (such that a < b < c).
For
L = 20, Pythagorean triples satisfying the condition a < b < c are (3, 4, 5), (6, 8, 10), (5, 12, 13), (9, 12, 15), (8, 15, 17), (12, 16, 20).Hence the output should be
6.
Rearrange Numbers in String
Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part.
Input
The input will be a single line containing a string.
Output
The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order.
Explanation
For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".
Sample Input
I am 5 years and 11 months old
Sample Output
I am 11 years and 5 months old
Vowel Sound
Given a sentence, write a program rotate all the words left, so that every word starts with a vowel.
Note: If there is no vowel in the word, do not rotate it.
Input
The input will be a single line containing a string.
Output
The output should be a single line containing the modified sentence with rotated words.
Explanation
For example, if the given string is "I saw a DRAGON flying in the sky", rotating each word towards left in this way "I aws a AGONDR and ingfly in eth sky", makes every word start with a vowel letter. The word "sky" is not rotated as it does not have any vowel in it. The words "I", "a", "and", "in" are not rotated as they already start with a vowel.
Sample Input
I saw a DRAGON flying in the sky
Sample Output
I aws a AGONDR ingfly in eth sky