from pprint import pprint


#############################################################
# dictionaries
#############################################################


subject_6100 = {
    "number": "6.100",
    "name": "Intro to Programming and CS",
    "units": 12,
    "description": "Develops foundational skills in programming...",
}
subject_6100A = {
    "number": "6.100A",
    "name": "Intro to CS Programming",
    "units": 6,
    "description": "Introduction to computer science and programming...",
}


# print()
# print(subject_6100)
# print(subject_6100A)

# print()
# pprint(subject_6100)
# pprint(subject_6100A)

# print()
# print(subject_6100["name"])
# print(subject_6100["units"])
# print(subject_6100.get("units"))
# subject_6100["units"] = 18
# pprint(subject_6100)


subjects_list = [
    subject_6100,
    subject_6100A,
    {
        "number": "6.100B",
        "name": "Intro to Computational Thinking",
        "units": 6,
        "description": "Provides an introduction to using computation...",
    },
    {
        "number": "6.101",
        "name": "Fundamentals of Programming",
        "units": 12,
        "description": "Introduces fundamental concepts of programming...",
    },
]


# print()
# pprint(subjects_list)


subject_numbers = ["6.100", "6.100A", "6.100B", "6.101"]
subjects = {}
for i in range(len(subjects_list)):
    subjects.update({subject_numbers[i]: subjects_list[i]})


# print()
# pprint(subjects)


# print()
# print(subjects["6.100A"]["units"])

# print(subjects["6.101"]["prereqs"])  # KeyError
# print(subjects["6.101"].get("prereqs"))
# print(subjects["6.101"].get("prereqs", "NONE SPECIFIED"))
# print(subjects["6.100"].get("prereqs", []))

# subjects["6.101"]["prereqs"] = ["6.100"]
# subjects["6.100B"]["prereqs"] = ["6.100A"]
# pprint(subjects)


# print()
# for elt in subject_6100:
#     print(elt)

# print()
# for elt in subject_6100.items():
#     print(elt)

# print()
# for property, value in subject_6100.items():
#     print(value)


def remove_value(pairs, target):
    """
    Remove all key-value pairs from a dict that match a given target
    value. Mutate the pairs dict, and return None
    """
    # debug this code
    for key, val in pairs.items():
        if val == target:
            del pairs[key]


# print()

# test = {"a": 1, "b": 2, "c": 1, "d": 2, "e": 2}
# remove_value(test, 1)
# print(test)

# test = {"a": 1, "b": 2, "c": 1, "d": 2, "e": 2}
# remove_value(test, 2)
# print(test)



def all_anagrams(words):
    """
    An anagram is a word with the same letters as another word, but
    rearranged. Given a non-empty list of strs, return True if they are
    all anagrams of each other, and False othewise.
    """
    # TODO


# print()
# print(all_anagrams(["listen", "silent", "enlist"]))
# print(all_anagrams(["evil", "vile", "veil", "live", "vill"]))


#############################################################
# tuples
#############################################################


# print()
# print({
#     1: ["a"],
#     2: ["b", "c"],
#     3: {"d": "e", "f": "g", "h": "i"},
# })
# print({
#     ["a"]: 1,
#     ["b", "c"]: 2,
#     {"d": "e", "f": "g", "h": "i"}: 3,
# })  # TypeError
# print({
#     ("a",): 1,
#     ("b", "c"): 2,
#     (("d", "e"), ("f", "g"), ("h", "i")): 3,
# })


seq = (1, (2, 3), 4)
repeat = 1, (2, 3), 4
# print()
# print(seq)
# print(repeat)
# print(seq == repeat)


subject_6101 = {
    "number": "6.101",
    "name": "Fundamentals of Programming",
    "units": 12,
    "description": "Introduces fundamental concepts of programming...",
}

subjects = {
    ("6.101", "2025 spring"): subject_6101 | {"prereqs": ["6.100A"]},
    ("6.101", "2025 fall"): subject_6101 | {"prereqs": ["6.100"]},
}


# print()
# pprint(subjects)
# pprint(subjects[("6.101", "2025 fall")])


#############################################################
# graphs
#############################################################


flights = {
    "Boston": ["Providence", "New York"],
    "Providence": ["Boston", "New York"],
    "New York": ["Chicago"],
    "Chicago": ["Denver", "Phoenix"],
    "Denver": ["New York", "Phoenix"],
    "Los Angeles": ["Boston"],
}


prereqs = {
    "6.100B": ["6.100A"],
    "6.101": ["6.100"],
    "6.120": ["18.01"],
    "6.121": ["6.100A", "6.120"],
    "6.190": ["6.100A"],
    "6.191": ["8.02", "6.100A", "6.190"],
}
