0% found this document useful (0 votes)
126 views11 pages

PPS Case Study

The document provides information about Malla Reddy Engineering College for Women including that it is an autonomous institution approved by UGC and AICTE located in Secunderabad, Telangana.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views11 pages

PPS Case Study

The document provides information about Malla Reddy Engineering College for Women including that it is an autonomous institution approved by UGC and AICTE located in Secunderabad, Telangana.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

MALLA REDDY ENGINEERING COLLEGE FOR WOMEN

(Autonomous Institution – UGC Govt. of India)


Accredited by NBA and NAAC with ‘A’ grade
National Ranking by NIRF-Rank band (151-300), MHRD, GOVT. of India
Approved by AICTE, Affiliated to JNTUH, ISO 9001:2015 Certified Institution
Maisammaguda, Dhulapally, Secunderabad-500100

1. Problem Statement: Digital Time


The objective is to form the maximum possible time in the HH:MM:SS format using any six of nine
given single digits (not necessarily distinct) Given a set of nine single (not necessarily distinct) digits,
say 0, 0, 1, 3, 4, 6, 7, 8, 9, it is possible to form many distinct times in a 24 hour time format
HH:MM:SS, such as 17:36:40 or 10:30:41 by using each of the digits only once. The objective is to
find the maximum possible valid time (00:00:01 to 24:00:00) that can be formed using some six of the
nine digits exactly once. In this case, it is 19:48:37.

Input Format
A line consisting of a sequence of 9 (not necessarily distinct) single digits (any of 0-9) separated by
commas. The sequence will be non-decreasing

Output
The maximum possible time in a 24 hour clock (00:00:01 to 24:00:00) in a HH:MM:SS form that can
be formed by using some six of the nine given digits (in any order) precisely once each. If no
combination of any six digits will form a valid time, the output should be the word Impossible
Explanation

Example 1
Input
0,0,1,1,3,5,6,7,7
Output
17:57:36
The maximum valid time in a 24 hour clock that can be formed using some six of the 9 digits
precisely
once is 17:57:36

Example 2
Input
3,3,3,3,3,3,3,3,3
Output
Impossible
No set of six digits from the input may be used to form a valid time.

2. Problem statement :Milk Man and His Bottles

A Milkman serves milk in packaged bottles of varied sizes. The possible size of the bottles are
{1, 5, 7 and 10} litres. He wants to supply the desired quantity using as fewer bottles as possible
irrespective of the size. Your objective is to help him find the minimum number of bottles
required to supply the given demand for milk.

Input Format:
The first line contains the number of test cases N
Next N lines, each contains a positive integer Li which corresponds to the demand of milk.

Output Format:
For each input Li, print the minimum number of bottles required to fulfill the demand

Constraints:
1 <= N <= 1000 Li > 0 1 <= i<= N
Sample Input and Output:
2
17
65
27
Explanation:
Number of test cases is 2
For 17 = 10*1 + 7*1 = 2
For 65 = 10*6 + 5*1 = 7
Few more examples:
For 99 = 10*9 + 7*1 + 1*2 = 12
For 63 = 10*6 + 1*3 =9

3. Given an unsorted array ‘a’ of size N of non-negative integers, find a continuous sub-array which
adds to a given number sum. Input Format: The first line contains an integer, denoting the size of the
array. The second line contains integers denoting the elements of the array. The last line contains an
integer, denoting the sum.
Constraints 1<= n<=100
1<=arr<= 1000, where arr is the ith element of the array.
1<= n<=100000

Output Format:
The output line contains integers denoting the indexes.

TESTCASE 1:
Input:
7
[1, 4, 0, 0, 3, 10, 5]
sum = 7
Output:
Sum found between indexes 1 and 4

TESTCASE 2:
Input:
2
[1, 4]
sum = 0
Output:
No subarray found

4. Problem Statement: WORD AKSHARI


Antakshari is a popular parlor game played in India. Many word games are similar to antakshari. One
such game is wordakshari. The game can be played by two or more people. The first player has to
recite a word. The last letter of the word is then used by the next player recite another word, starting
with that word. The winner or winning team is decided by a process of elimination. The person or
team that cannot come up with a word with the right consonant is eliminated.
The following rules need to be followed while playing this game
(i) The first word can begin with any letter.
(ii) All other words have to begin with the last letter of the previous word
(iii) No words can be repeated.

Input and Output Format :


Input consists of n+1 lines. The first n lines contain strings corresponding to the words in the
chain. The last line of input contains the string #### to mark the end of input.
Output consists of the valid wordakshari chain.

Sample Input:
architect
tailor
referee
electrician
nurse
blacksmith
####
Sample Output:
architect
tailor
referee
electrician
nurse

Algorithm to solve wordakshari


Input the strings from the user.
If the last letter of the former string and the first letter of the latter string are the same, print both
the strings.
Else, display only the former string.
Continue the same until all the strings are traversed.

5. Problem Statement: Program to replace all 0's with 1 in a given integer


Given an integer as an input, all the 0's in the number has to be replaced with 1.
For example, consider the following number
Input: 102405
Output: 112415
Input: 56004
Output: 56114
Algorithm to replace all 0's with 1 in a given integer
ï‚· Input the integer from the user.
ï‚· Traverse the integer digit by digit.
ï‚· If a '0' is encountered, replace it by '1'.
ï‚· Print the integer.

6. Program to Replace a Substring in a String


The steps for replacing a substring with another string are given below.
Input:
hi hello
string to be replaced: hi
string to be replaced with: hey
output: hey hello

Algorithm to replace a substring in a string


Input the full string (s1).
Input the substring from the full string (s2).
Input the string to be replaced with the substring (s3).
Find the substring from the full string and replace the new substring with the old substring (Find
s2 from s1 and replace s1 by s3).

7. Movie Ticket Booking System

People nowadays like doing thing through online for example shopping online, bill payment online,
study online and many more. In order to make people easier and save the time, Movie Ticket Booking
System was introduced. This system can save people time by no need to go to the cinema and buy the
ticket. This system require people to booking and buy movie ticket through online. People can choose
what type of movie they want to watch and what type of seat they want to choose.

Movie Ticket Booking System require user to enter:


Personal data
Movie type
No of ticket
Date
Time

No Movie name Price


1 UpinIpin RM15.00
2 Shazam! RM10.90
3 Friend zone RM12.50
4 Fighting RM15.00
5 Dumbo RM10.00

This system also give permission to choose how many movie you like and what seat you want.
The total price will calculated at the end of the booking process.

totalprice=ticket+price;

After the seat has been chosen, program will display no of seat and also available seat that had left
seatAvlb=seats-people;

8. You have a certain number of 100 rupee notes, 10 rupee notes and 1 rupee notes with you.
There is an item you want to buy whose price is given to you.
Write a program to find if the item is affordable, that is the price of the item is less than or equal to the
current money you have.

Input
-----
Four non negative integers.
The first input is an integer representing the number of 100 rupee notes.
The second input is an integer representing the number of 10 rupee notes.
The third input is an integer representing the number of 1 rupee notes.
The fourth input is an integer representing the price of the item.

Output
------
You have to output 1 if the item is affordable.
You have to output 0 if the item is not affordable.

9. Bank Compare
There are two banks; Bank A and Bank B. Their interest rates vary. You have received offers from
both banks in terms of the annual rate of interest, tenure, and variations of the rate of interest over the
entire tenure.
You have to choose the offer which costs you least interest and reject the other. Do the computation
and make a wise choice.
The loan repayment happens at a monthly frequency and Equated Monthly Installment (EMI) is
calculated using the formula given below :
EMI = loanAmount * monthly InterestRate / ( 1 – 1 / (1 + monthly InterestRate)^(numberOfYears *
12))
Constraints:
1 <= P <= 1000000
1 <=T <= 50
1<= N1 <= 30
1<= N2 <= 30
Input Format:
 First line : P – principal (Loan Amount)
 Second line : T – Total Tenure (in years).
 Third Line: N1 is the number of slabs of interest rates for a given period by Bank A. First slab
starts from the first year and the second slab starts from the end of the first slab and so on.
 Next N1 line will contain the interest rate and their period.
 After N1 lines we will receive N2 viz. the number of slabs offered by the second bank.
 Next N2 lines are the number of slabs of interest rates for a given period by Bank B. The first
slab starts from the first year and the second slab starts from the end of the first slab and so
on.
 The period and rate will be delimited by single white space.
Output Format: Your decision – either Bank A or Bank B.
Sample Input 1:
10000
20
3
5 9.5
10 9.6
5 8.5
3
10 6.9
5 8.5
5 7.9
Sample Output 1:
Bank B
Sample Input 2:
500000
26
3
13 9.5
3 6.9
10 5.6
3
14 8.5
6 7.4
6 9.6
Sample Output 2:
Bank A

10. . Given an N×N matrix, with N>1


You have to determine whether the matrix is an upper triangular matrix.
A matrix is upper triangular if every entry below the diagonal is 0. The following is an example of an
upper triangular matrix:
1111
0411
0001
0001
Note: The diagonal itself, and the entries above the diagonal can be zeroes or non-zero integers.

Input
First, you will be given N, which is the size of the matrix.
Then you will be given N rows of integers, where each row consists of N integers separated by
spaces.

Output
If the input matrix is upper triangular, then print 1. Otherwise, print 0.

11. One Egg


“One Egg” is an egg supply company which supplies eggs to retailers. They have M classes of eggs.
Each class can have N number of eggs (N can be the same or can vary class to class). They accept
order via mail for X eggs. In response, they confirm if they can supply the eggs with a “Thank you”
note and the number of eggs or with a “Sorry” note and the numbers of eggs they can supply. They
also mention the breakdown of eggs by the class they will supply. The ordered eggs are adjusted
against the different classes with the most number of eggs adjusted first then the balance is adjusted
against the second-highest and so on. The company is a bit superstitious as well. If the number of
eggs ordered is greater than or equal to the total number of eggs in stock then they retain one egg and
responds back with the “Sorry” note with total number of eggs in stock minus one and breakdown of
eggs by class.
Note: If the classes have the same number of eggs then class entered first should be selected to adjust.
Input Format:
First line contains two space-separated integers denoting the respective values of M (the number of
classes of eggs) and X, the number of eggs ordered The following M lines contain an integer each
indicating the number of eggs available in each class
Output Format:
First line should be, if X is less than total number of Eggs then Print ” Thank you, your order for X
eggs is accepted” Else if X is greater than or equal to total number of Eggs then print ” ” Sorry, we
can only supply (total number of Eggs in stock -1) eggs” T hen M lines with 3 columns: First column
– Number of eggs available in each class Second column – Eggs allocated against each class for that
order Third column – Balance Eggs against each class
Constraints:
1 ≤ M ≤ 20 N ≥ 1 X ≥ 1
Sample Input 1:
5 150
50
15
80
10
5
Sample Output 1:
Thank you, your order for150 eggs are accepted
50 50 015 15 080 80 010 5 55 0 5
Explanation:
Total order of 150 eggs is less than the total number of Eggs 50+15+80+10+5 = 160. Hence the
Thank you message. 150 was first adjusted against Class with the first highest number of eggs 80.
Balance of 150-80 = 70 was adjusted against the second highest class of 50. Balance of 70-50 = 20
then adjusted against 15. Balance of 20-15 = 5 then adjusted against 10 leaving behind 5 eggs in that
class.
Sample Input 2:
4 250
80
50
70
20
Sample Output 2:
Sorry, we can only supply 219 eggs
80 80 0
50 50 0
70 70 0
20 19 1
Explanation:
The total order of 250 eggs was greater than the total number of eggs 80+50+70+20 = 220. Hence the
sorry message. 250 was first adjusted against Class with the first highest number of eggs 80. Balance
of 250-80 = 170 was adjusted against the second highest class of 70. Balance of 170-70 = 100 was
then adjusted against 50. Balance of 100-50 = 50 then adjusted against 20. Since Balance is greater
than the last class of egg all but one egg is left in that last class.

12.Astronomy Lecture
Problem Statement -: Anirudh is attending an astronomy lecture. His professor who is very strict
asks students to write a program to print the trapezium pattern using stars and dots as shown below .
Since Anirudh is not good in astronomy can you help him?
Sample Input:
N=3
Output:
**.**
*…*
…..
*…*
**.**

13. Copycat in exam


Problem Statement – Rahul copies in the exam from his adjacent students. But he doesn’t want to be
caught, so he changes words keeping the letter constant. That means he interchanges the positions of
letters in words. You are the examiner and you have to find if he has copied a certain word from the
one adjacent student who is giving the same exam, and give Rahul the markings he deserves.
Note that: Uppercase and lowercase are the same.
Input Format:
 First line with the adjacent student’s word
 Second line with Rahul’s word
Output Format:
 0 if not copied
 1 if copied
Constraints:
 1<=Length of string<=10^6
Sample Input:
CAR
Acr
Sample Output:
1

14.Weird Terminal
Problem Statement – Here is a weird problem in Susan’s terminal. He can not write more than two
words each line, if she writes more than two, it takes only 2 words and the rest are not taken. So she
needs to use enter and put the rest in a new line. For a given paragraph, how many lines are needed to
be written in Susan’s terminal?
Input Format:
 A string as the text to input in the terminal
Output Format:
 Number of lines written.
Constraints:
 Number of words <=10^7
Sample Input:
How long do you have to sit dear?
Sample Output:
4
Explanation:
The writing will be:
 How long
 Do you
 Have to
 Sit dear?

15. Sudoko
Given a partially filled 9×9 2D array ‘grid[9][9]’, the goal is to assign digits (from 1 to 9) to the
empty cells so that every row, column, and subgrid of size 3×3 contains exactly one instance of the
digits from 1 to 9.
Examples:
Input: grid
{ {3, 0, 6, 5, 0, 8, 4, 0, 0},
{5, 2, 0, 0, 0, 0, 0, 0, 0},
{0, 8, 7, 0, 0, 0, 0, 3, 1},
{0, 0, 3, 0, 1, 0, 0, 8, 0},
{9, 0, 0, 8, 6, 3, 0, 0, 5},
{0, 5, 0, 0, 9, 0, 6, 0, 0},
{1, 3, 0, 0, 0, 0, 2, 5, 0},
{0, 0, 0, 0, 0, 0, 0, 7, 4},
{0, 0, 5, 2, 0, 6, 3, 0, 0} }
Output:
316578492
529134768
487629531
263415987
974863125
851792643
138947256
692351874
745286319
Explanation: Each row, column and 3*3 box of the output matrix contains unique numbers.

16.The modulo operator, %, returns the remainder of a division. For example, 4 % 3 = 1 and 12 % 10
= 2. The ordinary division operator, /, returns a truncated integer value when performed on integers.
For example, 5 / 3 = 1. To get the last digit of a number in base 10, use 10 as the modulo divisor.
Task
Given a five digit integer, print the sum of its digits.
Input Format
The input contains a single five digit number, n
Constraints

Output Format
Print the sum of the digits of the five digit number.
Sample Input
10564
Sample Output
16
17. Print a pattern of numbers from 1 to n as shown below. Each of the numbers is separated by a
single space.

Input Format
The input will contain a single integer n.

Constraints

Sample Input 0
2

Sample Output 0
222
212
222

Sample Input 1
5

Sample Output 1
555555555
544444445
543333345
543222345
543212345
543222345
543333345
544444445
555555555

Sample Input 2
7

Sample Output 2
7777777777777
7666666666667
7655555555567
7654444444567
7654333334567
7654322234567
7654321234567
7654322234567
7654333334567
7654444444567
7655555555567
7666666666667
7777777777777
18. Given a string,s, consisting of alphabets and digits, find the frequency of each digit in the given
string.
Input Format
The first line contains a string, num, which is the given number.
Constraints

All the elements of num are made of english alphabets and digits.
Output Format
Print ten space-separated integers in a single line denoting the frequency of each digit from 0 to9 .
Sample Input 0
A11472o5t6
Sample Output 0
0210111100
Explanation 0
In the given string:
 1 occurs two times.
 2,4,5,6, and occur one time each.
 The remaining digits 0,3,8 and 9 don't occur at all.
Sample Input 1
Lw4n88j12n1
Sample Output 1
0210100020
Sample Input 2
1v88886l256338ar0ekk
Sample Output 2
1112012050

19. Given a sentence,s, print each word of the sentence in a new line.
Input Format
The first and only line contains a sentence,s.
Constraints

Output Format
Print each word of the sentence in a new line.
Sample Input 0
This is C

Sample Output 0
This
is
C
Explanation 0
In the given string, there are three words ["This", "is", "C"]. We have to print each of these words in a
new line.

Sample Input 1
Learning C is fun

Sample Output 1
Learning
C
is
fun

Sample Input 2
How is that

Sample Output 2
How
is
that

20. One day three best friend’s Atul, Pandey and tony decided to form a team and take part in
programming contests. Particiants are usually offered several problems during programming
contests.Long before the start friends decide that they will implement a problem if atleast two of them
are sure about solution. othewise, friends won’t write the problem’s solution.
The contest offers n problems to the participants. For each problem we know which friend is sure
about solution. Help friends find the number of problems for which they will write a solution.
Input Format:
The first input line contains a single integer ‘n’ the number of problems in the contest. Then n line
contains three integers each integer is either 0 or 1. If the first number in the line equal 1, then Atul is
sure about the problem’s solution, otherwise he isn’t true.
The secong number shows Pandey’s view on the solution,the third number shows Tony’s view.The
number on the lines are separated by space.

21. C program to check if two given matrices are identical. First element should read elements r1 and
c1.Second element should read elements r2 and c2.Third element read with elements of matrix 1 with
space and in the NextLine it read the element of matrix 2.
If both matrices are identical print “Matrices are identical” otherwise Print “Matrices are not
identical”.
If r1 and c1, r2 and c2 are not equal print -1.

22. Consider a sample space S consisting of all perfect squares starting from 1, 4, 9 and so on. You
are given a number N, you have to output the number of integers less than N in the sample space S.

Example:
Input : N = 9
Output: 2
Explanation: 1 and 4 are the only Perfect Squares less than 9. So, the Output is 2

You might also like