# Arup Guha
# 11/7/2017
# Program to verify answer to COT 3100 Homework 7 Question 2E

# I store each super letter in tokens.
tokens = ["OLAND","A", "C", "D", "D", "L", "M", "N", "O", "R"]

# This stores each unique string I want to count that contains "OLAND"
# Note: The use of the set naturally takes care of not adding duplicates.
strings = set()

# Usual permutation function, takes in the ordering, which items have
# been used and how many items are fixed in my permutation.
def perm(order, used, k):

    # Filled in the permutation - build the string and add to our set.
    if k == len(order):
        build = ""
        for i in range(len(order)):
            build = build + tokens[order[i]]
        strings.add(build)

    # Must recurse.
    else:

        # Try each valid item in slot k and recurse.
        for i in range(len(order)):
            if (not used[i]):
                used[i] = True
                order[k] = i
                perm(order, used, k+1)
                used[i] = False

# We run our test from main...
def main():
    order = [0]*10
    used = [False]*10
    perm(order, used, 0)
    print(len(strings))

# Get main going...
main()
                
