Skillrack Inlab Problem 4

Solutions for Skillrack CSE1001 Inlab 4

11-Oct-2016 to 16-Oct-2016

Total time : 20 mins

Challenges : 1

Question (Government survey)

A team of experts formed by Govt. of India conducted a survey on colleges in India. Let us assume that the survey was conducted in ‘n’ number of institutes. The experts were asked to rank the institutes based on three different metrics. The metrics are facilities, academics and infrastructure. Maximum score in each category is as follows.

Facilities = 25

Academics = 50

Infrastructure = 25

At the end of the survey the scores of the individual metrics are added up to get the total score and the institutes are ranked based on the total score. The institute that scores the highest score is ranked 1st. Next highest score is given the rank 2 and so on. Write a program to read the scores of the three metrics for each institute, store the scores in a list. Make a list of individual score list for 10 institutes. Print only the Total score in the sorted (Descending) order. Use insertion sort for arranging the data in descending order.

Input format:

First line contains the number of institutes

Next line contains the scores for Facilities of Institute 1

Next line contains the scores for Academics of Institute 1

Next line contains the scores for Infrastructure of Institute 1

Next line contains the scores for Facilities of Institute 2

Next line contains the scores for Academics of Institute 2

Next line contains the scores for Infrastructure of Institute 2

Next line contains the scores for Facilities of Instituten

Next line contains the scores for Academics of Instituten

Next line contains the scores for Infrastructure of Instituten

Output format:

List of total scores in the descending order

Solution

n=int(input())
l=[]
for i in range(n) :
	s=0
	s+=int(input())
	s+=int(input())
	s+=int(input())
	l.append(s)
for i in range(1, len(l)):
        t=l[i]
        j=i-1
        while (j>=0) and (l[j]<t):
            l[j+1]=l[j]
            j=j-1
        l[j+1]=t
print(l)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s