题解 | 开心还是难过

开心还是难过

https://www.nowcoder.com/practice/bdbe8ce947e64745b6383f16807b6e77

str_ = str(input())
positions = []
start = 0
while start < len(str_) - 2:
    pos = str_.find(':-', start)
    if pos == -1:
        break
    positions.append(pos)
    start = pos + 1
# print(positions)
sad = 0
happy = 0
for pos in positions:
    kuohao = str_[pos+2]
    if kuohao == '(':
        sad+=1
    elif kuohao == ')':
        happy+=1
if happy == 0 and sad == 0:
    print('None')
elif happy == sad:
    print('Just so so')
elif happy > sad:
    print('Happy')
elif sad > happy:
    print('Sad')



全部评论

相关推荐

01-12 20:31
东北大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务