36% found this document useful (14 votes)
22K views30 pages

InfyTQ Coding Questions Set 3

The document describes an event management startup called "Pine Tree" that has gained a good reputation. The founder Nikhil wants to design an online event management system called "Pineaxe" and needs code to display a welcome message. It provides sample code to output the text "Welcome to Pineaxe Event Management System".

Uploaded by

Walker Sanket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
36% found this document useful (14 votes)
22K views30 pages

InfyTQ Coding Questions Set 3

The document describes an event management startup called "Pine Tree" that has gained a good reputation. The founder Nikhil wants to design an online event management system called "Pineaxe" and needs code to display a welcome message. It provides sample code to output the text "Welcome to Pineaxe Event Management System".

Uploaded by

Walker Sanket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

1) Welcome Message

"Pine Tree" is a recently launched startup Event Management company. The


company gained a good reputation within a short span because of its highly
reliable service delivery.
Nikhil, the founder of this company wished to take the company’s services to the next step
and decided to design an Event Management System that would let its Customers plan and
host events seamlessly via an online platform. As a part of this requirement, Nikhil wanted
to write a piece of code for his company’s Pineaxe Event Management System that will
welcome all the Customers who are using it. Help Nikhil on the task.
Input Format
No input
Output Format
Output should display "Welcome to Pineaxe Event Management System’.
Sample Testcases
Testcase 1 input Testcase 1 Output
Welcome to Pineaxe Event Management System
Video Solution Link : https://youtu.be/bCrLR5yUIN8
2) Raju borrowed Rs. 20000 from Ramu at an interest rate of 5% . Write a
program to find the simple interest for 5 units of time.
(Simple interest is given by: SI = (P*T*R)/100 where P is the principle amount,
T is the time, R is the rate).
Input Format
Input is directly given in the program
Output Format
Output is the number representing the simple interest
sample Testcases
Testcase 1 Input Testcase 1 Output
5000.0

Video Solution Link: https://youtu.be/23gY-E2qXhg


3) Write a python program to add 24 and 20.

Sample Testcases
Testcase 1 Input Testcase 1 Output
44

Video Solution link: https://youtu.be/XHv3R6TQChs


4) Write a Python program to print "Welcome to Python Programming".

Sample Testcases
Testcase 1 input Testcase 7 Output
Welcome to Python Programming

Video Solution Link: https://youtu.be/NBm9TnCznaw


5) CHANGE POSITION
The room that Patrick and Johnny were staying in was very big. They felt lazy to
walk inside the room from the bed's location to another location. So they wanted
to change the position of the bed. The shape of the room is a Square. They decided to place
the bed at the exact center of the room so that their walking distance would be minimized.
Can you please help them in placing the bed at the exact center?
Given the coordinates of the left bottom vertex of the square room and the length of the
side, you need to write a program to determine the coordinates of the center of the room.
[Assumption --- Length of the side is always even]
Input Format
Input consists of 3 integers. The first integer corresponds to the x-coordinate of the left
bottom vertex. The second integer
corresponds to the y-coordinate of the left bottom vertex. The third integer corresponds to
the length of the square.
Output Format
Refer Sample Input and Output for exact formatting specifications.
Sample Testcases
Testcase 1 Input Testcase 1 Output
10 The center of the room is at (18,38)
30
16

Video Solution Link: https://youtu.be/XamuzzTVYQk


6) Talent Show
Mountain View Middle School is all set for organizing their elaborate talent show
event of the year, “Stars Onstage’. It is a fun-filled event for the students to
showcase and build their confidence.
Of the total audience who had come for the show, 1/3 were boys, 3/6 were girls and the rest
of them were adults. If there were 'x' more girls than adults, how many people were there in
total? Help the School authorities to find the total people who visited their show.
Input Format
First line of the input is an integer ‘x’, which corresponds to the count of girls more than adults.
Output Format
Output the total number of people who had visited the talent show.
Refer to sample input and output for formatting specifications.
Sample Testcases
Testcase 1 Input Testcase 1 Output
50 150

Testcase 2 Input Testcase 2 Output


70 210
Video Solution Link : https://youtu.be/FTPOwZ69Ruw

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
7) Total Expenses for the Event
The prime functionality of an Event Management System is budgeting. An Event
Management System should estimate the total expenses incurred by an event
and the percentage rate of each of the expenses involved in planning and executing
an event. Nikhil, the founder of "Pine Tree” wanted to include this functionality in his
company's Pine axe Event Management System and requested your help in writing a program
for the same. The program should get the branding expenses, travel expenses, food expenses
and logistics expenses as input from the user and calculate the total expenses for an event and
the percentage rate of each of these expenses.
Input Format
First input is a double value that corresponds to the branding expenses.
Second input is a double value that corresponds to the travel expenses.
Third input is a double value that corresponds to the food expenses.
Fourth input is a double value that corresponds to the logistics expenses.
Output Format
First line of the output should display the double value that corresponds to the total expenses
for the Event.
Next four lines should display the percentage rate of each of the expenses.
Refer to sample input and output for formatting specifications.
Constraints
Use format function to display the decimal values rounded off up to two decimal
places.
Sample Testcases
Testcase 1 Input Testcase 1 Output
20000 100000.00
40000 20.00%
15000 40.00%
25000 15.00%
25.00%
Testcase 2 Input Testcase 2 Output
20001 100021.00
40005 20.00%
15009 40.00%
25006 15.01%
25.00%
Video Solution Link : https://youtu.be/UzUYTYEWmfo

This video is sole property of Talent Battle Pvt. Ltd. Strict penal action will be taken against unauthorized piracy of this video
8) Given 2 integers N and M, add both the numbers and check whether the sum is
odd or even.
Input Format
First-line contains integer 1
Second-line contains integer 2
Output Format
Output describes weather the condition provided in the problem satisfies or not.
Sample Testcases
Testcase 1 Input Testcase 1 Output
9 odd
2
Testcase 2 Input Testcase 2 Output
10 even
2

Video Solution Link : https://youtu.be/5VJiPhW8_RQ


9) Given 2 integers N, M find the GCD of N and M. If it cannot be found for a
given number(s) then print -1
Input Format
First line of input contains a value
Second line of input contains value2
Output Format
Output displays the GCD of two input integers.
If GCD cannot be found print -1
Sample Testcases
Testcase 1 Input Testcase 1 Output
5 5
10

Testcase 2 Input Testcase 2 Output


0 -1
0
Video Solution Link : https://youtu.be/k-ovEX9_-KM
10) Given 2 numbers N, K print the number after performing right shift ‘K’
times of number N.
Input Size : 1 <= N, K <= 1000.
Input Format
First line of input contains integer N
Second line of input contains integer K
Output Format
Output prints the k'" right shift of value N.
Sample Testcases
Testcase 1 Input Testcase 1 Output
5 1
2

Testcase 2 Input Testcase 2 Output


9 4
1
Video Solution Link : https://youtu.be/PayMZ1qzD4E
11) Given a number N, print the Bit wise NOT of the number.
input Size : 1 <= N <= 10000
Input Format
Input consists of an integer.
Output Format
Output consists of bitwise NOT of the input integer.
Sample Testcases
Testcase 1 Input Testcase 1 Output
5 -6

Testcase 2 Input Testcase 2 Output


1 -2

Video Solution Link : https://youtu.be/shRo9LR5r4U


12) How many possible ways are to shuffle the given number of playing cards?.
Input Size : |N| <= 1000000.
Input Format
Input consists of an integer denoting the number of cards.
Output Format
Output displays the number of possible ways.
Sample Testcases
Testcase 1 Input Testcase 1 Output
3 6

Testcase 2 Input Testcase 2 Output


7 5040

Video Solution Link : https://youtu.be/tA3DQEqy9LY


13) Alternating Code
It is IPL season and the first league match of Dhilip’s favorite team, "Chennai
Super Kings". The CSK team is playing at the IPL after 2 years and like all Dhoni
lovers, Dhilip is also eagerly awaiting to see Dhoni back in action.
After waiting in long queues, Dhilip succeeded in getting the tickets for the big match. On the
ticket, there is a letter-code that can be represented as a string of upper-case Latin letters.
Dhilip believes that the CSK Team will win the match in case exactly two different letters in
the code alternate. Otherwise, he believes that the team might lose. Please see note section
for formal definition of alternating code.
You are given a ticket code. Please determine, whether CSK Team will win the match or not
based on Dhilip's conviction. Print "YES" or "NO" (without quotes) corresponding to the
situation.
Note:
Two letters x, y where x != y are said to be alternating in code, if code is of form “xyxyxy...”.
Input Format
First and only line of the input contains a string S denoting the letter code on the ticket.
Output Format
Output a single line containing "Yes" (without quotes) based on the conditions
given and "No" otherwise.
Refer to sample input and output for formatting specifications.
Sample Testcases
Testcase 1 Input Testcase 1 Output
ABABAB Yes

Video Solution Link : https://youtu.be/L_EMo1n_8kE


14) Balls for Challenge
The Circoloco Children Carnival is the City’s largest and successful event dedicated
to children and families. The main focus at the carnival is the workshop arena
where kids can participate in engaging and educational activities.
Charlie, a little boy accompanied by his Mom visited the fair, where he participated at the
“Balls for Challenge” activity. He was given many balls of white and black colours. During the
play, he arranged the balls into two rows both consisting of N number of balls. These two
rows of bails are given to you in the form of strings X, Y. Both these string consist of ‘W' and
‘B’, where 'W' denotes a white-coloured ball and 'B' a black coloured.
Other than these two rows of balls, Charlie has an infinite supply of extra balls of each colour.
He wants to create another row of N balls, Z in such a way that the sum of Hamming distance
between X and Z, and the hamming distance between Y and Z is maximized.
Hamming Distance between two strings X and Y is defined as the number of positions where
the colour of balls in row X differs from the row Y ball at that position. e.g. Hamming distance
between "WBB’", "BWB" is 2, as at position 1 and 2, corresponding colours in the two strings
differ. As there can be multiple such arrangements of row Z, Charlie wants you to find the
lexicographically smallest arrangement which will maximize the above value.
Input Format
First line of the input will contain a string X denoting the arrangement of balls in
first row. Second line of the input will contain the string Y denoting the
arrangement of balls in second row.
Output Format
Output a single line containing the string of length N denoting the arrangement of colors of
the balls belonging to row Z.
Refer to sample input and output for formatting specifications.
Sample Testcases
Testcase 1 input Testcase 1 Output
BBBW WBWB
BWBB

Video Solution link : https://youtu.be/mfPy1r6zxgc


15) Caption Contest
Exeter Caption Contest is a competition open to all writers worldwide. The
entrants will have one day to compose and submit a caption that will be based on
the theme posted on the competition page.
Robin, a creative writer had penned two captions for the contest but he unknowingly
misplaced them. After searching long, he managed to locate his captions, but some letters
in them have become unreadable. The captions were in two very old sheets of paper, each
of which originally contained a string of lowercase English letters. The strings on both the
sheets have equal lengths.
Robin would like to estimate the difference between these strings. Let's assume that the
first string is named S1, and the second S2. The unreadable symbols are specified with the
question mark symbol ‘2’. The difference between the strings equals to the number of
positions i, such that S1i is not equal to S2i, where S1i and S2i denote the symbol at the i th
position in S1 and S2, respectively.
Robin would like to know the minimal and the maximal difference between the two strings
if he changes all unreadable symbols to lowercase English letters. Robin is not an expertise
in programming and so he needs your help solving this problem!
Input Format
The first line of the input contains a string S1.
The second line of the input contains a string S2.
Both strings consist of lowercase English letters and question marks in places where
the symbols are unreadable.
Output Format
Output the minimal and the maximal difference between two given strings separated with
a single space.
Refer to sample input and output for formatting specifications.
Sample Testcases
Testcase 1 Input Testcase 1 Output
a?c 13
??b

Video Solution Link : https://youtu.be/knaDeNVV2Io


16) Little Authors
“Little Authors" Slogan Writing Competition was organized for School students at
Orchids Senior School. Any student who is creative and effective in communicating
ideas in short, yet powerful about any instant topic can participate in the competition.
The important guideline for the contest is that the Slogan should contain a string where the
number of occurrences of some character in it is equal to the sum of the numbers of
occurrences of other characters in the string.
Input Format
First and only line of input contains one string S consisting of a lowercase letter
Output Format
Refer to sample input and output for formatting specifications.
Sample Testcases
Testcase 1 Input Testcase 1 Output
acab Yes

Video Solution Link: https://youtu.be/FnKz5zUv3zM


17) Nela's Birthday and Colourful Balloons
Nella is an eight-year-old princess who will inherit the kingdom of Castle haven.
It is her birthday today and her Dad, the King of Castle haven has arranged for a
grand party. Nella loves colourful balloons and so her Dad planned to decorate the
entire palace with balloons of the colours that Nella loved. So he asked her about her colour
preferences. The sophisticated princess that Nella is, she likes only two colours — amber
and brass. Her Dad bought n balloons, each of which was either amber or brass in colour.
You are provided this information in a string s consisting of characters ‘a’ and ‘b' only, where
‘a’ denotes that the balloon is amber, where ‘b' denotes it being brass coloured. When Nella
saw the balloons, she was furious with anger as she wanted all the balloons of the same
colour. In her rage, she painted some of the balloons with the opposite colour (i.e., she
painted some amber ones brass and vice versa) to make all balloons appear to be the same
colour.
It took her a lot of time to do this, but you can probably show her the right way of doing so,
thereby teaching her a lesson to remain calm in difficult situations, by finding out the
minimum number of balloons needed to be painted in order to make all of them the same
colour.
Input Format
The first and only line of input contains a string s.
Output Format
Output a single line containing an integer — the minimum number of flips required.
Refer to sample input and output for formatting specifications.
Sample Testcases
Testcase 1 Input Testcase 1 Output
ab 1

Video Solution Link : https://youtu.be/aC1TbSmzu78


Sample Testcases
Testcase 1 Input Testcase 1 Output
10111010111 Win

Testcase 2 Input Testcase 2 Output


00000101011110000 Lose

Video Solution Link : https://youtu.be/EzAe7lnqhhg


18) Number Challenge
Mike set off with great zeal to the "Kracker Jack Fun Fair 2017". There were
numerous activities in the fair, though Mike being a math expert, liked to
participate in the Number Challenge.
Mike was given a string D of numbers containing only digits 0's and 1's. His challenge was to
make the number to have all the digits the same. For that, he should change exactly one
digit, i.e. from 0 to 1 or from 1 to 0. If it is possible to make all digits equal (either all 0's or all
1's) by flipping exactly 1 digit then he has to output “Yes’, else print "No" (without quotes).
Write a program to help Mike win over his challenge.
Input Format
First and only input contains a string D of numbers made of only digits 1's and 0's.
Output Format
Output “Yes" or a "No", depending on whether it's possible to make it all Os or 1s or not.
Refer to sample input and output for formatting specifications.
Sample Testcases
Testcase 1 input Testcase 1 Output
101 Yes
Video Solution Link : https://youtu.be/CZq8_A9nIPQ
19) Peter at Challenger Series
The Table tennis Challenger Series is the springboard to fame for the future stars
of professional table tennis. Peter is very passionate towards table tennis and
made his debut in the first league match of the Series against a prominent player
Horejsi. Peter found some statistics of matches which described who won the points in order.
A game shall be won by the player first scoring 11 points except in the case when both players
have 10 points each, then the game shall be won by the first player subsequently gaining a
lead of 2 points. Could you please help Peter find out who the winner was from the given
statistics? (It is guaranteed that statistics represent always a valid, finished match.)
Input Format
First and only line of the input consists of a binary string S, which describes a match. ‘0’ means
Peter lose a point, whereas '1'
means he won the point.
Output Format
Output on a separate line a string describing who won the match. If Peter won then print
"Win" (without quotes), otherwise print
"Lose" (without quotes).
Refer to sample input and output for formatting specifications.
20) Wildcard Matching
Sunil is a little scientist. Sunil has planned to design a wildcard pattern matcher
to exhibit at the "Young Inventors", a tech talent show organized at his school.
Sunil wanted to design the wildcard pattern matcher supporting the wildcard
character '?'. The wildcard character ‘?' can be substituted by any single lower case English
letter for matching. He has two strings X and Y of equal length, made up of lower case letters
and the character '?’. Sunil wants your help in designing the device, to know whether the
strings X and Y can be matched or not. Write a program to check whether the given strings
can be matched or not.
Input Format
First line of the input contains the string ‘x’.
Second line of the input contains the string ‘V’.
Output Format
Output a single line with the word "Yes‘(without quotes) if the strings can be matched,
otherwise output "No"(without quotes).
Refer sample input and output for formatting specifications.
Sample Testcases
Testcase 1 Input Testcase 1 Output
s?or? Yes
sco??

Video Solution Link : https://youtu.be/Rd9eY3B1sKM

You might also like