-
-
Save meooow25/c66a9a7bd00889c6951c1a2c9cb0864d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
for t in range(int(input())): | |
S = input() | |
f = [y for x, y in Counter(S).most_common()] | |
f = f[::-1] | |
if len(f) > 3 and f[3] != f[2] + f[1]: | |
f[0], f[1] = f[1], f[0] | |
ok = len(f) < 3 or all(f[i] == f[i - 1] + f[i - 2] for i in range(2, len(f))) | |
print('Dynamic' if ok else 'Not') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can we swap only f[0] and f[1] ?