Files

26 lines
668 B
Python

# HumanEval/80
# Loki Mode Multi-Agent Solution
# Attempts: 1
# Passed: True
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
is_happy(a) => False
is_happy(aa) => False
is_happy(abcd) => True
is_happy(aabb) => False
is_happy(adb) => True
is_happy(xyy) => False
"""
if len(s) < 3:
return False
for i in range(len(s) - 2):
a, b, c = s[i], s[i + 1], s[i + 2]
if a == b or b == c or a == c:
return False
return True