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)
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.
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