Posts

Showing posts from March, 2021

Expand alphabets occurrence

Expand alphabets occurrence  Problem:  A string consisting of short hand form of occurrence of alphabets will be passed as input. The program must expand the code and print the alphabets. Input Format: The first line will contain the short hand form of the code of length L.  Boundary Conditions:  2 <= L <= 20  Output Format: The alphabets occurrence based on the short hand code.  Example Input/Output 1:  Input:  a3b5a2  Output:  aaabbbbbaa  Explanation:  a3 implies a has to occur 3 times and hence a is printed thrice. b5 implies b has to be occur five times and hence b is printed five times. a2 again implies a has to occur 2 times and hence a is printed thrice. Example Input/Output 2:  Input:  z2m6c4  Output:  zzmmmmmmcccc  Example Input/Output 3:  Input:  abc5  Output:  aaaaabbbbbccccc  Explanation:  Here there is no number after a and b. This implies the next immedi...

Letters at position of multiples of a number

Letters at position of multiples of a number   Problem: A string of length L consists of characters is passed as input to the program. A given number N is also passed as the input to the program. The program must print the characters at the positions which are multiples of the given number.  Input Format:  The first line will contain the string of length L.  The second line will contain the number N.  Boundary Conditions:  3 <= L <= 50  1 <= N <= 30  Output Format:  The characters at the positions which are multiples of the given number.  Example Input/Output 1:  Input:  abcdef  3  Output:  cf  Explanation:  Multiples of 3 are like 3,6,9,... So the characters at positions 3,6 namely c and f are printed as output.  Example Input/Output 2:  Input:  environment  2  Output:  niomn  Explanation:  As it must be multiples of 2, the characters at even pos...