• 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:

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