Posts

Showing posts with the label CODEVITA

Important TCS CodeVita Questions Solved – Saving for a rainy day

Image
Important  TCS CodeVita Questions Solved – 2015 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. Consider the following example. Dhaniram wants to buy a TV. He needs to pay Rs 2000/- per month for 12 installments to own the TV. If let’s say he gets 4% interest per annum on his savings bank account, then Dhaniram will need to deposit a certain amount in the bank today, such that he is able to withdraw Rs 2000/- per month for the next 12 months without requiring any additional deposits throughout. Your task is to find out how much Dhaniram should deposit today so that he gets assured cash flows for a fixed period in the future, given the rate of interest at which his money ...

Important TCS CodeVita Questions Solved – Sheldon Cooper and his beverage paradigm

Image
Important TCS CodeVita Questions Solved – 2015 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 You are given Number of bottles N corresponding to different beverages and hence their sizes Next N lines, contain a positive integer corresponding to the size of the beverage Last line consists of an integer value, denoted by X above Your task is to help find out if there can be any combination of three beverage sizes that can sum up to the quantity they intend to consume. If such a combination...

TCS CodeVita previous years questions Solved – Matrix Rotation

Image
TCS CodeVita previous years questions – 2014 Problem : Matrix Rotations You are given a square matrix of dimension  N . Let this matrix be called  A . Your task is to rotate  A  in clockwise direction by S  degrees, where  S  is angle of rotation. On the matrix, there will be 3 types of operations viz. Rotation Rotate the matrix A by angle S, presented as input in form of A S Q uerying Query the element at row K and column L, presented as input in form of Q K L U pdation Update the element at row X and column Y with value Z, presented as input in form of U X Y Z Print the output of individual operations as depicted in Output Specification Input Format: Input will consist of three parts, viz. 1. Size of the matrix (N) 2. The matrix itself (A = N * N) 3. Various operations on the matrix, one operation on each line. (Beginning either with A, Q or U) -1 will represent end of input. Note: Angle of rotation will a...

TCS CodeVita previous years questions solved – Compiler Design

Image
TCS CodeVita2014 Round 1 question Problem : Compiler Design – Limit the Method Instructions Raj is a newbie to the programming and while learning the programming language he came to know the following rules: –         Each program must start with ‘{‘ and end with ‘}’. –         Each program must contain only one main function. Main function must start with ‘<‘ and end with ‘>’. –         A program may or may not contain user defined function(s). There is no limitation on the number of user defined functions in the program. User defined function must start with ‘(‘ and end with ‘)’. –         Loops are allowed only inside the functions (this function can be either main function or user defined function(s)). Every loop must start with ‘{‘ and end with ‘}’. –         User defined function(s) are not allowed to be defined inside main function or ...

Important TCS CodeVita Questions Solved – Catch22 Problem

Image
Important TCS CodeVita questions solved – 2015 Problem : Catch-22 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. Input Format: First line contains total number of test cases, denoted by N Next N lines, contain a tuple containing 5 values delimited by space F B T FD BD, where F denotes forward displacement in meters B denotes backward displacement in meters T denotes time taken to cover 1 meter FD denotes distance from Robot’s starting position and the ditch in forward direction BD denotes dista...

Make a Map of INDIA using c, most amazing C programs

Image
Have you tried or seen any C or c++ program that can make a map of INDIA. Here we are going to see one this code is awesome. You will get the exact replica of the Map of INDIA. Try it now in your compiler. Here is the code you need to write. Just copy paste from here. #include int main() { int a,b,c; int count = 1; for (b = c = 10; a = "- FIGURE?, UMKC,XYZHello Folks, TFy!QJu ROo TNn(ROo)SLq SLq ULo+ UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^ NBELPeHBFHT}TnALVlBLOFAkHFOuFETp HCStHAUFAgcEAelclcn^r^r\tZvYxXy T|S~Pn SPm SOn TNn ULo0ULo#ULo-W Hq!WFs XDt!"[b+++21]; ) for(; a-- > 64 ; ) putchar ( ++c=='Z' ? c = c/ 9:33^b&1); return 0; } Output :  This code will output the map of India: Map of INDIA using C++ Amazing ya! Share this with your friends.

TCS codevita Question Milkman and his bottles Solved

TCS codevita Question Problem : Milk Man and His Bottles A Milkman serves milk in packaged bottles of varied sizes. The possible size of the bottles are {1, 5, 7 and 10} litres. He wants to supply desired quantity using as less bottles as possible irrespective of the size. Your objective is to help him find the minimum number of bottles required to supply the given demand of milk. Input Format: First line contains number of test cases N  Next N lines, each contain a positive integer L i  which corresponds to the demand of milk. Output Format: For each input L i , print the minimum number of bottles required to fulfill the demand  Constraints: 1 <= N <= 1000 L i > 0 1 <= i <= N Sample Input and Output SNo. Input Output 1 2 17 65 2 7 Explanation:  Number of test cases is 2  In first test case, demand of milk is 17 litres which can be supplied using minimum of 2 bottles as follows  1 x 10 l...

TCS Codevita Preparations - Old is Gold

Image
Hello All,                   Hope you would like to sharp your mind and solve some questions that might help you in your career. http://alltricks007.blogspot.in/2017/06/tcs-codevita-n-queen-problem-with.html http://alltricks007.blogspot.in/2017/03/tcs-codevita-2016-round1-question.html http://alltricks007.blogspot.in/2017/03/tcs-codevita-2016-round1-question-logic.html http://alltricks007.blogspot.in/2017/03/tcs-codevita-2016-round1-question-min.html http://alltricks007.blogspot.in/2017/06/tcs-codevita-credit-and-risk-calculator.html http://alltricks007.blogspot.com/2017/06/tcs-codevita-reverse-gear-solution.html http://alltricks007.blogspot.in/2017/06/tcs-codevita-minimum-distance-solution.html http://alltricks007.blogspot.in/2017/06/tcs-codevita-recurring-deposit-question.html http://alltricks007.blogspot.in/2017/06/tcs-codevita-old-quistions.html http://alltricks007.blogspot.in/2017/06/tcs-codevita-question-milkman-and-hi...

TCS Codevita Minimum Distance Solution

Image
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  V A meters/second and  V B  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.                                                               Fig:Approaching Intersection Input Format: First line contains the distance of Rider A from intersection denoted by x Second line contains the distance of Rider B from intersection denoted by y Third line contains the Vel...