• Welcome to Programming_info!!

    Here you will get questions as well as there solutions.
    we provid you daily with a new question and it's solution.
    we have codechef and hackerrank solution for beginner now.

  • Welcome to Programming_info!!

    Here you will get questions as well as there solutions.
    we provid you daily with a new question and it's solution.
    we have codechef and hackerrank solution for beginner now.

  • Welcome to Programming_info!!

    Here you will get questions as well as there solutions.
    we provid you daily with a new question and it's solution.
    we have codechef and hackerrank solution for beginner now.

  • Welcome to Programming_info!!

    Here you will get questions as well as there solutions.
    we provid you daily with a new question and it's solution.
    we have codechef and hackerrank solution for beginner now.

  • Welcome to Programming_info!!

    Here you will get questions as well as there solutions.
    we provid you daily with a new question and it's solution.
    we have codechef and hackerrank solution for beginner now.

Rto List |Programming_info || python_problem_21

 RTO is the place where the new bikes and cars are registered but they have a limitation like, they have to register only m number of vehicles per day. So if there are any vehicle more than that, they’ll be sent back asking to come back tomorrow. So write a program to display the number of vehicles registered with the all the details regarding vehicles and help them get all the details of the day in on single sheet.

                                                                    
Input format:
Input will contain two integers.
The First corresponds to number of vehicals for registration.
The second Input corresponds to maximum number of vehicals that can be registered in one day
And all the details of the vehicle.


Output format:
The output contains a list of details of all the vehicles registered one after the other.

Sample input :
4
10
KA09MN01
51178964525
258795462
Chandan V
Mysore
KA09MN02
51178964525
258795462
Chandru V
Mysore
KA09MN03
51178964525
258795462
Chandini V
Mysore
KA09MN04
51178964525
258795462
Chandana A
Mysore
 

Sample output:
Reg.no: chassis no: engine no: owner name: address:
KA09MN01 51178964525 258795462 Chandan V Mysore
KA09MN02 51178964525 258795462 Chandru V Mysore
KA09MN03 51178964525 258795462 Chandini V Mysore
KA09MN04 51178964525 258795462 Chandana A Mysore
Solution:
n=int(input())
m=int(input())
l=[]
for i in range(n):
    ls=[]
    reg=input()
    chs=input()
    enf=input()
    onr=input()
    add=input()
    ls.extend((reg,chs,enf,onr,add))
    l.append(ls)
print("Reg. no: chassis no: engine no: owner name: address:")
for i in l:
    print(i[0],i[1],i[2],i[3],i[4])

Share:

Lucky Card Game |Programming_info || python_problem_20

 Arun and Arya are very good friends. They started playing a card game. In this game, each of them will have a set of cards.

Each card consists of a number and a symbol. Each player will have a set of cards and that set consist 16 cards and it has 4 types of cards named as (R, Q,  P,  S) and there will be 4 cards of each type numbered as (If card symbol like R then card contains details like R 1, R 2, R 3, R 4). So they started playing the game.
 

     


Initially, cards are flipped and shuffled. At the time each player can flip one card. According to the rules of card game, Score of each player depending on card types that they have got(for card R total sum of R cards will increase by multiplying by 10, similarly for Q it’s 10 and for P it’s 7 and S it’s 5), and player who got the highest score is the winner.
Find the winner of the card game.

Input format
1st input is an integer indicates a number of times each player can flip the card. (1>=n<=16).
The next line of input indicates details of the flipped card, like card name[should be b/w[R, Q, P, S] and card number[b/w 1-4].
(follow the sample input and output format).

Output format
The output consists of the total scores and status of the game.
Refer to sample input and output for formatting details.
Note: All text in bold corresponds to the input and the rest corresponds to output [Refer to sample input and output format].

Sample Input and Output 1:
Enter number of time player can flip the card
3
Arun flip the card
R
1

Arya flip the card
S
2

Arun flip the card
P
1

Arya flip the card
R
3

Arun flip the card
R
4

Arya flip the card
P
3

Total scores 57 61
Arya won the game

Sample Input and Output 2:
Enter number of time player can Flip the card
2
Arun flip the card
R
2

Arya flip the card
Q
2

Arun flip the card
P
3

Arya flip the card
S
3

Total scores  41 35
Arun won the game

Sample Input and Output 3:
Enter number of time player can flip the card
2
Arun flip the card
R
2

Arya flip the fard
P
3

Arun flip the card
P
3

Arya flip the card
Q
2

Total scores  41 41
Game tied
Solution:
print("Enter number of time player can flip the card")
n=int(input())
a=[]
b=[]
for i in range(n):
    print("Arun flip the card")
    a1=[]
    x=input()
    a1.append(x)
    y=int(input())
    a1.append(y)
    a.append(a1)
    print("Arya flip the card")
    b1=[]
    x1=input()
    b1.append(x1)
    y1=int(input())
    b1.append(y1)
    b.append(b1)
s1,s2=0,0
for i in a:
    if i[0]=='P':
        s1+=i[1]*7
    elif i[0]=='Q':
        s1+=i[1]*10
    elif i[0]=='R':
        s1+=i[1]*10
    elif i[0]=='S':
        s1+=i[1]*5
for i in b:
    if i[0]=='P':
        s2+=i[1]*7
    elif i[0]=='Q':
        s2+=i[1]*10
    elif i[0]=='R':
        s2+=i[1]*10
    elif i[0]=='S':
        s2+=i[1]*5
print("Total scores {} {}".format(s1,s2))
if s1>s2:
    print("Arun won the game")
elif s2>s1:
    print("Arya won the game")
else:
    print("Game tied")

Share:

OCCURRENCE OF CHARACTERS |Programming_info || python_problem_19

 Ramya wants to know about the dictionary data type. Now she wants to create a dictionary using a string like each unique character in a string is considered as keys of dictionary and number of occurrence of each character considered as values of each key in a dictionary.


    

Now she has to display the dictionary format and occurrence of characters in ascending order.

Input and Output Format:
Input is a string.
The output contains dictionary representation in ascending order of characters and occurrence of each character in a string (Refer sample output format).

All text in bold corresponds to the input and the rest corresponds to output [Refer sample input and output format].

Sample Input 1:
sandhyaa
Sample Output 1:
Dictionary of string: {'a': 3, 'd': 1, 'h': 1, 'n': 1, 's': 1, 'y': 1}
a-- 3
d-- 1
h-- 1
n-- 1
s-- 1
y-- 1

Sample Input 2:
aaaattttgggjjjiiibb
Sample Output 2:
Dictionary of string: {'a': 4, 'b': 2, 'g': 3, 'i': 3, 'j': 3, 't': 4}
a-- 4
b-- 2
g-- 3
i-- 3
j-- 3
t-- 4

Sample Input 3:

rathhaann
Sample Output 3:

Dictionary of string: {'a': 3, 'h': 2, 'r': 1, 't': 1, 'n': 2}
a-- 3
h-- 2
n-- 2
r-- 1
t-- 1

 

Solution:
x=list(input())
x.sort()
s=""
s=s.join(x)
d=dict()
for i in s:
    c=s.count(i)
    d[i]=c
print("Dictionary of string:",d)
for letter,lcount in d.items():
    print(letter,"--",lcount)

Share:

AVERAGE OF MARKS |Programming_info || python_problem_18

 You have a record of students. Each record contains the student's name and their percentage marks in Maths, Physics, and Chemistry. The marks can be floating values. The user enters some integer followed by the names and marks of students. You are required to save the record in a dictionary data type. The user then enters a student's name. The output is the average percentage marks obtained by that student, correct to two decimal places.

                              

 

Input and Output format:
The first line contains the integer, which indicates the number of students, 'n'.
The next 'n' lines contain the name and marks obtained by that student separated by a space. The final line contains the name of a particular student previously listed to find the average mark of him.
The output is the average of the marks obtained by the particular student correct to 2 decimal places.

Note: Use Dictionary concept to solve the problem.
Sample Input 1:
4
aaa 35 67 89
bbb 45 46 48
ccc 78 78 78
ddd 78 90 89
ddd
Sample Output 1:
Average Mark of is : 85.67

 

Sample Input 2:
3
aaa 46 78 89
bbb 34 68 90
ccc 13 56 34
ccc
Sample Output 2:
Average Mark of is : 34.33

Solution:
d=dict()
n=int(input())
for i in range(0,n):
    name,m1,m2,m3=input().split()
    d[name]=[int(m1),int(m2),int(m3)]
s=input()
if s in d.keys():
    print("Average Mark of is : {:.2f}".format(sum(d[s])/3))

Share:

List of Orders |Programming_info || python_problem_17

 List of orders from amazon are given along with the departure date. The Amazon are adding features to their delivery management system in iterations. The Support desk is finding it difficult to filter the Trains with the departure dates from the data available.

Can you please implement a date filter to help the Support desk with this regard?
 
Input Format :
The first line of input is an integer that corresponds to the number of records, 'n'.
The next 'n' line corresponds to the records.
The last line of input consists of the date to be filtered.
 
Output format :
The first line of the output is a set of comma seperated string containing the cargo name and date. 
The next lines consists of the names of the cargos printed one next to  other seperated by new line.
 
Refer to sample input and output for formatting specifications and more details.
 
Sample Input 1:
5
Sparx_Shoes,11-12-2013
Suits,29-12-2016
SAMSUNG Mobiles,27-03-2017
Tissot Watchs,10-04-2014
Levis Denim,27-03-2017
27-03-2016
 
Sample Output 1:
[('Sparx_Shoes', '11-12-2013'), ('Suits', '29-12-2016'), ('SAMSUNG Mobiles', '27-03-2017'), ('Tissot Watchs', '10-04-2014'), ('Levis Denim', '27-03-2017')]
Suits
SAMSUNG Mobiles
Levis Denim
 
Explanation for Sample:
First line of the output contains the cargo details in the form of list of tuples.
The next 3 lines are the cargo names, whose departure date is greater than the filter date.
 
Solution:
import datetime
n=int(input())
l=[]
for i in range(n):
    ls=[]
    x,y=input().split(",")
    ls.extend((x,y))
    ls=tuple(ls)
    l.append(ls)
d=input()
day,month,year=map(int,d.split("-"))
date=datetime.date(year,month,day)
print(l)
for i in l:
    day,month,year=map(int,i[1].split("-"))
    date1=datetime.date(year,month,day)
    if date1>date:
        print(i[0])

Share:

Friendship Test |Programming_info || python_problem_16

 Michael is celebrating his 10th birthday and he wished to arrange a party to all his class mates. But there are n tough guys amongst his class who are weird. They thought that this is the best occasion for testing their friendship with him. They put up conditions before Michael that they will break the friendship unless he gives them a grand party on their chosen day. Formally, ith friend will break his friendship if he does not receive a grand party on dith day.

 
Michael is not a lavish spender and can give at most one grand party daily. Also, he wants to invite only one person in a party. So he just wonders what the maximum number of friendships he can save.
Please help Michael in this difficult task.
 
Input Format:
First line will contain a single integer denoting n. Assume that the maximum value for n as 50.
Second line will contain n space separated integers where ith integer corresponds to the day dith as given in the problem.

Output Format:
Print a single line corresponding to the maximum number of friendships Michael can save.
Refer sample input and output for formatting specifications.

Sample Input 1:
2
3 2

Sample Output 1:
2

Sample Input 2:
5
4 1 3 7 5

Sample Output 2:
5


Sample Input 3:
6
1 2 3 3 2 1
Sample Output 3:
3

Solution:
n=int(input())
l=list(map(int,input().split()))
s=set()
for i in l:
    s.add(i)
print(len(s))


Share:

Welcome Party |Programming_info || python_problem_15

 New Year is shortly arriving and the students of St. Philip’s College of Business are eager to receive the freshers for the coming year. The Welcome party for the freshers is going to be organized in a week’s time and in connection to that the College Management has ordered the students to renovate their class room block. The Class room block has N rooms in it numbered from 1 to N. Each room is currently painted in one of the red, blue or green colors. Students are given configuration of colors of their class room block by an array consisting of N values. In this array, color red will be denoted by '1', green by '2' and blue by '3'.

 
The Management wanted the class room block to be repainted such that each class room has same color. For painting, Students have all the 3 color paints available and mixing any 2 color paints will result into 3rd color paint i.e
  • 1 + 2 = 3
  • 2 + 3 = 1
  • 3 + 1 = 2
For example, if a room is already painted in green color, painting that room red color, will make the color of the room blue.

Also, students have many buckets of paint of each color. Simply put, you can assume that they will not run out of paint. Students are a bit lazy, so they does not want to work much and therefore, has asked you to find the minimum number of rooms they have to repaint (possibly zero) in order to have all the rooms with same color as told by the Management. Can you please help them?
 
Input Format:
First line of input contains an integer N, denoting the number of class rooms in the College’s class room block. Assume that the maximum value for N as 50.
Next line of input contains N values, denoting the current color configuration of rooms.

Output Format:
Print the minimum number of rooms that need to be painted in order to have all the rooms painted with same color i.e red, blue or green.
Refer sample input and output for formatting specifications.

Sample Input 1:
3
1 2 1

Sample Output 1:
1

Sample Input 2:
3
1 1 1

Sample Output 2:
0

Solution:
n=int(input())
l=list(map(int,input().split()))
max=0
num=l[0]
for i in l:
    freq=l.count(i)
    if freq>max:
        max=freq
        num=i
x=l.count(num)
y=n-x
print(y)
Share:

Bob's Challenge |Programming_info || python_problem_14

 Stella and friends have set out on a vacation to Manali. They have booked accommodation in a resort and the resort authorities headed by Bob, organize Campfires every night as a part of their daily activities. Stella volunteered herself for an activity called the "Stick Game".


Stella was given a total of N sticks. The length of i-th stick is Ai. Bob insists Stella choose any four sticks and make a rectangle with those sticks as its sides. Bob warns Stella not to break any of the sticks, she has to use sticks as a whole.
 
Also, Bob wants that the rectangle formed should have the maximum possible area among all the rectangles that Stella can make. Stella takes this challenge up and overcomes it. You have to help her know whether it is even possible to create a rectangle. If yes, then tell the maximum possible area of the rectangle.
 
Input Format:
The first line of the input contains a single integer N denoting the number of sticks.
The second line of each test case contains N space-separated integers A1A2, ...,AN denoting the lengths of sticks.

Output Format:
Output a single line containing an integer representing the maximum possible area for rectangle or output -1, if it's impossible to form any rectangle using the available sticks.
Refer sample input and output for formatting specifications.

Sample Input 1:
5
1 2 3 1 2

Sample Output 1:
2

Sample Input 2:
4
1 2 2 3

Sample Output 2:
-1

Solution:
n=int(input())
l=list(map(int,input().split()))
r=[]
for i in l:
    c=l.count(i)
    if c>1:
        c1=c//2
        r.extend([i]*c1)
        while i in l:
            l.remove(i)
r.sort()
if len(r)>=2:
    print(r[-2]*r[-1])
else:
    print("-1")

Share:

Adjacent Stick Game |Programming_info || python_problem_13

 Steffan and friends have set out on a vacation to Coorg. They have booked accommodation in a resort and the resort authorities organize Camp fires every night as a part of their daily activities. Steffan volunteered himself for an activity called the "Adjacent Stick Game" where sticks of different length will be placed in a line and Steffan needs to remove a stick from each adjacent pair of sticks. He then has to form a bigger stick by combining all the remaining sticks.

 
Steffan needs to know the smallest length of the bigger stick so formed and needs your help to compute the same. Given the number of sticks N and the lengths of each of the sticks, write a program to find the smallest length of the bigger stick that is formed.
 

Input Format:

First line of the input contains an integer N denoting the number of sticks. Assume that the maximum value for N as 50.
Assume that N is always even.
Next line of input contains an N integer denoting the length of each of the sticks.


Output Format:

Output the smallest length of the bigger stick that is formed.
Refer sample input and output for formatting specifications.

 

[All text in bold corresponds to the input and the rest corresponds to output.]


Sample Input and Output 1:

4
2 1 3 1

2


Sample Input and Output 2:

8
2 3 1 4 3 2 1 4

6

Solution:
n=eval(input())
l=list(map(int,input().split()))
s=0
for i in range(0,n,2):
    if l[i]>l[i+1]:
        s+=l[i+1]
    else:
        s+=l[i]
print(s)

Share:

Chocolate Game |Programming_info || python_problem_12

 It was Christmas Eve and the celebrations remembering the birth of Jesus were going on in full swing at the Catheral Chapel. The Event Management Team had arranged for some exciting games after the mass worship and feast, where adults and kids of all ages participated very actively. "Chocolate Game" was organized for the kids which involved a standard chocolate of by m pieces. More formally, chocolate is a rectangular plate consisting of n rows and m columns.

Two kids at a moment will play with the chocolate. First kid takes the chocolate and cuts it into two parts by making either a horizontal or vertical cut. Then, the second kid takes one of the available pieces and divides into two parts by either making a horizontal or vertical cut. Then the turn of first kid comes and he can pick any block of the available chocolates and do the same thing again. The player who cannot make a turn loses.
Write a program to find which of the kids will win if both of them play optimally. Output "Yes", if the kid who plays first will win, otherwise print "No".

Input Format:
The only line of the input contains two space separated integers n and m - the sizes of the chocolate.

Output Format:
Output a single line containing one word "Yes" (without quotes) if there is a sequence of moves leading to the winning of the person who moves first and "No" (without quotes) otherwise.
Refer sample input and output for formatting specifications.

Sample Input 1:
1 2

Sample Output 1:
Yes


Sample Input 2:
1 3

Sample Output 2:
No

Solution:
a,b=input().split()
if (int(a)*int(b))%2==0:
    print("Yes")
else:
    print("No")
Share:

Hanging Bridge |Programming_info || python_problem_11

 At the annual "KrackerJack Karnival", there was a newest attraction ever in the City, the "Hanging Bridge". Visitors will be able to walk 200ft on the bridge, hanging around 50ft above the ground, and enjoy a wide-angle view of the breathtaking greenery.

The Hanging Bridge was inaugurated successfully in co-ordination with the Event Manager Rahul. There is a limit on the maximum number of people on the bridge and Rahul has to now ensure the count of people on the bridge currently should not exceed the limit. He then approximately estimated that adults and kids who came to the show, were on the hanging bridge. He also noticed that there are L legs of the people touching the bridge.
Rahul knows that kids love to ride on the adults and they might ride on the adults, and their legs won't touch the ground and hence he would miss counting their legs. Also Rahul knew that the adults would be strong enough to ride at max two kids on their back.
Rahul is now wondering whether he counted the legs properly or not. Specifically, he is wondering is there some possibility of his counting being correct. Please help Rahul in finding it.

 
Input Format:
The only line of input contains three space separated integers C, D, L denoting number of the adults, number of the kids and number of legs of people counted by Rahul, respectively.

Output Format:
Output a single line containing a string "yes" or "no" (both without quotes) according to the situation.
Refer sample input and output for formatting specifications.

Sample Input 1:
1 1 4

Sample Output 1:
yes

Sample Input 2:
2 4 16

Sample Output 2:
no

Solution:
a,b,c=[int(i) for i in input().split()]
if((a+b)*2>=c):
    print("yes")
else:
    print("no")

Share:

Aayush's Scholarship |Programming_info || python_problem_10


Aayush studies in Teswan National University. Now is the time for exam results. Aayush similar to other students, hopes that his scores in 5 subjects in the exam could fetch him a scholarship for his GRE preparation.
 
The following simple rules  are used to find whether he is eligible to receive scholarship:
  • University follows 5 point grading system. In an exam, a student can receive any score from 2 to 5.  2 is called an F grade, meaning that student has failed that exam.
  • Student should not have fail any of the exams.
  • Student must obtain a full score in some of his/her exams to show that he/she is excellent in some of the subjects.
  • He/She must have a grade point average not less than 4.0
​You are given information regarding how Aayush performed in those 5 subjects . Help him determine whether he will receive the scholarship or not.
 
Input Format:
The input contains 5 space separated integers denoting Aayush’s 5 subjects score in the exam.
 
Output Format:
Output a single line - "Yes" (without quotes) if Aayush will receive scholarship, or "No" (without quotes) otherwise.
Refer sample input and output for formatting specifications.

Sample Input 1:
3 5 4 4 3

Sample Output 1:
No

Sample Input 2:
3 4 4 4 5

Sample Output 2:
Yes

Solution:

a,b,c,d,e =[int(i) for i in input().split()]

if a==2 or b==2 or c==2 or d==2 or e==2:

    print("no")

elif ((a+b+c+d+e)/5>=4.0):

    print("Yes")

else:

    print("No")

Share:

Daily Routine |Programming_info || python_problem_09

 Brendon is a little techno-whiz whose IQ is out of the charts. He has set up a laboratory at home for his research and development and was once approached by an Event Management firm to design them a Robot that would log all the activities carried out in an event at various instants during the day. This would help them keep a track and in smooth functioning of events.

Brendon, after long days of hard work designed one such Robot but wanted to test it on his own daily routines. His daily routine is very simple, he starts his day working in a computer, then he eats food and finally proceeds for sleeping thus ending his day. He has programmed his Robot to log the activities of him at various instants during the day.
Today it recorded activities that Brendon was doing at N different instants. These instances are recorded in chronological order (in increasing order of time). This log is provided to you in form of a string s of length N, consisting of characters 'C', 'E' and 'S'. If s[i] = 'C', then it means that at the i-th instant Brendon was working in Computer, 'E' denoting he was eating and 'S' means he was sleeping.
Write a program to tell whether the record log made by the robot could possibly be correct or not.

Input Format:
The only line of input contains the string s.

Output Format:
Output a single line containing "yes" or "no" (without quotes) accordingly.
Refer sample input and output for formatting specifications.

Sample Input 1:
CES

Sample Output 1:
yes

Sample Input 2:
SCCC

Sample Output 2:
no

Solution:
x=input()
a=0
for i in range(len(x)-1):
    if x[i]=='C':
        if x[i+1]=='C' or x[i+1]=='S' or x[i+1]=='E':
            a+=1
    elif x[i]=='E':
        if x[i+1]=='E' or x[i+1]=='S':
            a+=1
    elif x[i]=='S':
        if x[i+1]=='S':
            a+=1

if(a==len(x)-1):
    print("yes")
else:
    print("no")
Share:

Welcome |Programming_info || python_problem_08

 A recently launched attraction at the "Events Square" entertainment fair is the "Carnival of Terror" which is an interactive fun zone featuring scary, horror and Halloween stories.

 
The Entry tickets for the show is to be printed with a Welcome message along with an additional message for Children stating they should be accompanied by an adult. Given the age of the person visiting the scary house, the ticket should carry the additional message only for Children whose age is less than 15 years. The show organizers wanted your help to accomplish this task. Write a program that will get age as the input and display the appropriate message on the tickets.

 
Input Format:
First line of the input is an integer that corresponds to the age of the person.

Output Format:
Output should display the additional message "Please note that you should be accompanied by an adult" for Children less than 15 years. Otherwise it should print only the Welcome message.
Refer sample input and output for formatting specifications.

Sample Input 1:
20

Sample Output 1:
Welcome to the show

Sample Input 2:
14

Sample Output 2:
Welcome to the show
Please note that you should be accompanied by an adult

 

Solution:

x=int(input())

if(x>=15):

    print("Welcome to the show")

else:

    print("Welcome to the show")

    print("Please note that you should be accompanied by an adult")

Share:

Translate

Recommended platforms

  1. codechef
  2. hackerrank
  3. codeforces
  4. leetcode
  5. hackerearth

Popular Posts

programming_info. Powered by Blogger.

Recent Posts

other platforms

  • geeks for geeks
  • w3schools
  • codepen
  • skillshare
  • udemy

Pages

reader support Support