# Kathleen Prendergast
# 5/7/22
# Card Game Assignment

import random


# Get each name
name1 = input("What is your name?\n")
name2 = input("What is the name of your first friend?\n")
name3 = input("What is the name of your second friend?\n")

# First roll.
random.seed()
roll1 = random.randint(1,4)
print(name1, "rolled a", roll1, end=".\n")

# Second roll.
roll2 = random.randint(1,4)
print(name2, "rolled a", roll2, end=".\n")

# Third roll.
roll3 = random.randint(1,4)
print(name3, "rolled a", roll3, end=".\n")

# First person wins.
if (roll1 < roll2 and roll1 < roll3):
    first = name1

# Second person wins.    
elif (roll2 < roll1 and roll2 < roll3):
        first = name2

# Third person wins.    
elif (roll3 < roll1 and roll3 < roll2):
        first = name3

# Tie case.
else:

    # All tied.
    if (roll1 == roll2 == roll3):

        # This finds which name comes first alphabetically.
        if (name1 < name2 and name1 < name3):
            first = name1
        elif (name2 < name1 and name2 < name3):
            first = name2
        else:
            first = name3

    # Next case where only the first two rolls are tied for the smallest.
    elif (roll1 == roll2):

        # This distinguishes between the two.
        if (name1 < name2):
            first = name1
        else:
            first = name2

    # This is for a tie between names 2 and 3.
    elif (roll2 == roll3):
        if (name2 < name3):
            first = name2
        else:
            first = name3

    # This has to be a tie between names 1 and 3.
    else:
        if (name1 < name3):
            first = name1
        else:
            first = name3

    # Ta da!
    print(first, "will go first!")

main()
