Latest recipes tagged "setgame"http://code.activestate.com/recipes/tags/setgame/new/2013-04-05T12:49:36-07:00ActiveState Code RecipesFinding sets in the card game SET! (Python) 2013-04-05T12:49:36-07:00Sander Evershttp://code.activestate.com/recipes/users/4173111/http://code.activestate.com/recipes/578508-finding-sets-in-the-card-game-set/ <p style="color: grey"> Python recipe 578508 by <a href="/recipes/users/4173111/">Sander Evers</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/setgame/">setgame</a>). Revision 2. </p> <p>In the card game <a href="http://en.wikipedia.org/wiki/Set_%28game%29">SET!</a>, players are shown an array of 12 (or more) symbol cards and try to identify a so-called 3-card <strong>set</strong> among these cards as quickly as possible.</p> <p>A card has four attributes (number, shape, color and shading), each of which can take 3 possible values. In a <strong>set</strong>, for each attribute, all three cards should have either the same value, or the three different values.</p> <p>This recipe solves the problem of finding <em>all</em> sets within an array of an arbitrary number of cards, showing some clever optimizations and celebrating the clarity of Python in expressing the algorithms.</p>