Python Question: There is a card game called Set. It has a deck of 81 cards. Each
Question:
Python Question:
There is a card game called Set. It has a deck of 81 cards.
Each card has some colored shapes. They are distinguished by the shapes, the color of the shapes,
the number of shapes, and the shading of the shapes. Each of these four attributes can take three
possible values.
Sets of three cards form a Set if for each attribute, the three cards are all the same or all different. In
the picture below, there is a set. It is marked in the next figure.
The goal of the game is to find these sets. Moreover, the goal is to identify these sets faster than
anyone else.
If there is no set on the table, more cards are added one at a time. As soon as you see a set you
shout "Set" and point out the set you found.
You will write a program that reads line of input from stdin that represents a list of cards. The format
of the input will be strings of numbers in {0,1,2} separated by whitespace.
0101 2010 1201 0001 1000 2111 1121 1002
This string represents eight cards. The cards are laid out in the order given, one at a time. Your
program should print the number of cards read until the first set. For example, for the following input,
the output would be 4.
1201 0001 1000 1102 2202 0021
Your goal is to run in quadratic time. Cubic time is okay, but not as good. (Hint: a dictionary can be
useful).
Call your program FindSet.py. It should read from stdin.