#
# anagram.py - simple anagram checker
# Written by Nick A. Rusnov, 2007
#

import sys
import string

# Some options make it more or less strict. we'll go ahead and default
# to the standard way anagrams are composed in English.
def isAnagram(strA, strB, ignorepunc=True, ignorecase=True):
    """Determine if two strings are anagrams of each other."""
    if ignorepunc:
        mt = string.maketrans('','')
        strA = strA.translate(mt, string.punctuation+string.whitespace)
        strB = strB.translate(mt, string.punctuation+string.whitespace)
    if ignorecase:
        strA = strA.lower()
        strB = strB.lower()
    strA = list(strA)
    strB = list(strB)
    strA.sort()
    strB.sort()

    return strA == strB

if __name__ == "__main__":
    if len(sys.argv) >= 3:
        str1 = sys.argv[1]
        str2 = sys.argv[2]
    else:
        print """Using default strings 'Alec Guinness' and 'genuine class'
Specify your own on the command line!
"""
        str1 = 'Alec Guinness'
        str2 = 'genuine class'
    if isAnagram(str1, str2):
        print "ANAGRAMS!"
    else:
        print "Not anagrams"

