GoalScope — is_happy (Qwen2.5-Coder-32B-Instruct) — hover a token to see the patched verbalization
↵
<code>↵
def is_happy(s):↵
"""Check if the string s is 'happy'.↵
↵
A string is 'happy' if it contains only the letters 'a' and 'b'↵
and every 'a' is followed by at least one 'b'.↵
↵
Args:↵
s (str): The string to check.↵
↵
Returns:↵
bool: True if the string is happy, False otherwise.↵
"""↵
if not s:↵
return True↵
if 'a' not in s:↵
return True↵
for i in range(len(s) - 1):↵
if s[i] == 'a' and s[i + 1] != 'b':↵
return False↵
if s[-1] == 'a':↵
return False↵
return True↵
</code>