#C4579. Happy Day Checker
Happy Day Checker
Happy Day Checker
You are given a string that represents a day. A day is considered "Happy" if the string contains a palindromic substring of length at least 2. In other words, there exists an index i such that one of the following conditions holds:
$$S_i = S_{i+1}$$
or
$$S_i = S_{i+2}$$
If neither condition is satisfied, then the day is "Sad". Your task is to determine whether the given day is "Happy" or "Sad".
Note: The palindromic substring must be contiguous.
inputFormat
The input consists of a single line containing a non-empty string S
representing the day.
The string will only consist of English letters and its length will be at least 1.
outputFormat
Output a single line containing either Happy
if the day is happy (i.e. there is a palindromic substring of length at least 2) or Sad
otherwise.
abac
Happy