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

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.

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

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


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.


write a function to parse the below pattern onto a text file and highlight the matched pattern using the sliding window concept. AATAA,ATTAAA,TATA,CAT,ATAGTCGC and slicing by 32 bases


Shift Numbers

Given a string, write a program to move all the numbers in it to its end.Input


The input will contain a string A.Output


The output should contain a string after moving all the numbers in it to its end.Explanation


For example, if the given string A is "1good23morning456," the output should be "goodmorning123456," as it contains numbers at the end.




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.


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.


Sandglass Star

Given an integer N, write a program to print the sandglass star pattern, similar to the pattern shown below.

* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Input


The input will be a single line containing a positive integer (N).Output


The output should contain the asterisk(*) characters in the sandglass star pattern.

Note: There is a space after each asterisk(*) character.Explanation


For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.

* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

AD


ASSIGNMENT - 2


DESCRIPTION


HINTS & SOLUTION


SUBMISSIONS


DISCUSS


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
    A

The 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
    A

Sum of Non-Primes

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.Explanation


For example, if the given number is 5, then read the inputs in the next 5 lines and print the sum of non-primes in the given five numbers. If the given input integers in the next five lines are 8, 11, 96, 49, and 25 the output should be 8 + 96 + 49 + 25 is 178.


Given a string in camel case, write a python program to convert the given string from camel case to snake case.Input


The input will be a single line contain a string.Output


The output should contain the given word in snake case.Explanation


For example, if the given word is "PythonLearning" in camel case, your code should print given word in snake case "python_learning".


LATEST TUTORIALS
APPROVED BY CLIENTS