Answer to Question #302667 in Python for Charan

Question #302667

Highest Sum of Scores

The students in the class were divided into groups of three.Each student was given a T-shirt for a game.Later they were asked to calculate the score of their group by adding the jersey numbers on the T-shirt of every member.Find the group with the highest scores and print the jersey numbers on the T-shirts of every group member.


Input

The first line of the input contains an integer N that denotes the number of groups.

The next N lines of input contains the scores of students in the group separated by comma.


Output

The output contains the scores of the students of the group with maximum sum separated by space.


Explanation

Given the input lists are [[0,1,2],[3,1,0]].

The sum of the scores is highest in the group[3,1,0] i.e., 4.So the output should be 3 1 0.


Sample Input1

2

0,1,2

3,1,0

Sample Output1

3 1 0


1
Expert's answer
2022-02-25T10:29:21-0500
array=[]
print("Enter integer N: ", end='')
n = int(input())
print(f"Enter {n} lines of scores (separated by comma):")
for i in range(n):
    a = input().split(',')
    array.append([])
    sum = 0
    for j in range(len(a)):
        array[i].append(int(a[j]))
        sum += array[i][j]
    if i == 0:
        max = sum
        ind_max = i
    elif max < sum:
        max = sum
        ind_max = i

print('Output:')
for j in range(len(array[ind_max])):
    print(array[ind_max][j], end =' ')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS