Wong answer on kattis problem beekeeper

After almost a year of absence from competitive programming, I tried my hand at one of the simpler Kattis problems: beekeeper.

I wrote a quick solution that, for some reason, works for the sample input but not for the second, secret, one:

vowels = {"a","e","i","o","u","y"}

def doubles(s:str) -> int:
    ans = 0
    for i in range(len(s)-1):
        a,b = s[i],s[i+1]
        if a in vowels and a==b: ans+=1
    return ans

assert(doubles("ee")==1)
assert(doubles("eevaa")==2)
assert(doubles("baloon")==1)
assert(doubles("llbbtt")==0)


while True:
    n = int(input()) # size of sample
    if n <= 0: break

    winner = ""
    winner_num = 0
    for _ in range(n):
        word = input()
        num = doubles(word)
        # print(num)
        if num > winner_num: 
            winner = word
            winner_num = num
    print(winner)

What have I done wrong? Thanks for the attention

What did you expect as output?
What did you get as output?

@barry How do you get the secret test cases?

I can’t find the mistake, but it passes if you change L26 from
if num > winner_num:
to
if num >= winner_num:

I can only imagine that one of the secret test cases is something like

1
a

and the judge expects the output to be a. However, that input violates the instructions:

1 Like

Different Barry. @barry-scott not @barry :smiley:

1 Like

That case doesn’t violate the instructions.

Doesn’t it? a contains zero vowel pairs. All other words in the list (the empty set) also contain zero vowel pairs. Zero is not strictly more than zero, so the test case violates the instructions.

No. Since there aren’t any other words, there also aren’t any comparisons.

Thanks! It worked for me too. I agree with the hypothesis that at least one secret test case contained a single word without any doubles so this fixes the problem