why do i get wrong answer in the following question (CLFIBD|python3.6)

Question code: CLFIBD

My code: for i in range(int(input())): str1=input() l=list(str1) s=set(l) l2=[] if len(s)<3: print("Dynamic") else: for x in s: a=l.count(x) l2.append(a) l2.sort() b=len(l2) ans=True for y in range(0,b-2): if l2[y]+l2[y+1]==l2[y+2]: ans=ans and True else: ans=ans and False if ans ==True: print ("Dynamic") else: print ("Not")

1 Like

You need to take into account this case:

abbcccdddd

which is Dynamic under the permutation (b,a,c,d).

Oh correct. Thanks a lot