In the card game of Set, each card has four distinct attributes:
- shape (diamond, oval, squiggle)
- colour (green, red, purple)
- fill (blank, lined, filled)
- count (one, two, three)
A set is made from any three cards where the attributes are either all the same or all different.
In our application, a Set card is modelled by:
Card = Struct.new(:shape, :colour, :fill, :count)
(All attributes are passed as symbols.)
Your task is to implement the following function which takes three Card
objects as input, and returns true
if the three cards make a set, or false
otherwise.
def set?(*cards)
# Add your implementation here
end
Constraints:
- All cards in a deck of Set are unique, so you don't need to care about looking for duplicates.