Quantcast
Channel: Geek
Viewing all 82 articles
Browse latest View live

TCS CodeVita 2015 Round 2 : Find Captures

$
0
0
Problem : Find Captures
Background

A Chess board position is accurately captured by Forsyth-Edwards notation and is abbreviated as FEN. A FEN "record" defines a particular game position, all in one text line and using only the ASCII character set. A FEN record contains six fields. A complete description of the FEN format to represent Chess positions can be found here

For the purpose of this problem only consider first of the six fields of FEN. Before we describe the problem, let us look at how FEN maps to a board position. The following 5 images show board positions and its corresponding FEN representation.

                    Figure 1.




This board position depicts initial position before any side has made a move. In FEN format this board position is represented as


rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
















Let's say, White plays e4. Then the board position looks like shown below 


                    Figure 2.




This board position depicts the Chess board after White has played e4. In FEN format this board position is represented as


rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR
















Similarly, 3 more half-moves are depicted in following diagrams 

                         Figure 3.                                                  Figure 4.                                                      Figure 5.


The FENs corresponding to Figure 3, 4 and 5 are represented as 

           3. rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR
           4. rnbqkbnr/pppp1ppp/8/4p3/4PP2/8/PPPP2PP/RNBQKBNR
           5. rnbqkbnr/pppp1ppp/8/8/4Pp2/8/PPPP2PP/RNBQKBNR 

Wikipedia describes first field of FEN format as follows 

Piece placement (from white's perspective). Each rank is described, starting with rank 8 and ending with rank 1; within each rank, the contents of each square are described from file "a" through file "h". Following the Standard Algebraic Notation (SAN), each piece is identified by a single letter taken from the standard English names (pawn = "P", knight = "N", bishop = "B", rook = "R", queen = "Q" and king = "K").[1] White pieces are designated using upper-case letters ("PNBRQK") while black pieces use lowercase ("pnbrqk"). Empty squares are noted using digits 1 through 8 (the number of empty squares), and "/" separates ranks 

Statement 

You will be given FENs of successive board positions. Your task is to find the number of captures in the game and then break it down into number of captures by White and Black respectively. You also have to print the move number and the move on which each side makes the capture. See example output to get better understanding. 

For e.g. the five FENs depicted above, corresponds to the following move list in the game. 

1) e4 e5
2) f4 exf4 

The output of processing these FENs will thus be 

Number of Captures in the game : 1
Captures By White : []
Captures By Black : [2) .. exf4] 

Sections below describe the Input and Output specifications followed by examples. Input has to be read from console and output has to be written back to console. 

Input Format:
  1. Each input will correspond to one game only i.e. all successive FEN inputs will represent successive board positions that are a part of the same game.
  2. Each input will begin with FEN corresponding to Initial Position in chess as depicted in Fig 1.
  3. One line will contain only one FEN record
  4. There can be arbitrary number of FEN records provided as input
  5. Input will be terminated by -1
  6. See example inputs for better understanding

Output Format:
  1. First line of the output must print Number of Captures in the game : , where n corresponds to total number of captures by White and Black together
  2. Next two lines should print captures by White and Black respectively, one on each line
  3. The format of printing these two lines is Captures By : [Move List] where colour will be {White | Black}
  4. Move List must be enclosed in square brackets.
    1. If there are no captures by a side, then Move List should be empty denoted by []
    2. If the Move List is non-empty, then print the formats for printing captures by White and Black are as follows
      • Capture by White should be tuples delimited by ',' where tuple comprises on , where move number should be suffixed by ')' e.g. [4) cxd5, 6) bxc3]
      • Capture by Black should be tuples delimited by ',' where tuple comprises on , where move number should be suffixed by ')' e.g. [4) .. Nxd5, 5) .. Nxc3]. The '.. ' represents a placeholder for White's move
      • In case, number of captures is exactly 1, print only respective tuples (without ',')
  5. See example outputs for better understanding

Constraints:
  1. A check in algebraic notation is depicted by '+' symbol. We don't expect checks to be detected. Hence the output should be printed without '+' symbol. Ditto for double checks.
  2. Similarly, a check mate is usually denoted by #. We don't expect check mate to be detected. Hence the output should be printed without '#' symbol.
  3. Similarly, castling is usually denoted by o-o (short castle) or o-o-o (long castle). We don't expect castling to be detected. Hence our test cases don't contain FENs which give rise to such positions.
  4. Algebraic notation provides a way to disambiguate a move. We don't expect disambiguation to be implemented. Hence we have ensured test cases don't have ambiguous move. The following diagram explains the ambiguity and the corresponding disambiguation method.

                        Figure 6.


    The next move by White in this position is Nd2. Now both Knights can move to d2 square. Hence this move is ambiguous until it is explicitly expressed which knight has moved to d2.


    The algebraic notation solves this problem by writing the move as
    Nbd2 - if knight on b-file has moved to d2 or
    Nfd2 - if knight on f-file has moved to d2

    Generating a move list which can disambiguate move based on FENs is not expected. Hence our test cases don't contain FENs which give rise to such positions.


















  5. There is no need to handle En Passant positions. There are no test cases involving En Passant moves.

Sample Input and Output

SNo.InputOutput
1
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR
rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR
rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R
r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R
r1bqkbnr/pppp1ppp/2n5/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/2b1p3/2B1P3/5N2/PPPP1PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/2b1p3/1PB1P3/5N2/P1PP1PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/4p3/1bB1P3/5N2/P1PP1PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/4p3/1bB1P3/2P2N2/P2P1PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/b3p3/2B1P3/2P2N2/P2P1PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/b3p3/2BPP3/2P2N2/P4PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/b7/2BpP3/2P2N2/P4PPP/RNBQK2R
r1bqk1nr/pppp1ppp/2n5/b7/2BpP3/2P2N2/P4PPP/RNBQ1RK1
r1bqk1nr/pppp1ppp/2n5/b7/2B1P3/2Pp1N2/P4PPP/RNBQ1RK1
r1bqk1nr/pppp1ppp/2n5/b7/2B1P3/1QPp1N2/P4PPP/RNB2RK1
r1b1k1nr/pppp1ppp/2n2q2/b7/2B1P3/1QPp1N2/P4PPP/RNB2RK1
r1b1k1nr/pppp1ppp/2n2q2/b3P3/2B5/1QPp1N2/P4PPP/RNB2RK1
r1b1k1nr/pppp1ppp/2n3q1/b3P3/2B5/1QPp1N2/P4PPP/RNB2RK1
-1

Number of Captures in the game : 2
Captures By White : []
Captures By Black : [4) .. Bxb4, 6) .. exd4] 
2
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR
rnbqkb1r/pppppppp/5n2/8/3P4/8/PPP1PPPP/RNBQKBNR
rnbqkb1r/pppppppp/5n2/8/2PP4/8/PP2PPPP/RNBQKBNR
rnbqkb1r/pppppp1p/5np1/8/2PP4/8/PP2PPPP/RNBQKBNR
rnbqkb1r/pppppp1p/5np1/8/2PP4/2N5/PP2PPPP/R1BQKBNR
rnbqkb1r/ppp1pp1p/5np1/3p4/2PP4/2N5/PP2PPPP/R1BQKBNR
rnbqkb1r/ppp1pp1p/5np1/3P4/3P4/2N5/PP2PPPP/R1BQKBNR
rnbqkb1r/ppp1pp1p/6p1/3n4/3P4/2N5/PP2PPPP/R1BQKBNR
rnbqkb1r/ppp1pp1p/6p1/3n4/3PP3/2N5/PP3PPP/R1BQKBNR
rnbqkb1r/ppp1pp1p/6p1/8/3PP3/2n5/PP3PPP/R1BQKBNR
rnbqkb1r/ppp1pp1p/6p1/8/3PP3/2P5/P4PPP/R1BQKBNR
rnbqk2r/ppp1ppbp/6p1/8/3PP3/2P5/P4PPP/R1BQKBNR
rnbqk2r/ppp1ppbp/6p1/8/3PP3/2P2N2/P4PPP/R1BQKB1R
rnbqk2r/pp2ppbp/6p1/2p5/3PP3/2P2N2/P4PPP/R1BQKB1R
rnbqk2r/pp2ppbp/6p1/2p5/3PP3/2P2N2/P4PPP/1RBQKB1R
rnb1k2r/pp2ppbp/6p1/q1p5/3PP3/2P2N2/P4PPP/1RBQKB1R
-1

Number of Captures in the game : 4
Captures By White : [4) cxd5, 6) bxc3]
Captures By Black : [4) .. Nxd5, 5) .. Nxc3]
3
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR
rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR
rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R
rnbqkb1r/pppp1ppp/5n2/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R
rnbqkb1r/pppp1ppp/5n2/4N3/4P3/8/PPPP1PPP/RNBQKB1R
rnbqkb1r/ppp2ppp/3p1n2/4N3/4P3/8/PPPP1PPP/RNBQKB1R
rnbqkb1r/ppp2ppp/3p1n2/8/4P3/5N2/PPPP1PPP/RNBQKB1R
rnbqkb1r/ppp2ppp/3p4/8/4n3/5N2/PPPP1PPP/RNBQKB1R
-1

Number of Captures in the game : 2
Captures By White : [3) Nxe5]
Captures By Black : [4) .. Nxe4]

Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

For C and C++, return type of main() function should be int.


TCS CodeVita 2015 Round 2 : Romeo and Juliet

$
0
0
Problem : Romeo and Juliet

Romeo and Juliet stay in Rectanglevilla. As the name suggests, Rectanglevilla is indeed a rectangle in shape. Romeo's current location is marked by 's'. Juliet's current location is marked by 'd'. In a difficult hour, Romeo has to ensure that he reaches Juliet via the shortest path and hence in shortest time.

There are many in Rectanglevilla who are enemies of Romeo and hence will not allow Romeo to pass through their areas. Romeo must avoid these areas while reaching out for Juliet. These areas are marked by 'w' character. Areas that Romeo can freely access is marked by '-' character.

Today Romeo needs your help to reach Juliet via shortest path. Help him.

The input and output specification sections describe how inputs will be provided on console and how output is expected back on console.
Input Format:
  1. First line of input contains grid dimensions delimited by space character
  2. Next rows number of lines contain column number of characters
  3. Valid characters are {s, d, w, -}, where
    1. s represents the location of the Romeo
    2. d represents the location of the Juliet
    3. w represents inaccessible region
    4. - represents accessible region
  4. End of input is marked by -1 character

Output Format:
  1. Output grid should be of the same dimension as the input grid
  2. Output grid should contain path from Romeo's location s to Juliet's location d
  3. The 's' character in the grid must be replaced by character 'a' to denote that Romeo is actively heading towards Juliet.
  4. See example section for better understanding

Constraints:
1. It is guaranteed that there will always be exactly one shortest path for Romeo to reach Juliet 

Sample Input and Output

SNo.InputOutput
1
4 4
w - d -
w - w -
w - w w
s - - -
-1

w - d -
w a w -
w a w w
a - - -
2
6 6
s - - - - w
- - - - w -
- - - w - -
- - w - - -
- w - - - -
w - - - - d
-1

a - - - - w
- a - - w -
- - a w - -
- - w a - -
- w - - a -
w - - - - d


Explanation for sample input and output 1:


        Figure 1.

Note: - The output format shown above is for understanding purpose such that it highlights the shortest path between Romeo and Juliet. The example in above table depicts output in text format as you will be required to provide.
Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

For C and C++, return type of main() function should be int.


TCS Placement Preparation for 2016 batch

$
0
0


The Placement for 2016 batch has gained pace and many people have got the offer. I thought it was the time to jot down some key startegy and resources to ace TCS Campus Drive.

IT companies like TCS, Infosys, Wipro, Accenture hire students from almost all branches. Have you ever thought what students from non CSE/IT branch do in the company. Well I would tell you, it's not difficult to learn how to code. Software Developmet involves many phases and coding is just one phase. When you start in these IT companies, you get initial training where they teach you all that you need to know depending on your domain. After training you start working in a group of 20+ people with different level of experiences. You start getting small works and then time teaches you how to get things done. So it's no big deal whether you know programming or not, you can work in IT companies.

You are in final year or about to enter in final year. Before you make any decision to join any IT comapnies, read the following blog :

Placement

How to get through campus placements

You spent 2 excruciating years in a base camp called Kota or at a closed room studying dreadful ML Khanna’s maths or HC verma’s physics aiming to crack IIT-JEE and get into the best engineering college.

To know about TCS eligibility criteria and placement pattern read following blogs:

Placement

TCS Placement Pattern

TCS placement process consists of two phases - Written Round (Analytical+ Verbal Ability Test ) and Personal Interview.

Placement

TCS Placement Preparation

Well, placement season has started and the tech giant TCS is all set to recruit students. TCS changes its recruitment process continuously.

Are you aware of Email Writing in TCS Verbal Ability Test? We have listed here all the resources needed to write a perfect email to anyone. You can take the mock test of email writing also that evaluates on several parameters e.g. Uses of phrases, salutation, grammer, spelling and word limits. Go through all the resources mentioned below and believe me you won't have any problem in writing email to anyone.

Verbal

How to write convincing email

E-mails are the most common document in the business world. Unfortunately, many e-mails are so poorly written that recipients must struggle to figure out why they're reading the e-mail and what they're supposed to do about it. Here's a foolproof method to write e-mails that get the job done.

Verbal

TCS Verbal Ability Test Sample Email

You know how to write an email but want some samples of TCS email then here are few samples answers of TCS Verbal Questions asked in previous campus drives.

Verbal

TCS Verbal Ability Simulator

Take TCS Verbal Ability Mock Test and analyze your performance. Measure how you perform among thousands. Our TCS Verbal Ability Test Simulator gives you insights of all your mistakes and tips to improve your email.

Verbal

TCS Verbal Ability Simulator Chrome App

You don't have good internet connection or you are unable to be online. No problem, we have taken care of that problem. Download our Chrome App and take TCS Verbal Ability Test in offline mode. This offline app works fine except it does not check your spelling or grammatical mistakes.

Now comes TCS Analytical Ability Test. In order to ace TCS Analytical Ability Test, you must practice much to grasp all the concepts. If you have gone through above links then you already know how to prepare for TCS Analytical Ability Test. Here are a few resources and tips to ace TCS Analytical Ability Test.

Analytical

TCS Analytical Ability Test Paper

Want to practice questions asked in previous placemnt drives. Go through following link to download prevoius years'TCS Analytical Ability Questions with Answers.

Analytical

TCS Analytical Ability Mock Test

You know the basics and want to test where you stand among thousands or analyze your performance, take TCS Analytical Ability Mock Test and see where you stand.


Other Resources

  • Practice LOD1 and LOD2 from How to Prepare for Quantitative Aptitude for the CAT by Arun Sharma
  • Refer to campusgate.co.in for previous year TCS Aptitude Question
  • Refer to m4maths.com for latest questions.

To know how to answer HR interview questions, go through following blog:
Interview

How to interview questions

So you are in final year now preparing for placement. It might be your first interview and you are worried about how all things will go in the interview. We are here with a few tips to help you answer the questions smartly and grab the so called “Offer Letter”. Your seniors might have told you their experiences and you might have ample idea about all the stuff. Still if you have any doubt answering the HR questions or what should be the proper answer. This post is for you.

Also refer to a complete guide to get through TCS campus placement.
Guide

A complete guide to get through campus placement

If you are appearing for TCS Placement and have no clear idea on how to prepare different section viz. Verbal Ability Test, Analytical Ability Test, Interview (T.R., M.R. &amp. H.R. rounds) then this post is for you!



Still have doubts? Drop a comment below or mail at vikash@programminggeek.in

TCS Off Campus Drive for 2016 batch

$
0
0


TCS has announced off campus drive for engineering students graduating in the year 2016.  The exact date of drive has not been announced but application process has already started.

This blog explains how to apply and prepare for the TCS off-campus drive.

   Eligibility

Year of Graduation

Engineering students scheduled to graduate in the year 2016 are eligible to apply.

Relevant Disciplines

BE / B.Tech / ME / M.Tech in any of the following disciplines:
  • Computer Science
  • Information Technology
  • Electronics and Electrical Engineering
  • Electronics and Communication
  • Electronics and Telecommunication
  • Mechanical Engineering
  • Electronics/Electrical and Instrumentation Engineering
  • Electrical Engineering
  • Instrumentation Engineering
  • Network Engineering
MCA with BSc / BCA / BCom / BA (with Math / Statistics Background)

M.Sc in Computer Science / Information Technology

Marks Criteria

  • Minimum Aggregate Marks of 60% and above in the first attempt in all academic courses Standard 10th onwards.
  • Aggregate of all subjects in all semesters to be considered (All subjects mentioned on the mark sheet).
  • First attempt implies securing 60% and above marks within the normal duration of the course.
  • Improvement exam is not first attempt and hence the marks secured in improvement exams should not be considered to calculate aggregate marks.
  • In case you have done both, 12th and equivalent diploma, you should have secured minimum 60% aggregate marks in both courses.
Course Duration

Completion of all courses Standard 10th onwards, within the stipulated time as specified by the University/Institute without any extended education.

Backlog Criteria

No pending backlogs at the time of appearing for the TCS Selection process.
It is mandatory to declare pending backlogs, if any, in the TCS Application Form.

Experience

Candidates with more than 3 years of work experience are not eligible to participate in the TCS Selection process.

Course Type

Only Full time courses will be considered.

Age Criteria

Minimum Age-18 years and Maximum Age-28 years at the time of appearing for the TCS Selection process.

Gaps/Breaks

  • It is compulsory to declare gaps/breaks, if any, during your academics and work experience in the TCS Application form.
  • Maximum up to 24 months break may be permissible for valid reasons. Relevant document proof, as applicable, will be checked for gaps in education.
  • The reason for break in academics should not be extended education.



Recommended Reading: 

How to get through campus placements

TCS Placement Pattern

TCS Placement Preparation

How to write convincing email

TCS Verbal Ability Test Sample Email

TCS Verbal Ability Simulator

TCS Verbal Ability Simulator Chrome App

TCS Analytical Ability Test Paper


Registration & Application


How to Apply for the TCS Recruitment Drive for Engineers?


Candidates yet to registerAlready Registered Candidates
Step 1: Registration
  • Log on to https://nextstep.tcs.com and click onIT
  • Click "Register Here"
  • Click "Off-Campus Applicant"
  • Fill the Registration Form and Submit
  • Note your Reference ID and Password
Step 2: Application
  • Log on to https://nextstep.tcs.com with your Reference ID and Password
  • Click "Application Form" on the left hand side menu on the Profile Page
  • Fill the Application form and Submit. A confirmation message will be displayed on successful submission. Please ensure that the Application form is filled correctly and updated with your latest details.
  • Click on "Track My Application". The status should reflect as "Application Received".
  • If you have already registered with us and have a valid CT or DT reference ID, you need not register again. Please ensure that you have filled in the Application Form as well.

  • In-case you wish to update any information in the application form after submitting, you can do so by clicking Edit Application form on the left hand side menu of the Home Page.

  • For CT candidates who have already appeared for the TCS selection process in FY 2015-16, must check their nearest Test Location and update the location (if required), by logging ontohttps://nextstep.tcs.com > Select nearest test location from the Left side menu of the home page.

  • For DT candidates, the nearest Test Location will be the same as entered in their Application form. If you wish to update, you can do so by you can do so by clicking Edit Application form on the left hand side menu of the Home Page and update the same.
Your candidature for the TCS Offcampus Drive of 2016 will be considered only after completing both the below mentioned steps:
  • Successful completion of the Registration and Application form
  • Click on the 'Apply to Off Campus Drive'

Last Date of Registrations: 8th Feb 2016 @ 23:59 hrs.
Date of Test: 2nd March 2016

To Access the TCS Practice Test 'Open Seesame' log onto https://nextstep.tcs.com/ and Click on 'Open Seesame' Banner on the left hand side of the Home page.

In Case of any queries you may connect with TCS on Toll Free Helpline (1800-209-3111) or write at ilp.support@tcs.com.

Other Resources :

How to interview questionsA complete guide to get through campus placement


Interview : How To Dress

$
0
0


When it comes to attending an interview, the first thing that is noticed is how you are dressed.

It seems trivial that how dress determines your success in interview, but remember first impression is the last impression.


Interview is perhaps the most stressful in the process of getting job and the most important one.

So if you perform well in interview then you are most likely to get the offer.



What you should wear and what kind of impression you want to leave within your interview go hand and hand. In order to get the job, (or even be considered for the job) you have to look the part. Confused about exactly what to wear for which interview?

Follow this guide to ensure you look sleek, professional, and most importantly ready to get the offer!



Dress Code

Interview Dress Code for Boys

 Shirt Color
  • Light Blue / White : The shirt should contain no patterns.
 Trouser and Coat Color
  • Navy Blue / Black / Charcoal Gray : It's not mandatory to waer but good to have.
 Tie
  • Silk and Solid Color: Should contain no pattern or simple pattern.
 Footwear
  • Black/Brown: Properly laced and polished.
 Socks
  • The color should match with shoes or trouser
 Belt
  • Black leather with simple buckle or it should match the shoes.
 Hairstyle
  • The hair should be short and finely trimmed.
 Facial hair
  • You should be clean shaved.
Dress Code

Interview Dress Code for Girls

 Shirt Color
  • Light shade / White : The shirt should contain no patterns.
 Trouser and Coat Color
  • Navy Blue / Black / Charcoal Gray : Prefer narrow bottom trouser.
 Skirt and Coat Color
  • Navy Blue / Black / Charcoal Gray with stockings.
 Tie or Scarf
  • Silk and Solid Color: Should contain no pattern or simple pattern.
 Footwear
  • Black/Brown: heeled and polished stilettos
 Socks
  • The color should match with bellies or trouser
 Belt
  • Black leather with simple buckle or it should match the stilettos
 Hairstyle
  • Perfectly tied and no bangs on the face. Never ever go with open straight hair.
 Makeup
  • Light makeup. Don't use too much of makeup. Should be attractive but not eye-catching.
    Have more ideas? do share below!

TCS CodeVita Seaon V

$
0
0



Welcome to TCS CodVita Season V

Introduction

TCS CodeVita Season Five is here! Like four previous season TCS is strengthening its commitment to promote Programming-As-A-Sport culture. TCS has launched a platform called Anyone-Can-Code (https://campuscommune.tcs.com/channels/anyone-can-code) this time where you can practice programming problem.

Purpose of the Contest

The main objective for the contest is to sharpen the contestants' programming skills through some real-life computing practices.  The contest will also
  • Help TCS Spot the bright students
  • Provide students an opportunity to showcase their programming talent and earn peer recognition and honour
  • Provide an opportunity to showcase offerings of TCS to the academic world

Structure of the Contest

CodeVita is a team contest. A team must have 2 members. The contest will comprise of several rounds of coding. To participate in CodeVita, one needs to register the team. Both members of the team will need to register individually. The registration portal will provide necessary workflows to form the team online. Only a valid team can participate in the contest.
Registration windows open up different times for different geographies. Refer your geography specific section for details on registration process.
To help contestants warm up for the contest, a practice round will be open to participants who have registered for the contest
  • Practice Rounds: - Participants must use practice rounds to familiarize themselves with CodeVita website UI and also ensure that their workstations have compatible software that they can use for coding in Codevita. This is an optional, but highly recommended round to participate in.
  • MockVita 1:- MockVita are equivalent in difficulty levels to CodeVita round 1. Quite likely MockVita will repeat questions asked in previous seasons of CodeVita. This is an optional, but highly recommended round to participate in.
  • MockVita 2: - Same as MockVita 1. If MockVita 1 is on a weekday, MockVita 2 will be on a weekend or vice-versa. This is an optional, but highly recommended round to participate in.
  • Round 1: The real CodeVita begins here. This is the first round of the contest. Top 300 or Top 5% of teams (whichever is higher) from the first round will move into this round.
  • Round 2: Top performers from Round 2 will have an opportunity to reach the Finale. The list of Finalists is compiled only after all regional rounds across the globe are completed.
  • Grand Finale: To be held in one of the TCSL offices in India. Top 3 teams will be declared as winners of the contest. Winners will receive exciting prizes, internship offers with CTO Team and provisional Offer Letters.

TCS CodeVita Season IV : Instructions

Eligibility Criteria 

Coders from institutes across India are eligible for this contest. Registrations are invited from students in under graduate/ post graduate disciplines fromengineering/science background with any specialization

Registration Process

  • Students will have to  Register on TCSL NexStep for taking part in the contest. A CT/ DT Reference # is mandatory for participating in the contest.
  • Each team can have only  two members.
  • After registration begins, all interested participants will be required to register for the contest on Campus Commune. Each registered participant will be receiving a  unique secret code to take part in the contest. This code is of utmost importance to take part in the contest rounds and should not even be shared between team-mates The Secret code will also be a part of login credentials
  • Each team should choose a team name and the team leader.
  • During registration, the team leader should  Nominate self as the Team Leader and also  Invite the team members. It is the responsibility of the team members to  Accept the invitation.
  • In case a team member rejects a nomination, the Team Leader will be able to send a new request to another registered member from same institute to join the team.
  • The team will be formed after all invited members accept their invitations.
  • The Team Leader of each legitimate team will be our point of contact for any further communication with respect to the contest and will be responsible for updating the respective team members.
  • The team can be from the same discipline or may be inter-disciplinary.
  • Team members of a particular team have to be from same college/institute.
  • Team members have to remain constant throughout the contest. Swapping of participants within teams is not allowed and will lead to disqualification of the respective teams from the contest.

General Guidelines

  • The infrastructure / software(s) required for compiling code solutions shall be borne by the team or the institution they represent. TCS will not be liable for any damage to the institute’s infrastructure which may be caused by participants from the institute during the contest.
  • Language compilers are open source applications that can be downloaded from the internet. Participants will need to submit the compiled solution to a problem only. For example, codes written in Java should be submitted in .java format
  • CodeVita platform supports coding in 10 languages. Language names and supported compiler / interpreter versions are mentioned in table below.
  • Coding Guidelines will be provided as separate document. It will include information on scoring and ranking of teams in different rounds, list of URLs from which compilers and IDEs can be downloaded.

Participant Registration & Team Formation

Welcome to Phase 1 of the contest. Click on the Register button below to register yourself for the contest and start the Team Formation Process.
Notes

Important Notes

All times are in (IST)

Starts : Wed Mar 02 2016 13:00 Hrs
Ends : Tue Jul 26 2016 13:00 Hrs
Members Per Team : 2
Registrations are open.

TCS CodeVita Season IV : Round 1

The real CodeVita begins here. This is the first round of the contest. Top 300 or Top 5% of teams (whichever is higher) from the first round will move into this round.
Notes

Important Notes

Round Type: Other

All times are in (IST)

Starts : Fri Jul 29 2016 11:00 Hrs
Ends : Sat Jul 30 2016 11:00 Hrs
Bounty Points : 2000
Number to be Short-listed:
This phase is not open yet.

TCS CodeVita Season IV : Round 2

Top performers from Round 2 will have an opportunity to reach the Finale. The list of Finalists is compiled only after all regional rounds across the globe are completed.
Notes

Important Notes

Round Type: Other

All times are in (IST)

Starts : Sat Aug 20 2016 11:00 Hrs
Ends : Sun Aug 21 2016 11:00 Hrs
Bounty Points : 2500
Number to be Short-listed:
This phase is not open yet.

TCS CodeVita Season IV : Grand Finale

To be held in one of the TCSL offices in India. Top 3 teams will be declared as winners of the contest. Winners will receive exciting prizes, internship offers with CTO Team and provisional Offer Letters.
Notes

Important Notes

Round Type: Other

All times are in (IST)

Starts : Tue Feb 28 2017 09:30 Hrs
Ends : Tue Feb 28 2017 16:30 Hrs
Bounty Points : 3000
Number to be Short-listed: 3
This phase is not open yet.


Exciting Prizes to be won this Season:



*Winners will receive exciting prizes, internship offers with CTO Team and provisional Offer Letters.


What you can do here

  • Discussion with peers!
  • Find important tips and tricks!
  • Quick quotes for your query!

TCS CodeVita 2016: are you ready?

$
0
0

TCS CodeVita 2016


TCS has announced TCS CodeVita Season V (2016). Students from colleges across India have registered for TCS's annual programming contest. Have you registered? 

 TCS CodeVita provides you a platform to show off your skills and grab awesome goodies, internship and above all offer letter


 There has been one change this time though. Remember TCS CodeVita Season V(2016) is not a global contest. This time the contest is among students from colleges across India. Participation in CodeVita 2016 has tremendous importance in the TCS Campus Recruitment.  

Your participation in CodeVita shows your inclination toward programming which is of great importance in TCS Selection process. Remember even if you don't have 60% in 10th, 12th or B. Tech, you might get interview call from TCS which TCS generally doesn't allow for freshers. Well if you are not looking to join TCS, there is no harm in showing off your programming skills and grabbing the awesome prize


Prepare for CodeVita 2016 

You can find enough material on this site for TCS CodeVita 2016 preparation. We have published TCS CodeVita previous years' question from different rounds.  
Go through these links to explore more: 


Register for CodeVita 2016 

You can register for CodeVita 2016 after registering on https://nextstep.tcs.com and launching campus commune after login.

For detailed info on CodeVita 2016 visit http://goo.gl/7iWdvf

TCS CodeVita Previous years' question

$
0
0

TCS CodeVita Season IV Round1 Question: Catch 22

$
0
0

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
  1. F denotes forward displacement in meters
  2. B denotes backward displacement in meters
  3. T denotes time taken to cover 1 meter
  4. FD denotes distance from Robot's starting position and the ditch in forward direction
  5. BD denotes distance from Robot's starting position and the ditch in backward direction

Output Format:

For each test case print time taken by the Robot to fall in the ditch and also state which ditch he falls into. Print F for forward and B for backward. Both the outputs must be delimited by whitespace
OR

Print No Ditch if the Robot does not fall in either ditch
Constraints:
  1. First move will always be in forward direction
  2. 1 <= N <= 100
  3. forward displacement > 0
  4. backward displacement > 0
  5. time > 0
  6. distance of ditch in forward direction (FD) > 0
  7. distance of ditch in backward direction (BD) > 0
  8. All input values must be positive integers only

Sample Input and Output


SNo.InputOutput
1
3
9 4 3 13 10
9 7 1 11 13
4 4 3 8 12

63 F
25 F
No Ditch
2
5
8 4 7 11 22
4 5 4 25 6
4 9 3 6 29
7 10 6 24 12
10 10 1 9 7

133 F
216 B
231 B
408 B
9 F

Note:


Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:


Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:


For C and C++, return type of main() function should be int.

TCS CodeVita Season IV Round1 Question: Saving for a rainy day

$
0
0
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 will grow during this period.
Input Format:

First line contains desired cash flow M
Second line contains period in months denoted by T
Third line contains rate per annum R expressed in percentage at which deposited amount will grow
Output Format:

Print total amount of money to be deposited now rounded off to the nearest integer
Constraints:
M > 0
T > 0
R >= 0
Calculation should be done upto 11-digit precision

Sample Input and Output

SNo.InputOutput
1
500
3
12

1470
2
6000
3
5.9

17824
3
500
2
0

1000

Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

For C and C++, return type of main() function should be int.

TCS CodeVita Season IV Round1 Question: Minimum Distance

$
0
0
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 VAmeters/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.


                                        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 Velocity of Rider A denoted by VA
Fourth line contains the Velocity of Rider B denoted by VB
Output Format:

Print the minimum distance between these two riders, if minimum distance is non-zero. If minimum distance is zero, print it as 0.0
Constraints:
x > 0
y > 0
VA > 0 
VB > 0 
Calculation and printing of output should be done upto 11-precision

Sample Input and Output


SNo.InputOutput
1
100
100
10
10

0.0
2
500
300
20
14

41.18252056395
3
100
100
30
40

22.36067977500
5
0
50
-20
30

Invalid Input

Note:


Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:


Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:


For C and C++, return type of main() function should be int.

TCS CodeVita Season IV Round1 Question: Sheldon Cooper and his beverage paradigm

$
0
0
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
  1. Number of bottles N corresponding to different beverages and hence their sizes
  2. Next N lines, contain a positive integer corresponding to the size of the beverage
  3. 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 is possible print True else False

Input Format: 
  1. First line contains number of bottles ordered denoted by N
  2. Next N lines, contains a positive integer Ai, the size of the ith bottle
  3. Last line contains the quantity they intend to consume denoted by X in text above


Output Format:
True, if combination is possible
False, if combination is not possible
Constraints:
N >= 3
Ai > 0 
1 <= i <= N
X > 0 


Sample Input and Output


SNo.InputOutput
1
6
1
4
45
6
10
8
22

True
2
4
1
3
12
4
14

False


Explanation for sample input and output 1:

The sum of 2nd, 5th and 6th beverage size is equal to 22. So the output will be True.
Explanation for sample input and output 2:

Since no combination of given beverage sizes sum up to X i.e. 14, the output will be False.
Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

For C and C++, return type of main() function should be int.

TCS CodeVita Season IV Round1 Question: Number Game

$
0
0
Problem : Number Game

Aman and Jasbir are very intelligent guys of their batch. Today they are playing a game "Game of Numbers".

Description of game: 
  1. There are N numbers placed on a table.
  2. Since two players are playing the game, they will make their moves alternatively.
  3. In one move a player can perform the following operation.
    1. A player will choose a number from the table and will replace that number with one of its divisor. For example, 6 can be replaced with 1, 2, or 3 (since these are the divisors of 6). Similarly, 12 can be replaced with 1, 2, 3, 4 or 6.
    2. It is mandatory that the player has to replace the number.
    3. A player cannot put back the same number on table.
    4. As 1 does not have any divisor other than itself, a player cannot replace 1 with any other number. So soon a situation will arise when there will be only all 1s on the table. In that situation the player will not be able to make any move. The player who will not be able to make the move, loses.
  4. Both the players are masters of this game. So they will play the game optimally.
  5. Aman will make the first move of the game.

You will be given N integers that are on the table. You have to predict, who will win the game - Aman or Jasbir.

Input Format:

First line contains information about the numbers present of the table, denoted by N
Second line contains N integers delimited by space - A1 A2 A3 A4 ......... AN
Output Format:

Print the name of the player who will win the game in upper case i.e. AMAN or JASBIR.
Constraints:
1 <= N <= 100000
0 < Ai <= 10000 
A player cannot replace more than 1 number in one move. 
Players move alternate and a player cannot pass or make no move
A number cannot be replaced itself, i.e. 6 can be replaced with 1, 2 or 3 only , not with 6.
Aman always makes the first move.
Sample Input and Output


SNo.InputOutput
1
1
6

AMAN
2
2
18 6

AMAN
3
4
24 45 45 24

JASBIR


Explanation for sample input output 1:

There is only one number placed on the table do AMAN will replace it with 1. Jasbir will play next. As there is only 1 left on the table. And it cannot be replaced with any other number; he is not able to make any move. So he loses the game.
Explanation for sample input output 2:

There are 2 numbers present on the table. Since every move is the optimal move, Aman will replace 18 with 6. Now (6, 6) will be left on the table. Now, whatever move Jasbir will make. Aman will also make the same move. So whenever Jasbir will replace any number with 1. In the next move Aman will also replace the other number with 1. So both the numbers will be one after Aman's move. So Jasbir will lose the game.

Initial configuration - (18, 6)
AFTER Aman's MOVE - (6, 6)
AFTER Jasbir's MOVE - (6, 3)
AFTER Aman's MOVE - (3, 3)
AFTER Jasbir's MOVE - (1, 3)
AFTER Aman's MOVE - (1, 1)

Now, Jasbir WILL NOT BE ABLE TO MAKE ANY MOVE. So, Amanwill WIN.
Explanation for sample input output 3:

In this case, game is already symmetric. Aman has to make the first move. So whatever move Aman will make Jasbir will just repeat the same. So In the Aman will go out of moves and Jasbir will win the game.

Initial configuration - (24, 45, 45, 24)
AFTER Aman's MOVE - (1, 45, 45, 24)
AFTER Jasbir's MOVE - (1, 45, 45, 1)
AFTER Aman's MOVE - (1, 1, 45, 1)
AFTER Jasbir's MOVE - (1, 1, 1, 1)

Let's see if outcome changes if Aman replaces 24 by 6 instead of 1

Initial configuration - (24, 45, 45, 24)
AFTER Aman's MOVE - (6, 45, 45, 24)
AFTER Jasbir's MOVE - (6, 45, 45, 6)
AFTER Aman's MOVE - (6, 5, 45, 6)
AFTER Jasbir's MOVE - (6, 5, 5, 6)
AFTER Aman's MOVE - (3, 5, 5, 6)
AFTER Jasbir's MOVE - (3, 5, 5, 3)
AFTER Aman's MOVE - (1, 5, 5, 3)
AFTER Jasbir's MOVE - (1, 5, 5, 1)
AFTER Aman's MOVE - (1, 1, 5, 1)
AFTER Jasbir's MOVE - (1, 1, 1, 1)

Now, Aman WILL NOT BE ABLE TO MAKE ANY MOVE. So, Jasbir will WIN. It is easy to see that just by mimicking Aman's moves, Jasbir will win.
Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

For C and C++, return type of main() function should be int.

TCS CodeVita Season IV Round1 Question: Base Camp

$
0
0
Problem : Base Camp

Three friends set out to explore a remote area. They choose a safe place and make it their Base Camp. To speed up exploration time they decide to work independently. At any given point, either one or more of them can set out to explore the area. They set a protocol that after exploring the area they must meet back at the Base Camp in the evening and exchange notes.

The remote area consists of accessible and inaccessible pieces of land. Being ordinary humans, they must walk only the accessible piece of land. In order to maximize their exploration time, each one is interested in knowing about a shortest path back to the base camp.

Given that the area under exploration is arranged in form of a rectangular grid, help the explorers to chalk out a shortest path back to the base camp. Properties of a rectangle can be used as heuristic in computing distance between their positions and the Base Camp. Your task is to find out and mark the shortest path for each explorer and print each path as a separate grid.

The input and output specification sections describe how inputs will be provided on console and how output is expected back on console.
Input Format:
  1. First line of input contains grid dimensions delimited by space character
  2. Next rows number of lines contain column number of characters
  3. Valid characters are {s, d, w, -}, where
    1. s represents the location of the explorer
    2. d represents the location of the base camp
    3. w represents inaccessible region
    4. - represents accessible region
  4. End of input is marked by -1 character

Output Format:
  1. Number of grids in the output should be same as number of explorers i.e. 's' characters in the input grid
  2. Each output grid should be of the same dimension as the input grid
  3. Each output grid should contain path from explorer location s to base camp location d
  4. If there are more than one explorers, explorer with smallest value should be printed first in the output. Next smallest explorer location should be printed next followed by the last explorer grid.
  5. First explorer path should be marked by 'a' character, second by 'b' character and third by 'c' character
  6. The 's' character in the grid must be replaced by {a, b or c} whichever is appropriate for the given explorer
  7. The 's' character(s) in the grid must be replaced by '-' character for other explorer(s)
  8. Output grids must be separated by a blank line
  9. See example section for better understanding


Constraints:
1. It is guaranteed that there will always be exactly one shortest path for one explorer from a given location

Sample Input and Output


SNo.InputOutput
1
4 4
w - d -
w - w -
w - w w
s - - s
-1

w - d -
w a w -
w a w w
a - - -

w - d -
w b w -
w b w w
- - b b
2
4 4
s - - s
- - - -
- - - -
s - - d
-1

a - - -
- a - -
- - a -
- - - d

- - - b
- - - b
- - - b
- - - d

- - - -
- - - -
- - - -
c c c d


Explanation for sample input and output 1: 

Figure 1.

Figure 2.
                                                 

Note: - The output format shown above is for understanding purpose such that it highlights the shortest path between the explorer and the base camp. The examples in above table depicts output in text format as you will be required to provide.

Note:

Please do not use package and namespace in your code. For object oriented languages your code should be written in one class.
Note:

Participants submitting solutions in C language should not use functions from / as these files do not exist in gcc
Note:

For C and C++, return type of main() function should be int.

TCS CodeVita 2016 Round1 Question: Min Product Array

$
0
0


The task is to find the minimum sum of Products of two arrays of the same size, given that k modifications are allowed on the first array. In each modification, one array element of the first array can either be increased or decreased by 2.

Note- the product sum is Summation (A[i]*B[i]) for all i from 1 to n where n is the size of both arrays
Input Format: 
  1. First line of the input contains n and k delimited by whitespace
  2. Second line contains the Array A (modifiable array) with its values delimited by spaces
  3. Third line contains the Array B (non-modifiable array) with its values delimited by spaces

Output Format:

Output the minimum sum of products of the two arrays
Constraints:
  1. 1 ≤ N ≤ 10^5
  2. 0 ≤ |A[i]|, |B[i]| ≤ 10^5
  3. 0 ≤ K ≤ 10^9



Sample Input and Output


SNo.InputOutput
1
3 5
1 2 -3
-2 3 -5

-31
2
5 3
2 3 4 5 4
3 4 2 3 2

25

Explanation for sample 1:

Here total numbers are 3 and total modifications allowed are 5. So we modified A[2], which is -3 and increased it by 10 (as 5 modifications are allowed). Now final sum will be
(1 * -2) + (2 * 3) + (7 * -5)
-2 + 6 - 35
-31

-31 is our final answer.

Explanation for sample 2:

Here total numbers are 5 and total modifications allowed are 3. So we modified A[1], which is 3 and decreased it by 6 (as 3 modifications are allowed).
Now final sum will be
(2 * 3) + (-3 * 4) + (4 * 2) + (5 * 3) + (4 * 2)
6 - 12 + 8 + 15 + 8
25

25 is our final answer. 

Simplified Pseudo Code:

1. Initialize maxDiff = 0, minimumSum = 0
2. For i to n
    i. product = A[i] * B[i]
    ii. if ( product < 0 && B[i] < 0 ) then
            temp = (A[i] +  2  * k ) * B[i]
        else if( product < 0 && A[i] < 0) then
            temp = (A[i] - 2 * k) * B[i]
        else if( product > 0 && A[i] < 0) then
               temp = (A[i] + 2 * k) * B[i]
        else if (product > 0 && A[i] > 0)
               temp = (A[i] - 2 * k)  * B[i]
    iii. diff =  abs(product - temp)
    iV. if( diff > maxDiff )
         maxDiff = diff
     V. minimumSum = minimumSum + product

3. minimumSum = minimumSum - maxDiff

Mail us your TCS CodeVita question at vikash@programminggeek.in




         

TCS CodeVita 2016 Round1 Question: Consecutive Prime Sum

$
0
0
Problem : Consecutive Prime Sum



Some prime numbers can be expressed as Sum of other consecutive prime numbers.
For example

5 = 2 + 3
17 = 2 + 3 + 5 + 7
41 = 2 + 3 + 5 + 7 + 11 + 13

Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2.

Write code to find out number of prime numbers that satisfy the above mentioned property in a given range.

Input Format:

First line contains a number N
Output Format:

Print the total number of all such prime numbers which are less than or equal to N.
Constraints:
1. 2

Sample Input and Output


SNo.InputOutputComment
1202
(Below 20, there are 2 such numbers: 5 and 17).
5=2+3
17=2+3+5+7
2151



Pseudo Code:

1. Find all the prime numbers till N
    i.  A  is an array length N + 1 initialized with numbers from 0 to N                 (0,1,2, ..., N)
    ii. initialize p = 2
        a.  for p = 2 to p * p <= N ; p++
               if A[p] != 0 then
                  for  i = p * 2; i <= N; i += p
                         A[i] = 0 // mark non prime as 0
2.  sum = 5, count = 0
3. for j = 5 to j <= N;  j = j+2
    i.  if  ( (A[j]  != 0 && A[j] = sum) || A[j] = -1)
        count = count + 1
    ii. if (A[j] != 0 || A[j] == -1)
        sum = sum + j
        if ( A[sum] != 0) // if A[sum] is prime
            A[sum] = -1 // mark A[sum] as sum of consecutive
4. print count


TCS CodeVita 2016 Round1 Question: Logic Pyramid

$
0
0
Problem : Logic Pyramid



Identify the logic behind the series

6 28 66 120 190 276....

The numbers in the series should be used to create a Pyramid. The base of the Pyramid will be the widest and will start converging towards the top where there will only be one element. Each successive layer will have one number less than that on the layer below it. The width of the Pyramid is specified by an input parameter N. In other words there will be N numbers on the bottom layer of the pyramid.

The Pyramid construction rules are as follows
1.    First number in the series should be at the top of the Pyramid
2.    Last N number of the series should be on the bottom-most layer of the Pyramid, with Nth number being the right-most number of this layer.
3.    Numbers less than 5-digits must be padded with zeroes to maintain the sanctity of a Pyramid when printed. Have a look at the examples below to get a pictorial understanding of what this rule actually means.
Example

If input is 2, output will be

 00006
00028 00066

If input is 3, output will be

  00006
 00028 00066
00120 00190 00276

Formal input and output specifications are stated below 
Input Format: 

First line of input will contain number N that corresponds to the width of the bottom-most layer of the Pyramid 
Output Format: 

The Pyramid constructed out of numbers in the series as per stated construction rules 
Constraints:
1.    0 < N <= 14


Sample Input and Output
SNo.
Input
Output
1
2

https://www.tcscodevita.com/CodevitaV5/images/pyramid2.png
2
3

https://www.tcscodevita.com/CodevitaV5/images/pyramid1.png


Pseudo Code: 
The series is subset of Hexagonal Number generated using formula: n * ( 2 * n -1 )

If n is only even number then you will get the series as 6, 28, 66, 120, 190, 276, 378,  496, 630, 780, 946, 1128, 1326, 1540 and so on.

1. for i = 0 to i  < N; i++
    a. print blank space for (N- i - 1) times
    for j = 0 to j <= i ; j++ 
            a. n = ( i + j +1 ) * 2 
        b. num =  n  * ( 2 * n  - 1 )  
        c. if number of digit in num < 5
               print 0 for (number of digit in num - 5) times
        d. print num
        e. if (  j < i )
               print space







Christmas Tree: TCS CodeVita 2016 Round1 Question

$
0
0
Problem : Christmas Tree


Chirag is a pure Desi boy. And his one and only dream is to meet Santa Claus. He decided to decorate a Christmas tree for Santa on coming Christmas. Chirag made an interesting Christmas tree that grows day by day.

The Christmas tree is comprised of the following
  1. Parts
  2. Stand
Each Part is further comprised of Branches. Branches are comprised of Leaves.

How the tree appears as a function of days should be understood. Basis that print the tree as it appears on the given day. Below are the rules that govern how the tree appears on a given day. Write a program to generate such a Christmas tree whose input is number of days.

Rules:

  1. If tree is one day old you cannot grow. Print a message "You cannot generate christmas tree"
  2. Tree will die after 20 days; it should give a message "Tree is no more"
  3. Tree will have one part less than the number of days.
    E.g.
    On 2nd day tree will have 1 part and one stand.
    On 3rd day tree will have 2 parts and one stand
    On 4th day tree will have 3 parts and one stand and so on.
  4. Top-most part will be the widest and bottom-most part will be the narrowest.
  5. Difference in number of branches between top-most and second from top will be 2
  6. Difference in number of branches between second from top and bottom-most part will be 1
Below is an illustration of how the tree looks like on 4th day



Input Format:

First line of input contains number of days denoted by N
Output Format:

Print Christmas Tree for given N

OR

Print "You cannot generate christmas tree" if N <= 1

OR

Print "Tree is no more" if N > 20
Constraints:
  1. 0<= N <=20

Sample Input and Output


SNo.InputOutput
12

Exam Efficiency: TCS CodeVita 2016 Round1 Question

$
0
0
Problem : Exam Efficiency



In an examination with multiple choice questions, the following is the exam question pattern.
  • X1 number of One mark questions, having negative score of -1 for answering wrong
  • X2 number of Two mark questions, having negative score of -1 and -2 for one or both options wrong
  • X3 number of Three mark questions, having negative score of -1, -2 and -3 for one, two or all three options wrong
  • Score Required to Pass the exam : Y
  • For 1,2 and 3 mark questions, 1,2 and 3 options must be selected. Simply put, once has to attempt to answer all questions against all options.
Identify the minimum accuracy rate required for each type of question to crack the exam.

Calculations must be done up to 11 precision and printing up to 2 digit precision with ceil value

Input Format:

First line contains number of one mark questions denoted by X1,
Second line contains number of two mark questions denoted by X2
Third line contains number of three mark questions denoted by X3
Fourth line contains number of marks required to pass the exam denoted by Y.
Output Format:

Minimum Accuracy rate required for one mark question is 80%
Minimum Accuracy rate required for Two mark question is 83.33%
Minimum Accuracy rate required for Three mark question is 90%


Note: - If the mark required to pass the exam can be achieved by attempting without attempting any particular type of question then show message similar to, One mark question need not be attempted, so no minimum accuracy rate applicable

See Example Test cases for better understanding.

Sample Input and Output


SNo.InputOutputExplaination
1
20
30
30
120

One mark questions need not be attempted, so no minimum accuracy rate applicable.
Minimum Accuracy rate required for Two mark question is 58.33%
Minimum Accuracy rate required for Three mark question is 72.23% 

If one got full marks in two marks question and three marks question then total accuracy can be 0 in one mark question

In same way it will be done for two marks and three marks question
2
20
30
30
170

Minimum Accuracy rate required for one mark question is 100%
Minimum Accuracy rate required for Two mark question is 100%
Minimum Accuracy rate required for Three mark question is 100% 

If one got full marks in two marks question and three marks question then total accuracy should be 100% in one mark question to pass the exam.

In same way it will be done for two marks and three marks question

House Numbers: TCS CodeVita 2016 Round1 Question

$
0
0
Problem : House Numbers



There are a number of buildings of different sizes (width) and with different number of floors. Each may have zero, one or more flats marked with a different character, say $. Identify these flats and print the address in form of building number, floor and flat number.

Buildings are separated from each other by a space character. Floors start from 1 i.e. the lowest floor is the first floor. Also flat numbers are assigned from left to right. The $ character is the flat of interest for which we have to find the address.

For example,


The above is an example of a colony with 4 buildings. The first building has 5 floors with 4 flats on each floor. The flat marked by $ in the first building can be identified as 134 (building 1, floor 3 and flat 4). Similarly, the flat marked by $ in the second building can be identified as 223 (building 2, floor 2 and flat 3).

A file containing a random colony will be given as an input to your program. You have to identify all flats marked by $ in the colony. Note that there is no limit to the number of buildings, floors or flats.
Input Format:

Text file path
Output Format:

Print Building number(B), floor number(F), Flat numbers(R) of all flats marked by $ in the following format:

Constraints:
Print order for $-marked flats should be from top floors to bottom floors and left building to right building

Sample Input and Output


SNo.InputContents Of Input FileOutput
1/tmp/T1.txt
232
2/tmp/T2.txt
>
152
142
341
221
223
111
213



Viewing all 82 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>