Skip to content

Instantly share code, notes, and snippets.

@Rushi98
Created November 11, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rushi98/bb7c320ca25ed8daf5a37e6749f8a6c6 to your computer and use it in GitHub Desktop.
Save Rushi98/bb7c320ca25ed8daf5a37e6749f8a6c6 to your computer and use it in GitHub Desktop.
T = int(raw_input())
for __ in range(T):
tmp = str(raw_input())
c = 0
for l in range(1,len(tmp)):
a = []
for i in range(len(tmp) - l + 1):
a.append(tmp[i:i+l])
for i in range(len(a)):
for j in range(i + 1, len(a)):
if sorted(list(a[i])) == sorted(list(a[j])) :c += 1
print c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment