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

Rotate Words In Sentence

Given a sentence and an integer N, write a program to rotate letters of the sentence among the words without changing the length of those words and positions of the spaces.

Input

The first line of input will be a sentence.

The second line of input will be an integer N.

Output

The output should be a single line containing the sentence by rotating the letters among the words without changing the length of the words and positions of the spaces.

Explanation

For example, if the given sentence and N are


Welcome to your first problem

5


Rotate the sentence 5 letters towards right side without changing the length of the words and position of spaces in the original sentence.

So the output should be

oblemWe lc omet oyour firstpr

Sample Input 1

Welcome to your first problem

5

Sample Output 1

oblemWe lc omet oyour firstpr

Sample Input 2

All the best

2

Sample Output 2

stA llt hebe




Design a solution pseudocode that will receive student test result

record and print a student test grade report. The student test

record contains the student ID, name and test score (out of

50%). The program is to calculate the percentage of test score

and to print the student ID, name, test score over 50% and its

letter grade. The letter grade is determined as follows:

A=90-100%

B=80-89%

C=70-79%

D=60-69%

F=0-59%


Develop a flowchart that will read in employee’s total weekly

hours worked and rate of pay. Determine the gross weekly pay

by using the formula,

gross weekly pay= total weekly hours worked

*rate of pay


But, if the hours is more than 40, the formula is,

gross weekly pay = (40*rate of pay) + (1.5* (total

weekly hours worked-40) *rate of pay)


Write a program to print the sum of non-primes in the given N numbers. The numbers which are not primes are considered as non-primes.


Input


The first line of input will contain a positive integer (N).

The following N lines will contain an integer in each line.


Output


The output should be the sum of non-primes in the given numbers.


Sample Input 1

5

8

11

96

49

25


Sample Output 1

178




Write a program to display the result of

game competition based on the following

information:

Master Novice

Score >= 90 Gold -

Score >= 80 Silver -

Score >= 70 Silver Pass

Score < 70 No Medal Fail


Triplet Sum
Given an array n integers, find and print all the unique triplets (a, b, c) in the array which give the sum K. (a+b+c=K).
Input

The first line of the input will be space separated integers, denoting the elements of the array. The second line of the input will be an integer denoting the required sum K
Output

The output should be multiple lines, each line containing a unique triplet. The elements of the triple must be sorted in increasing order and all the triplets printed must be sorted in increasing order. Print "No Matching Triplets Found" if there are no triplets with the given sum.
Explanation

When the given array is [0, 1, 2, 3, 5, 7, 13, 17, 19, 19] and the required sum is 22, the triplets (0, 3, 19), (0, 5, 17), (1, 2, 19), (2, 3, 17) and (2, 7, 13) have the given sum 22.
Sample Input 1
0 12 17 8 9 21
29
Sample Output 1
(0, 8, 21)
(0, 12, 17)
(8, 9, 12)

Sample Input 2
0 1 2 3 5 7 13 17 19 19
22
Sample Output 2
(0, 3, 19)
(0, 5, 17)
(1, 2, 19)
(2, 3, 17)
(2, 7, 13)


Non-Adjacent Combinations of Two Words
Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.
Input

The input will be a single line containing a sentence.
Output
For example, if the given sentence is "python is a programming language", the possible unique combination of two are (a, is), (a, language), (a, programming), (a, python), (is, language), (is, programming), (is, python), (language, programming), (language, python), (programming, python). 
a python
is language
is programming
language python
programming python
Sample Input 1
raju always plays cricket
Sample Output 1
always cricket
cricket raju
plays raju

Sample Input 2
python is a programming language
Sample Output 2
a language
a python
is language
is programming
language python
programming python

Sample Input 3
to be or not to be
Sample Output 3
be be
be not
or to
to to
Rotate Matrix Rings
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.
Input

The first line of input will be two space-separated integers, denoting the M and N.
The next M lines will contain N space-separated integers.
The next line will contain an integer, denoting K.
Output

The output should be M*N matrix by rotating the matrix by K elements.
Explanation

In the above matrix, the elements (1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5) is a ring, similarly, the elements (6, 7, 11, 10) will make a ring.
Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be 

Sample Input 1
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
3

Sample Output 1
13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4

Sample Input 2
3 4
1 2 3 4
10 11 12 5
9 8 7 6
2
Sample Output 2
9 10 1 2
8 11 12 3
7 6 5 4

Non-Adjacent Combinations of Two Words

Given a sentence as input, find all the unique combinations of two words and print the word combinations that are not adjacent in the original sentence in lexicographical order.Input


The input will be a single line containing a sentence.Output


The output should be multiple lines, each line containing a valid unique combination of two words. The words in each line should be lexicographical order and the lines as well should be in lexicographical order. A valid combination will not contain the words that appear adjacent in the given sentence. Print "No Combinations" if there are no valid combinations.Explanation


For example, if the given sentence is "python is a programming language",

So the output should be

a language

a python

is language

is programming

language python

programming python

Sample Input 1

raju always plays cricket


Sample Output 1

always cricket

cricket raju

plays raju




Rotate Matrix Rings

Given 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.Input


first line of input will be two space-separated integers, denoting the M and N.

next M lines will contain N space-separated integers.

next line will contain an integer, denoting K.Output


output should be M*N matrix by rotating the matrix by K element.Explanation


if the given M and N are 4 and 4 respectively. If the matrix elements

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

If the given K is 3. Rotate each ring of the matrix by 3 elements.

In the above matrix, the elements (1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5) is a ring, similarly, the elements (6, 7, 11, 10) will make a ring.

Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So the output should be

13 9 5 1

14 7 11 2

15 6 10 3

16 12 8 4



LATEST TUTORIALS
APPROVED BY CLIENTS