# Arup Guha
# 11/10/2020
# Example with a list of lists where each item is a string.

# Returns which aisle item is in, and returns -1 if not found.
def getAisleEasy(store, item):

    # Go through each aisle.
    for i in range(len(store)):

        # Note: store[i] is a list of items for aisle i.
        if item in store[i]:
            return i

    return -1

# Returns which aisle item is in, and returns -1 if not found.
def getAisleHard(store, item):

    # Go through each aisle.
    for i in range(len(store)):

        # Note: store[i] is a list, store[i][j] is the j th item in the
        # list store[i], or aisle i.
        for j in range(len(store[i])):
            if item == store[i][j]:
                return i

    return -1

# Which aisle has the most of your items...so if you were to only go to one
# aisle, which one should it be?
def bestAisle(store, mylist):

    curBest = -1
    curAisle = -1

    # Go to each aisle.
    for i in range(len(store)):

        # Stores my count of items from this aisle.
        count = 0
        
        # Try each item on my list.
        for item in mylist:

            # Add 1 if it's in this aisle.
            if item in store[i]:
                count += 1

        # This aisle is better, so update.
        if count > curBest:
            curBest = count
            curAisle = i

    # TA da! The best aisle!
    return curAisle

# Some tests.    
def main():

    # Simple store - 5 aisles, 3 items each.
    grocerystore = [["apples", "bananas", "strawberries"],
                    ["doritos", "lays", "sunchips"],
                    ["mandms", "snickers","reesespieces"],
                    ["chicken", "beef", "fish"],
                    ["subs", "friedchicken", "salad"]]

    # Tested both Easy and Hard functions here.
    print(getAisleHard(grocerystore, "beef"))
    print(getAisleHard(grocerystore, "salad"))
    print(getAisleHard(grocerystore, "pork"))

    # Best Aisle!
    print(bestAisle(grocerystore, ["apples", "subs", "paper", "salad"]))
    print(bestAisle(grocerystore, ["snickers", "beef", "reesepieces", "mandms"]))    

# Run the tests.
main()
    



