Skip to content

Instantly share code, notes, and snippets.

Created Apr 19, 2022
What would you like to do?
# You have a basket of socks
# There are a random assortment of socks
# They may have pairs
# Pick a sock out of the basket
# Keep pickings socks, one a time, until you have gone through them all
# Every time you find a match, put them together and set aside
import random
# random.seed(1)
basket = [random.randint(1,4) for i in range(10)]
socks = set()
for sock in basket:
if sock not in socks:
print("found match: " + str(sock))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment