Reverse a given string using recursion

Given an input string, output the reverse of the string using "recursion".

For example:

If the given string is , coderegister

Then the output is , retsigeredoc

Given a string, reverse the string but not the special characters in the string

Consider an input string and reverse the alphabets in the string except the special characters in the string and print the string.

For example: 


Consider the input string, s@t#!sh


The expected output is , h@s#!ts


As you can see, the special characters are in place without any change, whereas the alphabets in the string are reversed.


Python program to find factorial of a number

Given a number, N, find the factorial of that number. N! (read as 'N' factorial) is represented by N x (N-1) x (N-2) x (N-3) x (N-4) x (N-5)....x 1

Python program to reverse a number

Given a number 'N', as input single integer value, we have to reverse the number (i.e., digits in the number are to be reversed) and print it.

Consider the following example:

Number , N = 12345

Then the output should be , N = 54321

Python program to find sum of digits

Given a number, 'N', find the sum of the digits of the number 'N'. For example, assume that the input number is "12345", then the sum of its digits is 15.

TCS MockVita Solution : Problem D

Problem : Break The Friendship

In a class room everyone is very friendly and has bonded with others in a short span of time. During the exams, students will sit along with their friends and will write the exams, which actually resulted in the finding that only a few members in the batch are good at studies and others are not. After getting several complaints from the staff members, the Principal has agreed to change the sitting pattern during the exams for which she has formed a committee. Using a spy, committee was
able to get a list of close friends for all the students in the class. Now using this list they want to identify two groups of people such that a person in one group must not be a friend to any other in the same group. Your task is to help the committee.

TCS MockVita 2 Solution : Problem C

Problem : Minimum Distance

Two riders A and B are travelling on a highway towards each other on two roads that intersect at right angle at speeds VA meters/second and VB meters/second. A is at a distance of 'x' meters and B is at a distance of 'y' meters from the intersection. Calculate the minimum distance between these two riders that is possible.

TCS MockVita 2 Solution : Problem B

Problem : Saving for a rainy day

By nature, an average Indian believes in saving money. Some reports suggest that an average Indian manages to save approximately 30+% of his salary. Dhaniram is one such hard working fellow. With a view of future expenses, Dhaniram resolves to save a certain amount in order to meet his cash flow demands in the future.


TCS MockVita 2 Solution : Problem D

Problem : Sheldon Cooper and his beverage paradigm

Sheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a game out of this. Sheldon proposes as follows,
To decide the amount of beverage they plan to consume, say X. Then order for a random number of different drinks, say {A, B, C, D, E, F} of quantities {a, b, c, d, e, f} respectively.
If quantity of any three drinks add up to X then we'll have it else we'll return the order.
E.g. If a + d + f = X then True else False

TCS MockVita 2 Solution : Problem A

Problem : Catch22

A robot is programmed to move forward F meters and backwards again, say B meters, in a straight line. The Robot covers 1 meter in T units of time. On Robot's path there is a ditch at a distance FD from initial position in forward direction as well as a ditch at a distance BD from initial position in backward direction. This forward and backward movement is performed repeatedly by the Robot.

Your task is to calculate amount of time taken, before the Robot falls in either ditch, if at all it falls in a ditch.