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

Concatenate Word Pairs

Given a sentence and an integer L, write a program to concatenate word pairs so that the concatenated word has the length L.

Input

The first line of input will be a sentence.

The second line of input will be an integer L.

Output

The output should be containing the unique concatenated word pairs each in a line in the lexicographical order.

Explanation

For example, if the given sentence and L are


Welcome to your exam

6


The words which can be paired so that they make concatenated word with length 6 are

Word1Word2toyourtoexamexamtoyourto

So the output should be printing each concatenated word in a line in the lexicographical order


examto

toexam

toyour

yourto


Sample Input 1

Welcome to your exam

6

Sample Output 1

examto

toexam

toyour

yourto




Reverse Alternate Words in Sentence

Given a sentence, write a program to reverse the alternate words in the sentence and print it.

Reverse the first word and respective alternative words.

Input

The input will be a single line containing a sentence.

Output

The output should be a single line containing the sentence with the alternate words reversed.

Explanation

For example, if the given sentence is

Sun rises in the east and sets in the west The alternate words which need to be reversed are (Sun, in, east, sets, the), by reversing these words the output should benuS rises ni the tsae and stes in eht west


Sample Input 1

Sun rises in the east and sets in the west


Sample Output 1

nuS rises ni the tsae and stes in eht west


Sample Input 2

The car turned the corner


Sample Output 2

ehT car denrut the renroc




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.


2. Write a class named Pet, which should have the following data attributes:

a) __name (for the name of a pet) __animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’) __age (for the pet’s age) The Pet class should have an __init__ method that creates these attributes.

It should also have the following methods:

b) set_name: This method assigns a value to the __name field. set_animal_type: This method assigns a value to the __animal_type field. set_age: This method assigns a value to the __age field. get_name: This method returns the value of the __name field. get_animal_type: This method returns the value of the __animal_type field. get_age: This method returns the value of the __age field


1. Write a class named Car that has the following data attributes:

a) __year_model (for the car’s year model) __make (for the make of the car) __speed (for the car’s current speed) The Car class should have an __init__ method that accepts the car’s year model and make as arguments. These values should be assigned to the object’s __year_model and __make data attributes. It should also assign 0 to the __speed data attribute.

The class should also have the following methods:

b) Accelerate: The accelerate method should add 5 to the speed data attribute each time it is called. Brake: The brake method should subtract 5 from the speed data attribute each time it is called. get_speed: The get_speed method should return the current speed





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


Sample Input

3times4is12


Sample output

12times4is3


Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.


1. Write a program that reads integers from the user and stores them in a list. Your program should continue reading values until the user enters 0. Then it should display all of the values entered by the user (except for the 0) in order from smallest to largest, with one value appearing on each line.


2. Two words are anagrams if they contain all of the same letters but in a different order. For example, “evil” and “live” are anagrams because each contains one ‘e’, one ‘i’, one 'l', and one ‘V'. Create a program that reads two strings from the user, determines whether or not they are anagrams.


3. Write a function that takes three numbers as parameters, and returns the median value of those parameters as its result


1. Write a program that reads an integer from the user. Then your program should display a message indicating whether the integer is even or odd.


2. A string is a palindrome if it is identical forward and backward. For example “anna”, “civic”, “level” and“hannah” are all examples of palindromic words. Write a program that reads a string from the user and uses a loop to determines whether or not it is a palindrome. 


Input : A2b34ce - - > [2,34]

Output : A34b2ce - - > [34,2]


LATEST TUTORIALS
APPROVED BY CLIENTS