Skip to content

Instantly share code, notes, and snippets.

@meooow25
Created April 15, 2018 00:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meooow25/c66a9a7bd00889c6951c1a2c9cb0864d to your computer and use it in GitHub Desktop.
Save meooow25/c66a9a7bd00889c6951c1a2c9cb0864d to your computer and use it in GitHub Desktop.
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')
@vepriya
Copy link

vepriya commented Jan 19, 2019

can we swap only f[0] and f[1] ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment