OrderedSet

I'd like you to make an OrderedSet class. This class should work like a set, but it should also maintain the insertion order of the items added to it (unlike Python's built-in set which is unordered).

>>> ordered_words = ['these', 'are', 'words', 'in', 'an', 'order']
>>> print(*set(ordered_words))
an words in these are order
>>> print(*OrderedSet(ordered_words))
these are words in an order
>>> print(*OrderedSet(['repeated', 'words', 'are', 'not', 'repeated']))
repeated words are not

This set should be relatively memory efficient and containment checks should be relatively time efficient:

>>> words = OrderedSet(['hello', 'hello', 'how', 'are', 'you'])
>>> len(words)
4
>>> 'hello' in words
True

Initially you don't have to worry about allowing sets to be modified after they've been made. Just focus on getting len and the in operator.

Bonus 1


This is just a preview of the problem statement.

This exercise includes 3 bonuses, 8 hint links, and automated tests.