KEMBAR78
Python Easy Challenges | PDF | Arithmetic | Number Theory
0% found this document useful (0 votes)
15 views33 pages

Python Easy Challenges

The document outlines various programming problems that require specific input and output formats. Each problem includes constraints, examples, and the expected results for given inputs. The problems cover topics such as leap year determination, counting common characters in strings, simple arithmetic operations, and more.
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
0% found this document useful (0 votes)
15 views33 pages

Python Easy Challenges

The document outlines various programming problems that require specific input and output formats. Each problem includes constraints, examples, and the expected results for given inputs. The problems cover topics such as leap year determination, counting common characters in strings, simple arithmetic operations, and more.
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/ 33

Check leap year

ID:2581

Solved By 15397 Users

A year Y will be passed as input. The program must find if the given year is a leap year or not.
- If it is leap year, the program must print yes else it should print no
Note: A year is a leap year if it is divisible by 4. If it is a century then it should be divisible by 400.
The pseudocode is as given below.
if year is divisible by 400 then is_leap_year
else if year is divisible by 100 then not_leap_year
else if year is divisible by 4 then is_leap_year
else not_leap_year
Example Input/Output:
If 2000 is the input, the program must print yes
If 2100 is the input, the program must print no
If 2013 is the input, the program must print no
Input Format:
A year as a number is passed to the standard input.
Output Format:
The string value as per the conditions above printed to the standard output.
Boundary Conditions:
0 < Y <= 8000

Max Execution Time Limit: 10000 millisecs


Head Count - Birds and Animals

ID:2588

Solved By 14103 Users

In a zoo there are some birds and animals. All birds have two legs and all animals have four legs.
GIven the head count and leg count of both birds and animals taken together, the program must print the head
count of birds and animals separated by a space as output.
Input Format:
First line will contain the integer value H representing the head count of both birds and animals taken together.
Second line will contain the integer value L representing the leg count of both birds and animals taken together.
Output Format:
First line will contain the integer values of the head count of birds and animals separated by a space.
Constraints:
0 < H < 1000
1 < L < 2000
Sample Input/Output:
Example 1:
Input:
27
84
Output:
12 15
Explanation:
There are 12 birds and 15 animals.
Example 2:
Input:
114
256
Output:
100 14
Explanation:
There are 100 birds and 14 animals.

Max Execution Time Limit: 10000 millisecs


Convert rupee to paise

ID:2587

Solved By 13886 Users

A floating point value F indicating the amount in rupees is passed as input. The program must print the
corresponding value in paise.
Note: 1 rupee = 100 paise.
Input Format:
The first line contains F.
Output Format:
The first line contains the integer value denoting the paise.
Boundary Conditions:
0.00 <= F <= 999999.99
Example Input/Output 1:
Input:
11.30
Output:
1130
Example Input/Output 2:
Input:
0.80
Output:
80
Example Input/Output 3:
Input:
0.0
Output:
0

Max Execution Time Limit: 5000 millisecs


Reverse Number Sign

ID:2590

Solved By 13744 Users

An integer value N is passed as the input. The program must reverse the sign of N and print -N as the output.
Input Format:
The first line contains N.
Output Format:
The first line contains -N.
Boundary Conditions:
-999999 <= N <= 999999
Example Input/Output 1:
Input:
125
Output:
-125
Example Input/Output 2:
Input:
-346
Output:
346
Example Input/Output 3:
Input:
0
Output:
0

Max Execution Time Limit: 5000 millisecs


Count of common characters in two strings

ID:2583

Solved By 11881 Users

Two string values S1 and S2 are passed as input. The program must print the count of common characters in the
strings S1 and S2. Assume the alphabets in S1 and S2 will be in lower case.
Input Format:
First line will contain the value of string S1
Second line will contain the value of string S2
Output Format:
First line will contain the count of common alphabets.
Boundary Conditions:
Length of S1 and S2 will be from 3 to 100.
Sample Input/Output:
Example 1:
Input:
china
india
Output:
3
Explanation:
The common characters are i,n,a

Example 2:
Input:
energy
every
Output:
3
Explanation:
The common characters are e,r,y

Max Execution Time Limit: 5000 millisecs


Reverse String Till Underscore

ID:2584

Solved By 11250 Users

String S is passed as the input to the program. S may or may not have a single underscore embedded in it. The
program must reverse the String S till the first underscore and print it as the output.
Input Format:
The first line contains S.
Output Format:
The first line contains the string S modified based on the given conditions.
Boundary Conditions:
Length of S is from 3 to 100.
Example Input/Output 1:
Input:
abcd_pqrs
Output:
dcba_pqrs
Example Input/Output 2:
Input:
_kilo
Output:
_kilo
Example Input/Output 3:
Input:
nounderscore
Output:
erocsrednuon

Max Execution Time Limit: 5000 millisecs


Simple Calculator Command

ID:2586

Solved By 10725 Users

A string S is passed as input. S will contain two integer values separated by one of these alphabets - A, S, M, D
where
- A or a is for addition
- S or s is for subtraction
- M or m is for multiplication
- D or d is for division
The program must perform the necessary operation and print the result as the output. (Ignore any floating point
values just print the integer result.)
Input Format:
The first line contains S.
Output Format:
The first line contains the resulting integer value.
Boundary Conditions:
Length of S is from 3 to 100.
Example Input/Output 1:
Input:
5A11
Output:
16
Explanation:
As the alphabet is A, 5 and 11 are added giving 16.
Example Input/Output 2:
Input:
120D6
Output:
20
Example Input/Output 3:
Input:
1405d10
Output:
140

Max Execution Time Limit: 5000 millisecs


Expand Alphabets

ID:2585

Solved By 10206 Users

A string S is passed as input. S will contain multiple integer values with each integer value followed by an alphabet.
The program must expand the alphabets based on the related integer value.
Input Format:
The first line contains S.
Output Format:
The first line contains the expanded string value.
Boundary Conditions:
Length of S is from 2 to 100.
Example Input/Output 1:
Input:
4a5h
Output:
aaaahhhhh
Explanation:
As it is 4a and 5h, four a's are printed followed by 5 h's
Example Input/Output 2:
Input:
1k2b4k
Output:
kbbkkkk

Max Execution Time Limit: 5000 millisecs


Betting game - Dice roll

ID:2582

Solved By 9855 Users

In a betting game involving the roll of a dice, Sandeep gains Rs.X if an odd number turns up and he loses Rs.Y is an
even number turns up. The numbers shown on the face of the dice in a certain number of games is passed as
input. The values of X and Y are also passed as input. The program must print the net gain or loss as the output.

Input Format:
First line will contain the numbers shown on the face of the dice separated by one or more spaces.
Second line will contain the value of X
Third line will contain the value of Y
Output Format:
The net gain or loss (loss will be a negative value)

Sample Input/Output:
Example 1:
Input:
143
10
30
Output:
-10
Explanation:
He gains 20 rupees for 1 and 3 and loses 30 rupees for 4. Hence there is a net loss of 20-30 = -10

Example 2:
Input:
46121
50
25
Output:
25
He gains 100 rupees for 1,1 and loses 75 rupees for 4,6,2. Hence there is a net gain of 100-75 = 25

Max Execution Time Limit: 10000 millisecs


Count of common factors

ID:2589

Solved By 9631 Users

Given a set of numbers where all other numbers are multiple of the smallest number, the program must find the
count of the common factors C excluding 1.
Input Format:
First line will contain the integer value N representing how many numbers are passed as input.
Next N lines will have the numbers.
Output Format:
First line will contain the count of common factors C.
Constraints:
N will be from 2 to 20.
Sample Input/Output:
Example 1:
Input:
2
100
75

Output:
2
Explanation:
The common factors excluding 1 are 5,25. Hence output is 2
Example 2:
Input:
3
10
20
30
Output:
3
Explanation:
The common factors excluding 1 are 2,5,10. Hence output is 3.

Max Execution Time Limit: 10000 millisecs


Square Matrix - Corner Elements Sum

ID:2605

Solved By 11685 Users

A square matrix of size N×N is passed as the input. The program must calculate and print the sum of the elements
in the corners.
Input Format:
The first line will contain the value of N.
The next N lines will contain the N values separated by one or more spaces.
Output Format:
The first line will contain the integer value denoting the sum of the elements in the corners.
Boundary Conditions:
2 <= N <= 20
Example Input/Output 1:
Input:
3
10 90 1
4 22 5
32 8 66
Output:
109
Explanation:
The sum = 10+1+66+32 = 109

Max Execution Time Limit: 5000 millisecs


Arithmetic Progression - Nth Term

ID:2603

Solved By 10879 Users

The first three terms in an arithmetic progression are passed as input. A positive integer value N (where N > 3) is
also passed as the input. The program must print Nth term in the arithmetic progression.
Input Format:
The first line will contain the first three terms separated by a space.
The second line will contain N.
Output Format:
The integer value denoting the Nth term.
Example Input/Output 1:
Input:
5 10 15
6
Output:
30
Explanation:
The progression is 5 10 15 20 25 30 35 and so on.
The 6th term is 30.
Example Input/Output 2:
Input:
147
5
Output:
13

Max Execution Time Limit: 5000 millisecs


Count the primes in a range.

ID:2608

Solved By 10193 Users

Two whole numbers N1 and N2 are passed as input. The program must print the number of primes present
between N1 and N2 (the range is inclusive of N1 and N2)
Input Format:
First line will contain the value of the first number N1
Second line will contain the value of the second number N2
Output Format:
First line will contain the count of prime numbers between N1 and N2
Sample Input/Output:
Example 1:
Input:
6142
6200
Output:
6
Explanation:
The prime numbers within the range 6142 to 6200 are 6143, 6151, 6163, 6173, 6197, 6199

Example 2:
Input:
38
70
Output:
7
Explanation:
The prime numbers within the range 38 to 70 are 41, 43, 47, 53, 59, 61, 67

Max Execution Time Limit: 5000 millisecs


Rotate String - N Positions

ID:2606

Solved By 9868 Users

A string S of length L is passed as the input. The program must rotate the string S by N position in forward direction
and print the result as the output.
Input Format:
The first line will contain the value of S.
The second line will contain N.
Output Format:
The first line will contain the rotated string value.
Boundary Conditions:
The length L of the string S is from 3 to 100.
0 <= N <= L
Example Input/Output 1:
Input:
cricket
2
Output:
etcrick
Example Input/Output 2:
Input:
truth
5
Output:
truth

Max Execution Time Limit: 5000 millisecs


Arrange Alphabets - Descending Order

ID:2604

Solved By 9501 Users

A string S (with only LOWER case alphabets and length from 3 to 100) will be passed as input. The program should
print the alphabets in the string in descending order.
Input Format:
The first line will contain S.
Output Format:
The first line will contain the alphabets present in S in descending order.
Example Input/Output 1:
Input:
cake
Output:
keca
Example Input/Output 2:
Input:
innovation
Output:
vtonia

Max Execution Time Limit: 10000 millisecs


Concatenate Strings Alphabetically

ID:2610

Solved By 9190 Users

Two string values S1 and S2 are passed as the input. The program must concatenate them depending on which
string comes first in the alphabetical order.
Input Format:
The first line will contain S1.
The second line will contain S2
Output Format:
The first line will contain the concatenated string value.
Boundary Conditions:
Length of S1 and S2 is from 3 to 100.
Example Input/Output 1:
Input:
apple
orange
Output:
appleorange
Example Input/Output 2:
Input:
zoo
tiger
Output:
tigerzoo

Max Execution Time Limit: 5000 millisecs


Character B follows A

ID:2602

Solved By 8854 Users

Given a string S and two characters A, B the program must print the number of occurrences where A is followed
by B.
Boundary Conditions:
Length of the string S is between 2 and 200.

Input Format:
First line will contain the string value S.
Second line will contain the value of A.
Third line will contain the value of B.
Output Format:
First line will contain the integer which represents the number of occurrences in sring S where A is followed by B

Sample Input/Output:
Example 1:
Input:
malayalam
a
l
Output:
2
Explanation:
The two occurrences where a is followed by l is as highlighted below. malayalam

Example 2:
Input:
engine
e
n
Output:
1

Max Execution Time Limit: 10000 millisecs


Next Prime Number

ID:2607

Solved By 8750 Users

A number N is passed as the input. The program must print the next immediate prime number.
Input Format:
The first line will contain N.
Output Format:
The first line will contain the integer value of next immediate prime number.
Boundary Conditions:
1 <= N <= 999999
Example Input/Output 1:
Input:
11
Output:
13
Example Input/Output 2:
Input:
2
Output:
3

Max Execution Time Limit: 5000 millisecs


Identify correct operator.

ID:2601

Solved By 8556 Users

An expression E is passed as an input to the program. The expression will contain three numbers A, B and C, one
equal symbol and one of the mathematical operators + - * /
But the given mathematical operator is incorrect and hence the expression is not valid. Hence the program must
identify the correct operator and print that as the output.

Input Format:
First line will contain the expression E
Output Format:
First line will contain the correct mathematical operator
Sample Input/Output:
Example 1:
Input:
5-4=20
Output:
*
Explanation:
Only 5 multiplied with 4 gives 20. Hence - must be replaced with *.

Example 2:
Input:
999+9=111
Output:
/
Explanation:
Only 999 divided by 9 gives 111. Hence + must be replaced with /.

Max Execution Time Limit: 10000 millisecs


Alternate letters in uppercase

ID:2609

Solved By 8439 Users

A str‌ing S (only alphabets) is passed as input. The printed output should contain alphabets in odd positions in each
word in uppercase and alphabets in even positions in each word in lowercase.
Input Format:
The first line will contain S.
Output Format:
The first line will contain the resultant string value based on the conditions provided.
Boundary Conditions:
Length of S is from 3 to 100.
Example Input/Output 1:
Input:
tREE GiVES us fruiTS
Output:
TrEe GiVeS Us FrUiTs
Example Input/Output 2:
Input:
FLoweR iS beauTIFUL
Output:
FlOwEr Is BeAuTiFuL

Max Execution Time Limit: 5000 millisecs


HCF/GCD of Two Numbers

ID:2531

Solved By 27112 Users

The program must accept two numbers X and Y and then print their HCF/GCD.
Input Format:
The first line denotes the value of X.
The second line denotes the value of Y.
Output Format:
The first line contains the HCF of X and Y.
Boundary Conditions:
1 <= X <= 999999
1 <= Y <= 999999

Example Input/Output 1:
Input:
30
40
Output:
10
Example Input/Output 2:
Input:
15
10
Output:
5

Max Execution Time Limit: 5000 millisecs


Sum of Tenth and Unit Digits

ID:2534

Solved By 24518 Users

The program must accept a number N and print the sum of tenth and unit digits.
Input Format:
The first line denotes the value of N.
Output Format:
The first line contains the sum of tenth and unit digits.
Boundary Conditions:
10 <= N <= 9999999
Example Input/Output 1:
Input:
231
Output:
4
Example Input/Output 2:
Input:
100
Output:
0
Example Input/Output 3:
Input:
192
Output:
11

Max Execution Time Limit: 5000 millisecs


Prime Number

ID:2567

Solved By 23166 Users

An integer value N is passed as the input. The program must print YES if N is prime number. Else the program must
print NO.
Input Format:
The first line denotes the value of N.
Output Format:
YES or NO based on if N is a prime number or not. (The OUTPUT is CASE SENSITIVE).
Boundary Conditions:
2 <= N <= 9999999
Example Input/Output 1:
Input:
19
Output:
YES
Example Input/Output 2:
Input:
189210
Output:
NO

Max Execution Time Limit: 5000 millisecs


Second Largest Value among N integers
ID:2527

Solved By 22708 Users

The program must accept N integers and print the second largest value among the N integers.
Input Format:
The first line denotes the value of N.
Next N lines will contain the N integer values.
Output Format:
The first line contains the second largest integer.
Boundary Conditions:
2 <= N <= 100
The value of the integers will be from -999999 to 999999.
Example Input/Output 1:
Input:
3
100
2200
345
Output:
345
Example Input/Output 2:
Input:
6
-23
-256
-87
-90
-11019
-2
Output:
-23

Max Execution Time Limit: 5000 millisecs


Odd Integers In Range

ID:2525

Solved By 22166 Users

The program must accept two integers X and Y and print the odd integers between them.
Input Format:
The first line denotes the value of X.
The second line denotes the value of Y.
Output Format:
The first line contains the odd integers between X and Y separated by a space.
Boundary Conditions:
-999999 <= X <= 9999999
X < Y <= 9999999
Example Input/Output 1:
Input:
1
11
Output:
3579
Example Input/Output 2:
Input:
24
30
Output:
25 27 29

Max Execution Time Limit: 5000 millisecs


String Reverse

ID:2533

Solved By 21956 Users

The program must accept a string value S and print the reverse of S.
Input Format:
The first line denotes the value of S.
Output Format:
The first line contains reversed value of S.
Boundary Conditions:
Length of string S is from 2 to 100.
Example Input/Output 1:
Input:
abcde
Output:
edcba
Example Input/Output 2:
Input:
look
Output:
kool

Max Execution Time Limit: 5000 millisecs


Fibonacci Sequence

ID:2568
Solved By 21828 Users

An integer value N is passed as the input. The program must print the first N terms in the Fibonacci sequence.
Input Format:
The first line denotes the value of N.
Output Format:
The first N terms in the Fibonacci sequence (with each term separated by a space)
Boundary Conditions:
3 <= N <= 50
Example Input/Output 1:
Input:
5
Output:
01123
Example Input/Output 2:
Input:
10
Output:
0 1 1 2 3 5 8 13 21 34

Max Execution Time Limit: 5000 millisecs


Uppercase Letters Count

ID:2570

Solved By 21348 Users

A string S is passed as the input. The program must print the number of upper case letters in the string S.
Input Format:
The first line denotes the value of S.
Output Format:
The first line contains the count of upper case letters in S.
Boundary Conditions:
Length of S is from 3 to 100.
Example Input/Output 1:
Input:
ViCtorY
Output:
3
Example Input/Output 2:
Input:
zookeeper
Output:
0
Max Execution Time Limit: 5000 millisecs
String - Remove First & Last Characters

ID:2528

Solved By 21176 Users

The program must accept a String value S and remove the first and last characters.
Input Format:
The first line denotes the value of S.
Output Format:
The first line contains the string value after removing the first and last characters in the string S.
Boundary Conditions:
Length of S is from 3 to 200.
Example Input/Output 1:
Input:
Lion
Output:
io
Example Input/Output 2:
Input:
jug
Output:
u

Max Execution Time Limit: 5000 millisecs


Print String Till Character

ID:2569

Solved By 20452 Users

A string S is passed as the input. Character C is also passed as the input. The program must print the string value S
till C is encountered.
Input Format:
The first line denotes the value of S.
The second line denotes the value of C.
Output Format:
The first line contains the string value S till C is encountered.
Boundary Conditions:
Length of S is from 3 to 100.
Example Input/Output 1:
Input:
manager
e
Output:
manag
Example Input/Output 2:
Input:
Everest
e
Output:
Ev
Explanation:
As the input character C is e which is in lower case, the first letter in Everest< upper case E is ignored and the string
S is printed till a lower case e is encountered.

Max Execution Time Limit: 5000 millisecs


Pattern Printing - Half Pyramid Numbers

ID:2580

Solved By 21300 Users

The number of rows N is passed as the input. The program must print the half pyramid using the numbers from 1
to N.
Input Format:
The first line contains N.
Output Format:
N lines representing the half pyramid pattern using the numbers from 1 to N. (A single space is used to separate the
numbers)
Boundary Conditions:
2 <= N <= 100
Example Input/Output 1:
Input:
5
Output:
1
12
123
1234
12345
Example Input/Output 2:
Input:
3
Output:
1
12
123
Max Execution Time Limit: 5000 millisecs
Pattern Printing - Half Pyramid Numbers

ID:2580

Solved By 21300 Users

The number of rows N is passed as the input. The program must print the half pyramid using the numbers from 1
to N.
Input Format:
The first line contains N.
Output Format:
N lines representing the half pyramid pattern using the numbers from 1 to N. (A single space is used to separate the
numbers)
Boundary Conditions:
2 <= N <= 100
Example Input/Output 1:
Input:
5
Output:
1
12
123
1234
12345
Example Input/Output 2:
Input:
3
Output:
1
12
123

Max Execution Time Limit: 5000 millisecs


Pattern Printing - Half Pyramid

ID:2577

Solved By 20419 Users

The number of rows N is passed as the input. The program must print the half pyramid using asterisk *.
Input Format:
The first line contains N.
Output Format:
N lines representing the half pyramid pattern using * (A single space is used to separate the *)
Boundary Conditions:
2 <= N <= 100
Example Input/Output 1:
Input:
5
Output:
*
**
***
****
*****
Example Input/Output 2:
Input:
3
Output:
*
**
***

Max Execution Time Limit: 5000 millisecs


Print Only Alphabets

ID:2576

Solved By 17983 Users

A string S is passed as the input. S can contain alphabets, numbers and special characters. The program must print
only the alphabets in S.
Input Format:
The first line contains S.
Output Format:
The first line contains only the alphabets in S.
Boundary Conditions:
The length of the input string is between 1 to 1000.

Example Input/Output 1:
Input:
abcd_5ef8!xyz
Output:
abcdefxyz
Example Input/Output 2:
Input:
1239_-87
Output:
Explanation:
As there are no alphabets in the input value nothing is printed as output.
Max Execution Time Limit: 5000 millisecs
Space Separated Integers Sum

ID:2574

Solved By 15199 Users

A single line consisting of a set of integers, each separated by space is passed as input to the program. The
program must print the sum of all the integers present.
Input Format:
The first line contains the integer values (Each separated by a space)
Output Format:
The first line contains the sum of all the integers.
Boundary Conditions:
The length of the input string is between 3 to 10000
The value of the integer values will be from -99999 to 99999
Example Input/Output 1:
Input:
100 -99 98 5
Output:
104
Example Input/Output 2:
Input:
100 200 -300 500 -450 -50
Output:
0

Max Execution Time Limit: 5000 millisecs


Meeting Late Comers

ID:2575

Solved By 13972 Users

A certain number of people attended a meeting which was to begin at 10:00 am on a given day. The arrival time in
HH:MM format of those who attended the meeting is passed as the input in a single line, with each arrival time by
a space. The program must print the count of people who came late (after 10:00 am) to the meeting.
Input Format:
The first line contains the arrival time separated by a space.
Output Format:
The first line contains the count of late comers.
Boundary Conditions:
The length of the input string is between 4 to 10000.
The time HH:MM will be in 24 hour format (HH is hours and MM is minutes).
Example Input/Output 1:
Input:
10:00 9:55 10:02 9:45 11:00
Output:
2
Explanation:
The 2 people were those who came at 10:02 and 11:00

Max Execution Time Limit: 5000 millisecs


Innings Average

ID:2573

Solved By 13483 Users

The runs scored by a cricket team in the first and second innings of N test cricket matches are passed as input. The
program must print the average of first and second innings (with precision upto two decimal places).
Input Format:
The first line denotes the value of N.
Next N lines will contain the first and second innings score separated by a space.
Output Format:
The first line contains the average of first innings score.
The second line contains the average of second innings score.
Boundary Conditions:
2 <= N <= 20
The value of the runs will be from 0 to 1000.
Example Input/Output 1:
Input:
3
250 200
450 300
200 250
Output:
300.00
250.00

Max Execution Time Limit: 5000 millisecs


Palindrome Missing Alphabet

ID:2579

Solved By 11845 Users

String S which is a palindrome is passed as the input. But just one alphabet A is missing in S. The program must
print the missing alphabet A.
Note: The FIRST alphabet of S will always be present.
Input Format:
The first line contains S.
Output Format:
The first line contains the missing alphabet A.
Boundary Conditions:
The length of the input string S is between 3 to 100.
The FIRST alphabet of S will always be present.
Example Input/Output 1:
Input:
malayaam
Output:
l
Example Input/Output 2:
Input:
abcddcb
Output:
a

Max Execution Time Limit: 5000 millisecs


Lowest Mileage Car

ID:2578

Solved By 11582 Users

The name and mileage of certain cars is passed as the input. The format is CARNAME@MILEAGE and the input is as
a single line, with each car information separated by a space. The program must print the car with the lowest
mileage. (Assume no two cars will have the lowest mileage)
Input Format:
The first line contains the CARNAME@MILEAGE separated by a space.
Output Format:
The first line contains the name of the car with the lowest mileage.
Boundary Conditions:
The length of the input string is between 4 to 10000.
The length of the car name is from 1 to 50.
Example Input/Output 1:
Input:
Zantro@16.15 Zity@12.5 Gamry@9.8
Output:
Gamry

Max Execution Time Limit: 5000 millisecs


Top Scoring Batsman Name

ID:2571
Solved By 11022 Users

The runs scored by N batsmen of a cricket team is passed as the input to the program. The program must print the
name of the batsman who scored the highest runs. (You can assume that no two batsmen will be the top scorers).
Input Format:
The first line denotes the value of N.
Next N lines will contain the name of the batsman and the runs score (both separated by a comma)
Output Format:
The first line contains the name of the batsman with the top score.
Boundary Conditions:
2 <= N <= 11
The length of the names will be from 3 to 100.
The value of the runs will be from 0 to 500.
Example Input/Output 1:
Input:
5
BatsmanA,45
BatsmanB,52
BatsmanC,12
BatsmanD,9
BatsmanE,78
Output:
BatsmanE

Max Execution Time Limit: 5000 millisecs


Top Scoring Student

ID:2572

Solved By 10802 Users

Names of N students and the marks scored by them in Maths, Physics and Chemistry are passed as the input. The
program must print the name of the student who has scored the maximum marks in these three subjects. (Assume
only one student will be the top scorer).
Input Format:
The first line denotes the value of N.
Next N lines will contain the name of the student and the marks in three subjects separated by colon.
Output Format:
The first line contains the name of the students with the highest marks.
Boundary Conditions:
2 <= N <= 50
The length of the names will be from 3 to 100.
The value of the marks will be from 0 to 100.
Example Input/Output 1:
Input:
4
Sasikumar:50:60:70
Arun:60:40:90
Manoj:50:50:60
Rekha:60:35:45
Output:
Arun

Max Execution Time Limit: 5000 millisecs


First Repeating Character From Last

ID:2594

Solved By 11042 Users

A string S is passed as the input. S has at least one repeating character. The program must print the first repeating
character C from the last.
Input Format:
The first line contains S.
Output Format:
The first line contains C.
Boundary Conditions:
Length of S will be from 3 to 100.
Example Input/Output 1:
Input:
abcdexyzbwqpooplj
Output:
p

Max Execution Time Limit: 5000 millisecs


Characters at multiples of X

ID:2592

Solved By 10753 Users

A string S is passed as the input. A positive integer X is also passed as the input. The program must print the
characters at positions which are multiples of X.
Input Format:
The first line contains S.
The second line contains X.
Output Format:
The first line contains the characters at positions which are multiples of X.
Boundary Conditions:
Length of S will be from 3 to 100.
Example Input/Output 1:
Input:
abcdexyzwqpoolj
5
Output:
eqj
Explanation:
The multiples of 5 are like 5, 10, 15,...
So the characters in these positions are e,q,j

Max Execution Time Limit: 5000 millisecs


String Word Count

ID:2597

Solved By 10444 Users

The program must accept a string S and print the count of words in S.
Boundary Condition(s):
1 <= Length of S <= 100
Input Format:
The first line contains S.
Output Format:
The first line contains the integer value representing the word count.
Example Input/Output 1:
Input:
I like tea
Output:
3
Example Input/Output 2:
Input:
I like coffee very much
Output:
5

Max Execution Time Limit: 1000 millisecs


Average Speed

ID:2591

Solved By 10088 Users

A single line L with a set of space separated values indicating distance travelled and time taken is passed as the
input. The program must calculate the average speed S (with precision upto 2 decimal places) and print S as the
output.
Note: The distance and time taken will follow the format DISTANCE@TIMETAKEN. DISTANCE will be in kilometers
and TIMETAKEN will be in hours.
Input Format:
The first line contains L.
Output Format:
The first line contains the average speed S.
Boundary Conditions:
Length of L will be from 3 to 100.
Example Input/Output 1:
Input:
60@2 120@3
Output:
36.00 kmph
Explanation:
Total distance = 60+120 = 180 km.
Total time taken = 2+3 = 5 hours.
Hence average speed = 180/5 = 36.00 kmph

Max Execution Time Limit: 5000 millisecs


Calendar Month

ID:2600

Solved By 9645 Users

A date in DD-MM-YYYY format is passed as the input. The program must print the calendar month.
01 - January, 02 - February and so on till 12 - December.
Input Format:
First line will contain the date in DD-MM-YYYY format.
Output Format:
The string value denoting the month.
Example Input/Output 1:
Input:
23-12-2016
Output:
December

Max Execution Time Limit: 5000 millisecs


Difference between the length of the rectangles

ID:2599

Solved By 9605 Users


Alen and Tim both own a tennis grass court and they decide to mow the lawn in and around the court which will
cost them Rs.5 per square feet. Given the amount they spent to mow the lawn and the width of the court, find the
difference between the length of the courts.
Input Format:
First line will contain the amount spent (in Rs) by Alen and Tim separated by space.
Second line will contain the width (in feet) of the courts of Alen and Tim separated by space.
Output Format:
The value (in feet) which is the difference between the length of the courts rounded off upto two decimal points.
Example Input/Output 1:
Input:
100000 80000
100 80
Output:
0.00
Explanation:
Area of Alen's court = 100000/5 = 20000 sq.ft. Length = 20000/100 = 200
Area of Tim's court = 80000/5 = 16000 sq.ft. Length = 16000/80 = 200
Hence the difference = 200-200 = 0 which when rounded off to decimal places is 0.00
Example Input/Output 2:
Input:
17500 40000
50 80
Output:
30.00
Explanation:
Area of Alen's court = 17500/5 = 3500 sq.ft. Length = 3500/50 = 70
Area of Tim's court = 40000/5 = 8000 sq.ft. Length = 8000/80 = 100
Hence the difference = 100-70 = 30.00

Max Execution Time Limit: 5000 millisecs


Odd Length String - Middle Three Letters

ID:2596

Solved By 9562 Users

An odd length string S is passed as the input. The middle three letters of S must be printed as the output.
Input Format:
First line will contain the string value S
Output Format:
First line will contain the middle three letters of S.
Boundary Conditions:
Length of S is from 5 to 100
Example Input/Output 1:
Input:
level
Output:
eve
Example Input/Output 2:
Input:
manager
Output:
nag

Max Execution Time Limit: 5000 millisecs


First Letter In Word - Uppercase

ID:2598

Solved By 9303 Users

A string value S is passed as the input. The program must print the first letter of each word in S in upper case.
Input Format:
First line will contain the string value S
Output Format:
First line will contain the string value with the first letter of each word in S in upper case.
Boundary Conditions:
Length of S is from 5 to 500
Example Input/Output 1:
Input:
She is happy.
Output:
She Is Happy.
Example Input/Output 2:
Input:
joIN tHE ParTY
Output:
JoIN THE ParTY

Max Execution Time Limit: 5000 millisecs


First Repeating Character

ID:2593

Solved By 9236 Users


A string S is passed as the input. S has at least one repeating character. The program must print the first repeating
character C.
Input Format:
The first line contains S.
Output Format:
The first line contains C.
Boundary Conditions:
Length of S will be from 3 to 100.
Example Input/Output 1:
Input:
abcdexyzbwqpoolj
Output:
b

Max Execution Time Limit: 5000 millisecs


Common part in string values

ID:2595

Solved By 8703 Users

Two string values S1 and S2 are passed as input. The last portion of S1 will be the first portion of S2. The program
must print this common part in S1 and S2.
Input Format:
The first line contains S1.
The second line contains S2.
Output Format:
The first line contains the common part.
Boundary Conditions:
Length of S1 and S2 will be from 3 to 100.
Example Input/Output 1:
Input:
mayday
daybreak
Output:
day
Example Input/Output 2:
Input:
bridge
gear
Output:
ge

Max Execution Time Limit: 5000 millisecs

You might also like