# Arup Guha
# 1/11/2013
# Solution to Programming Knights Practice Program Chapter 4 Problem 6
# Uses sets to list out numbers divisible by 15 and 21, 15 or 21, and
# exactly one of 15 and 21, less than 1000.

MAX = 1000

def main():

    # Create set of multiples of 15.
    div15 = set()
    for i in range(15, MAX, 15):
        div15.add(i)

    # Create set of multiples of 15.
    div21 = set()
    for i in range(21, MAX, 21):
        div21.add(i)

    # Calculate each operation using the appropriate operator.
    either =  div15 | div21
    both = div15 & div21
    exactlyone = div15 ^ div21

    # To make the output easy to read, convert to a list and sort.
    listeither = list(either)
    listeither.sort()
    listboth = list(both)
    listboth.sort()
    listexactlyone = list(exactlyone)
    listexactlyone.sort()

    # Print out each list.
    print("Divisible by either", listeither)
    print("Divisible by both", both)
    print("Divisible by exactly one", exactlyone)

main()
