Set puzzle

From Rosetta Code
Revision as of 23:05, 9 February 2013 by rosettacode>Fwend (add draft task)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Set puzzle is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Set Puzzles are created with a deck of cards from the Set Game(TM). The object of the puzzle is to find sets of 3 cards in a rectangle of cards that have been dealt face up. There are 81 cards in a deck. Each card contains a variation of the following four features: color, symbol, number and shading.

there are three colors
red, green, or purple
there are three symbols
oval, squiggle, or diamond
there is a number of symbols on the card
one, two, or three
there are three shadings
solid, open, or striped


Three cards form a set if each feature is either the same on each card, or is different on each card. For instance: all 3 cards are red, all 3 cards have a different symbol, all 3 cards have a different number of symbols, all 3 cards are striped.


There are two degrees of difficulty: basic and advanced. The basic mode deals 9 cards, that contain 4 sets; the advanced mode deals 12 cards that contain 6 sets. The task is to write code that deals the cards, 9 or 12, depending on selected mode, and print the contents of the cards and the sets. For instance:


DEALT 9 CARDS:

green, one, oval, striped

green, one, diamond, open

green, one, diamond, striped

green, one, diamond, solid

purple, one, diamond, open

purple, two, squiggle, open

purple, three, oval, open

red, three, oval, open

red, three, diamond, solid


CONTAINING 4 SETS:

green, one, oval, striped

purple, two, squiggle, open

red, three, diamond, solid


green, one, diamond, open

green, one, diamond, striped

green, one, diamond, solid


green, one, diamond, open

purple, two, squiggle, open

red, three, oval, open


purple, one, diamond, open

purple, two, squiggle, open

purple, three, oval, open