Programs On Operators
Programs On Operators
3)Harry Potter
Having crossed the three-headed faun, Harry, Dumbledore, and Snape went
through a secret trap door in search of the Sorcerer's tomb. On the way, they
passed through a room and found that the room has only one door opposite to
them, and the door through which they entered shut once they entered the room.
The door was very large with a four-digit number imprinted on it. When Harry
and Dumbledore tried to open it by casting out spells, it didn't open. Having
tried various spells, both got fed up and left the task to Snape. Snape curiously
observing the room found that a statement was written on the top of the room. It
was written as follows "I will be always four" “I can only be opened when you
add my first and last digit and enter it” and “If you find a sign, you should not
consider it” help Snape break the code and open the door so that they can save
the Sorcerer's tomb.
Input Format
Input consists of an integer which is a four-digit number present on the door.
Constraints
NA
Output Format
The output is a single integer.
Sample Input 0
1001
Sample Output 0
2
Sample Input 1
1110
Sample Output 1
1
4) Splitting into the teams
During the weekend, Ross Geller has decided to conduct some team games. He
wants to split his friends into equal-sized teams. In some cases, some friends
may be left out of the teams, and he wanted to use the left-out friends to assist
him in conducting the team games. For instance, if there are 50 friends and they
have to be divided into 7 equal-sized teams, then there will be 7 in each team
and 1 friend will be left out. Ross asks for your help to automate this team-
splitting task. Can you please help him out?
Input Format
Input consists of 2 integers. The first integer corresponds to the number of
friends Ross has. The second integer corresponds to the number of teams.
Constraints
NA
Output Format
Refer sample input and output for formatting specifications.
Sample Input 0
60
8
Sample Output 0
The number of friends in each team is 7 and left out is 4
Sample Input 1
78
6
Sample Output 1
The number of friends in each team is 13 and left out is 0
5) Debt Repay
Leena wanted to start a business and she was looking for a venture capitalist.
Through her friend, she met a construction company owner Meena, who was
interested in investing in an emerging business. Looking at the business
proposal, the owner was very much impressed with Leena's work. So she
decided to invest in Leena's business and hence gave a green signal to go ahead
with the project. Leena got a loan of Rs. X for a period of Y years from the
owner at R% interest per annum. Find the rate of interest and the total amount to
be returned by Leena to the owner. The owner was impressed by the proper
repayment of the financed amount and decides to give a special offer of a 2%
discount on the total interest at the end of the settlement. Find the discount
amount and also find the total amount given back by Leena.
Note: All rupee values should be in two decimal points.
Input Format
Input consists of 3 floating point values. The first one corresponds to the
principal amount borrowed by Leena. The second one corresponds to the rate of
interest The third one corresponds to the number of years.
Constraints
NA
Output Format
The output consists of 4 floating point values. The first value corresponds to the
interest. The second value corresponds to the amount. The third value
corresponds to the discount. The last value corresponds to the final settlement.
All floating point values are to be rounded off to two decimal places.
Sample Input 0
100
1
10
Sample Output 0
10.00
110.00
0.20
109.80
Sample Input 1
40
1
10
Sample Output 1
4.00
44.00
0.08
43.92
6) 3 Psychos
Mani, Arun, and Kumar were very close friends at school. They were very good
in Mathematics and were the pets of Ranjani Ma'am. Mani, Arun, and Kumar
live in the same locality and their gang was known as 3 - Psychos. A new
student Logan joins their class and he wanted to be friends with the 3 - Psychos.
Logan asked Arun about his home address. Arun wanted to test Logan's
mathematical skills and hence told that his house is at the midpoint of the line
joining Mani's house and Kumar's house. Logan was puzzled. Can you help
Logan out? Given the coordinates of the 2 endpoints of a line (x1,y1) and
(x2,y2). Write a program to find the midpoint of the line.
Input Format
Input consists of 4 integers. The first and second value corresponds to x1 and y1
respectively. The third and fourth value correspond to x2 and y2 respectively.
Constraints
NA
Output Format
Refer sample input and output for the exact formatting specifications.
Print with 1 decimal place
Sample Input 0
2
4
10
15
Sample Output 0
Arun's house is located at(6.0,9.5)
Sample Input 1
9
6
5
3
Sample Output 1
Arun's house is located at(7.0,4.5)
**************************************************************
7)Hop n Hop
Peter Rabbit lives in a colony. He is the only rabbit in his colony who is not able
to hop. On his 5th birthday, his father Rabbit gifted him a pogo stick as he could
not jump like the other rabbits. He is so excited to play with the pogo stick. The
pogo stick hops one unit per jump. He wanders around his house jumping with
pogo sticks. He wants to show the pogo stick to his friend and decides to go
using his pogo stick. Write a program to find the number of hops needed to
reach his friends' house (x,y). Assume that Peter Rabbit's house is in the
coordinates (3,4).
Input Format
Input consists of two integers x and y.
Constraints
NA
Output Format
The output is an integer. It corresponds to the number of hops needed to reach
his friend's house.
Sample Input 0
5
10
Sample Output 0
6
8)Treasure Hunter
Though there have been more successful pirates, Blackbeard is one of the best-
known and widely feared of his time. He commanded four ships and had a
pirate army of 300 at the height of his career and defeated the famous warship,
HMS “Scarborough” in a sea battle. He was known for barreling into the battle
clutching two swords with several knives and pistols at the ready. He captured
over forty merchant ships in the Caribbean and without flinching killed many
prisoners. Now, Blackbeard and his three pirates found a treasure of gold coins.
Long Ben too joined them. They decided to share the treasure. Blackbeard
agreed to give x% share for Long Ben. He then decided to take y% share from
the remaining treasure. His other pirates will share the remaining gold coins
equally. Write a program to compute their shares. After sharing the gold coins in
this manner, if there are any leftover coins they decided to throw them into the
sea.
Input Format
Input consists of 3 integers. The first input corresponds to the number of gold
coins in the treasure. The second input corresponds to Ben's share percentage.
The last input corresponds to Blackbeard's share percentage.
Constraints
NA
Output Format
The output consists of three integers. The first output integer corresponds to
Long Ben's share. The second output integer corresponds to Blackbeard's share.
The third output should correspond to the other 3 pirates' equally divided shares.
Sample Input 0
729
65
87
Sample Output 0
473
222
11
Sample Input 1
654
87
65
Sample Output 1
568
55
10
*******************************************************