Basketball one on one problem

Problem Info

Basketball one on one
https://open.kattis.com/problems/basketballoneonone

My Work

def who_won(records):
  score_a = 0
  score_b = 0
  for i in range(0,len(records)-1, 2):
    if records[i] == "A":
      score_a += int(records[i+1])
    if records[i] == "B":
      score_b += int(records[i+1])
  if score_a > score_b:
    return "A"
  return "B"

The code is really simple. It takes advantage of the fact that the letters are odd indexes and the corresponding scores are on the even indexes. After figuring which score is which, the scores of A and B are compared.

What I’ve Tried

I’m pretty sure all we have to do is just return the letter of the winner, but I don’t think there’s really anything wrong with my code. But, alas, the solution wasn’t valid. I’m actually completely stumped right now, because I can’t think why it wouldn’t work, probably because it’s pretty late at night right now. Also, people who have experience with the kattis website, can you see where exactly you went wrong like Leetcode? Like what testcase scenario didn’t work with the code?

Question

Include a specific question if you have one.

Checklist

See How to ask for help on a problem for more information.

  • Include a link to the problem
  • Format your post (especially code blocks)
  • Include what you’ve tried so far
  • Add comments to your code
  • Read the debugging module

lol i’m just as confused as you are

I have no idea what you did, but I used your code and it worked just fine


Maybe you didn’t read the input and print the output?

Another way to solve the problem is to look at who scored the last point