Please help me in COOK82A (LALIGA)

Hi,
I coded solution for https://www.codechef.com/problems/COOK82A using python. And all test cases seems to work perfectly fine in IDE. However, on submission my code is failing. I am suspecting it to be an issue with output. Can someone please help in this regard?

Here is my code…

def accept_input():
    no_of_test_cases= int(input())
    if no_of_test_cases>500:
        exit(10)
    teamBarcelona = []
    teamMalaga = []
    teamRealMadrid = []
    teamEibar = []
    result = []
    def whereDoILand(ip):
        print(ip)
        if ip[0] == "Barcelona" and int(ip[1])<=20:
            teamBarcelona.append(ip)
        elif ip[0] == "Malaga" and int(ip[1])<=20:
            teamMalaga.append(ip)
        elif ip[0] == "RealMadrid" and int(ip[1])<=20:
            teamRealMadrid.append(ip)
        elif ip[0] == "Eibar" and int(ip[1])<=20:
            teamEibar.append(ip)

    def whoWonTheGame(idx):
        if int(teamRealMadrid[i][1])<int(teamMalaga[i][1]) and int(teamBarcelona[i][1])>int(teamEibar[i][1]):
            result.append("Barcelona")
        else:result.append("RealMadrid")


    for i in range(0,no_of_test_cases):
        ip = input()
        whereDoILand(ip.split(" "))
        ip = input()
        whereDoILand(ip.split(" "))
        ip = input()
        whereDoILand(ip.split(" "))
        ip = input()
        whereDoILand(ip.split(" "))

    for i in range(0,no_of_test_cases):
        whoWonTheGame(i)

    return result


result=accept_input()
for winner in result:
    print(winner)
1 Like

Hey there. I just ran your code on the online IDE. When the input is :

 2
Barcelona 2
Malaga 1
RealMadrid 1
Eibar 0
Malaga 3
RealMadrid 2
Barcelona 8
Eibar 6

Your program gives the output :

['Barcelona', '2']
['Malaga', '1']
['RealMadrid', '1']
['Eibar', '0']
['Malaga', '3']
['RealMadrid', '2']
['Barcelona', '8']
['Eibar', '6']
RealMadrid
Barcelona

However, the output should be :

RealMadrid
Barcelona

So, even when your program is working all fine and giving correct output, it will be considered wrong when submitted because the output is not in the format in which it is asked to be printed and unnecessary details are printed alongside as well. Hope this resolves your query.

1 Like