Success Party Hackerearth problem coderinme

Success Party

A billionaire won a lottery but he is a big miser so to minimize the people he organizes a party but in a different style.
Each member attending a party is given a name and a single digit number (from 0 to 9). Now they all play a game.
The rules of the game are as follows:
If only one player is playing the game,then he will be the winner.
Otherwise, all the players add the numbers provided to them until they get a single digit number.
If the number obtained is available with any one of the player attending the party, then that player is declared as the winner.
Otherwise the game is declared as a draw.

1 ≤ T ≤ 100
1 ≤ n ≤ 1000

The first line contains T — the number of test cases.
Each test case contains a number n-the number of people attending the party.
Next n lines contains the name and the number separated by space.


If the game is declared as a draw then print “NO”(without double quotes).
Otherwise print the name of the winners in each line and also display the total number of winners.

def sum_digits(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s
for x in range(int(input())):
	sum = 0
	s = []
	m = []
	n = int(input())
	for i in range(n):
		lis = [str(x) for x in input().split()]
		sum = sum + int(lis[1])
	no = sum_digits(sum)
		no = sum_digits(no)
	st = []
	for y in range(len(m)):
		if int(m[y]) == no:
	if len(st) == 0:
		for z in st:

Competitive coder

Hackerearth coder

A web developer(Front end and Back end), and DBA at Currently working as Salesforce Developer @ Tech Matrix IT Consulting Private Limited. Check me

Leave a reply:

Your email address will not be published.