Skip to content

Instantly share code, notes, and snippets.

@mtayseer
Forked from aessam/check_anagram.py
Last active August 29, 2015 14:17
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 mtayseer/e5c45ded6a3f67629ca4 to your computer and use it in GitHub Desktop.
Save mtayseer/e5c45ded6a3f67629ca4 to your computer and use it in GitHub Desktop.
import math
def string_norm(s):
return math.sqrt(sum(ord(c) ** 2 for c in s if c != ' '))
def anagram_detection(s1,s2):
return string_norm(s1) == string_norm(s2)
s1 = input("Please enter first string: ").lower()
s2 = input("Please enter second string: ").lower()
print ("Anagram.") if anagram_detection(s1, s2) else print ("Not Anagram.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment