Set, the card game: Difference between revisions

Added FreeBASIC
(Added FreeBASIC)
 
(36 intermediate revisions by 11 users not shown)
Line 5:
In the game a number of cards are layed out face up and the players try to identify "sets" within the cards.
 
A set is three cards where either the symbols on the cards are all the same or they are all different, the number of symbols on the cards are all the same or all different, the colours are all the same or all different, and the shadings are all the same or all different.
 
For example, this is a set:
Line 31:
;Also see:
 
::* The wikipediaWikipedia article, [[wp:Set (card game)|Set (card game)]]
 
=={{header|Acornsoft Lisp}}==
See [[Set puzzle#Acornsoft_Lisp]]
 
The [[Set puzzle]] task is so similar that the same solution can be used. Just redefine <code>play</code> from
 
<syntaxhighlight lang="lisp">
(defun play ((n-cards . 9))
(find-enough-sets n-cards (quotient n-cards 2)))
</syntaxhighlight>
 
to
 
<syntaxhighlight lang="lisp">
(defun play ((n-cards . 9))
(find-enough-sets n-cards 0))
</syntaxhighlight>
 
=={{header|C++}}==
<syntaxhighlight lang="c++">
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <random>
#include <string>
#include <unordered_set>
#include <vector>
 
const std::vector<std::string> numbers { "ONE", "TWO", "THREE" };
const std::vector<std::string> colours { "GREEN", "RED", "PURPLE" };
const std::vector<std::string> shadings { "OPEN", "SOLID", "SRIPED" };
const std::vector<std::string> shapes { "DIAMOND", "OVAL", "SQUIGGLE" };
 
typedef std::vector<std::string> Card;
 
std::vector<Card> create_pack_of_cards() {
std::vector<Card> pack;
for ( std::string number : numbers ) {
for ( std::string colour : colours ) {
for ( std::string shading : shadings ) {
for ( std::string shape : shapes ) {
Card card = { number, colour, shading, shape };
pack.emplace_back(card);
}
}
}
}
return pack;
}
 
bool all_same_or_all_different(const std::vector<Card>& triple, const int32_t& index) {
std::unordered_set<std::string> triple_set;
for ( const Card& card : triple ) {
triple_set.insert(card[index]);
}
return triple_set.size() == 1 || triple_set.size() == 3;
}
 
bool is_game_set(const std::vector<Card>& triple) {
return all_same_or_all_different(triple, 0) &&
all_same_or_all_different(triple, 1) &&
all_same_or_all_different(triple, 2) &&
all_same_or_all_different(triple, 3);
}
 
template <typename T>
std::vector<std::vector<T>> combinations(const std::vector<T>& list, const int32_t& choose) {
std::vector<std::vector<T>> combinations;
std::vector<uint64_t> combination(choose);
std::iota(combination.begin(), combination.end(), 0);
 
while ( combination[choose - 1] < list.size() ) {
std::vector<T> entry;
for ( const uint64_t& value : combination ) {
entry.emplace_back(list[value]);
}
combinations.emplace_back(entry);
 
int32_t temp = choose - 1;
while ( temp != 0 && combination[temp] == list.size() - choose + temp ) {
temp--;
}
combination[temp]++;
for ( int32_t i = temp + 1; i < choose; ++i ) {
combination[i] = combination[i - 1] + 1;
}
}
return combinations;
}
 
int main() {
std::random_device rand;
std::mt19937 mersenne_twister(rand());
 
std::vector<Card> pack = create_pack_of_cards();
for ( const int32_t& card_count : { 4, 8, 12 } ) {
std::shuffle(pack.begin(), pack.end(), mersenne_twister);
std::vector<Card> deal(pack.begin(), pack.begin() + card_count);
std::cout << "Cards dealt: " << card_count << std::endl;
for ( const Card& card : deal ) {
std::cout << "[" << card[0] << " " << card[1] << " " << card[2] << " " << card[3] << "]" << std::endl;
}
std::cout << std::endl;
 
std::cout << "Sets found: " << std::endl;
for ( const std::vector<Card>& combination : combinations(deal, 3) ) {
if ( is_game_set(combination) ) {
for ( const Card& card : combination ) {
std::cout << "[" << card[0] << " " << card[1] << " " << card[2] << " " << card[3] << "] ";
}
std::cout << std::endl;
}
}
std::cout << "-------------------------" << std::endl << std::endl;
}
}
</syntaxhighlight>
{{ out }}
<pre>
Cards dealt: 4
[TWO GREEN OPEN SQUIGGLE]
[THREE GREEN SRIPED OVAL]
[TWO RED SOLID SQUIGGLE]
[ONE GREEN SRIPED OVAL]
 
Sets found:
-------------------------
 
Cards dealt: 8
[ONE PURPLE OPEN SQUIGGLE]
[ONE GREEN OPEN OVAL]
[ONE RED SOLID DIAMOND]
[TWO RED SOLID OVAL]
[TWO PURPLE OPEN DIAMOND]
[THREE PURPLE SOLID OVAL]
[TWO GREEN SOLID OVAL]
[THREE RED OPEN SQUIGGLE]
 
Sets found:
[ONE GREEN OPEN OVAL] [TWO PURPLE OPEN DIAMOND] [THREE RED OPEN SQUIGGLE]
-------------------------
 
Cards dealt: 12
[ONE RED SRIPED DIAMOND]
[THREE GREEN OPEN OVAL]
[ONE GREEN SRIPED DIAMOND]
[THREE GREEN SRIPED DIAMOND]
[TWO GREEN SRIPED SQUIGGLE]
[ONE PURPLE OPEN SQUIGGLE]
[TWO RED SOLID OVAL]
[ONE RED SOLID SQUIGGLE]
[THREE GREEN OPEN DIAMOND]
[THREE RED SRIPED DIAMOND]
[TWO RED OPEN OVAL]
[TWO PURPLE SRIPED SQUIGGLE]
 
Sets found:
[THREE GREEN SRIPED DIAMOND] [ONE PURPLE OPEN SQUIGGLE] [TWO RED SOLID OVAL]
[ONE PURPLE OPEN SQUIGGLE] [THREE GREEN OPEN DIAMOND] [TWO RED OPEN OVAL]
[ONE RED SOLID SQUIGGLE] [THREE RED SRIPED DIAMOND] [TWO RED OPEN OVAL]
-------------------------
</pre>
 
=={{header|Common Lisp}}==
 
The [[Set puzzle]] task is so similar that the [[Set puzzle#Common_Lisp|Common Lisp solution]] there could be used with only slight modification. Here we take a somewhat more different approach by creating the deck as a vector, so that it can be shuffled more efficiently, rather than taking a random sample from the deck represented as a list.
 
Compare [[#Acornsoft_Lisp|Acornsoft Lisp]] above.
 
<syntaxhighlight lang="lisp">
(defparameter numbers '(one two three))
(defparameter shadings '(solid open striped))
(defparameter colours '(red green purple))
(defparameter symbols '(oval squiggle diamond))
 
(defun play (&optional (n-cards 9))
(let* ((deck (make-deck))
(deal (take n-cards (shuffle deck)))
(sets (find-sets deal)))
(show-cards deal)
(show-sets sets)))
 
(defun show-cards (cards)
(format t "~D cards~%~{~(~{~10S~}~)~%~}~%"
(length cards) cards))
 
(defun show-sets (sets)
(format t "~D sets~2%~:{~(~@{~{~8S~}~%~}~)~%~}"
(length sets) sets))
 
(defun find-sets (deal)
(remove-if-not #'is-set (combinations 3 deal)))
 
(defun is-set (cards)
(every #'feature-makes-set (transpose cards)))
 
(defun feature-makes-set (feature-values)
(or (all-same feature-values)
(all-different feature-values)))
 
(defun combinations (n items)
(cond
((zerop n) '(()))
((null items) '())
(t (append
(mapcar (lambda (c) (cons (car items) c))
(combinations (1- n) (cdr items)))
(combinations n (cdr items))))))
 
;;; Making a deck
 
(defun make-deck ()
(let ((deck (make-array (list (expt 3 4))))
(i -1))
(dolist (n numbers deck)
(dolist (sh shadings)
(dolist (c colours)
(dolist (sy symbols)
(setf (svref deck (incf i))
(list n sh c sy))))))))
 
;;; Utilities
 
(defun shuffle (deck)
(loop for i from (1- (length deck)) downto 0
do (rotatef (elt deck i)
(elt deck (random (1+ i))))
finally (return deck)))
 
(defun take (n seq) ; returns a list
(loop for i from 0 below n
collect (elt seq i)))
 
(defun all-same (values)
(every #'eql values (rest values)))
 
(defun all-different (values)
(every (lambda (v) (= (count v values) 1))
values))
 
(defun transpose (list-of-rows)
(apply #'mapcar #'list list-of-rows))
</syntaxhighlight>
 
{{Out}}
 
Depending on which Common Lisp you use, calling <code>(play)</code> might output:
 
<pre>
12 cards
three solid purple diamond
one striped green squiggle
two striped purple diamond
three open purple diamond
three striped red squiggle
one solid green squiggle
three open purple oval
two open green squiggle
two solid red diamond
three open red squiggle
three solid red oval
two solid green squiggle
 
1 sets
 
one striped green squiggle
three open purple oval
two solid red diamond
</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
attr$[][] &= [ "one " "two " "three" ]
attr$[][] &= [ "solid " "striped" "open " ]
attr$[][] &= [ "red " "green " "purple" ]
attr$[][] &= [ "diamond " "oval " "squiggle" ]
#
for card = 0 to 80
pack[] &= card
.
proc card2attr card . attr[] .
attr[] = [ ]
for i to 4
attr[] &= card mod 3 + 1
card = card div 3
.
.
proc prcards cards[] . .
for card in cards[]
card2attr card attr[]
for i to 4
write attr$[i][attr[i]] & " "
.
print ""
.
print ""
.
ncards = randint 5 + 7
print "Take " & ncards & " cards:"
for i to ncards
ind = randint len pack[]
cards[] &= pack[ind]
pack[ind] = pack[len pack[]]
len pack[] -1
.
prcards cards[]
#
for i to len cards[]
card2attr cards[i] a[]
for j = i + 1 to len cards[]
card2attr cards[j] b[]
for k = j + 1 to len cards[]
card2attr cards[k] c[]
ok = 1
for at to 4
s = a[at] + b[at] + c[at]
if s <> 3 and s <> 6 and s <> 9
# 1,1,1 2,2,2 3,3,3 1,2,3
ok = 0
.
.
if ok = 1
print "Set:"
prcards [ cards[i] cards[j] cards[k] ]
.
.
.
.
</syntaxhighlight>
 
{{out}}
<pre>
Take 10 cards:
one striped purple oval
two open red oval
one open purple oval
three open purple diamond
one open purple diamond
three open red oval
one striped green oval
two striped purple squiggle
one open red oval
two solid green oval
 
Set:
one striped purple oval
three open red oval
two solid green oval
 
Set:
two open red oval
three open red oval
one open red oval
</pre>
 
=={{header|Factor}}==
<syntaxhighlight lang="factor">USING: grouping io kernel literals math.combinatorics
prettyprint qw random sequences sequences.product sets ;
 
CONSTANT: cards $[
qw{
one two three
solid open striped
red green purple
diamond oval squiggle
} 3 group <product-sequence>
]
 
: deal ( n -- seq ) cards swap sample ;
 
: set? ( seq -- ? ) cardinality { 1 3 } member? ;
 
: sets ( seq -- newseq )
3 [ flip [ set? ] all? ] filter-combinations ;
 
: .length ( seq str -- ) write bl length . nl ;
 
: .cards ( seq -- )
[ " " join dup "o" head? "" "s" ? append print ] each nl ;
 
: .sets ( seq -- )
dup "Sets present:" .length [ .cards ] each ;
 
: play ( n -- )
deal [ "Cards dealt:" .length ]
[ .cards ]
[ sets .sets ] tri ;
 
4 8 12 [ play ] tri@</syntaxhighlight>
{{out}}
<pre>
Cards dealt: 4
 
two solid purple ovals
three open green diamonds
two striped purple ovals
three solid purple diamonds
 
Sets present: 0
 
Cards dealt: 8
 
two open red squiggles
one open red oval
two striped purple diamonds
one striped green oval
one striped red squiggle
three solid purple ovals
one solid green diamond
three striped purple ovals
 
Sets present: 1
 
two open red squiggles
one solid green diamond
three striped purple ovals
 
Cards dealt: 12
 
two striped purple diamonds
two open purple ovals
three striped green squiggles
one striped red diamond
three open green diamonds
three open green squiggles
two open green ovals
two solid red diamonds
three open purple squiggles
one open purple squiggle
two solid green ovals
two striped green ovals
 
Sets present: 2
 
one striped red diamond
three open purple squiggles
two solid green ovals
 
two open green ovals
two solid green ovals
two striped green ovals
</pre>
 
=={{header|FreeBASIC}}==
{{trans|Phix}}
<syntaxhighlight lang="vbnet">Dim Shared As String*5 nums(2) = {"one", "two", "three"}
Dim Shared As String*7 shades(2) = {"solid", "striped", "open"}
Dim Shared As String*6 colours(2) = {"red", "green", "purple"}
Dim Shared As String*8 symbols(2) = {" diamond", " oval", "squiggle"}
 
Sub showcard(card As Integer)
Dim As Integer n, s, c, m
n = card Mod 3
card \= 3
s = card Mod 3
card \= 3
c = card Mod 3
card \= 3
m = card Mod 3
Print Trim(nums(n)); " "; Trim(shades(s)); " "; Trim(colours(c)); " "; _
Trim(symbols(m)); Iif(n = 0, "", "s")
End Sub
 
Sub showsets(hand() As Integer)
Dim As Integer i, j, k
Dim As Integer uh = Ubound(hand) + 1
Color 14: Print "Cards dealt: "; uh
Color 7: Print
If uh <> 81 Then
For i = 0 To uh - 1
showcard(hand(i))
Next
End If
Dim As Integer sets = 0
For i = 0 To uh - 3
For j = i + 1 To uh - 2
For k = j + 1 To uh - 1
If (hand(i) + hand(j) + hand(k)) Mod 3 = 0 Then sets += 1
Next
Next
Next
Print
Color 11: Print "Sets present: "; sets
Color 7: Print
If uh <> 81 Then
For i = 0 To uh - 3
For j = i + 1 To uh - 2
For k = j + 1 To uh - 1
If (hand(i) + hand(j) + hand(k)) Mod 3 = 0 Then
showcard(hand(i))
showcard(hand(j))
showcard(hand(k))
Print
End If
Next
Next
Next
End If
End Sub
 
Randomize Timer
Dim As Integer i, deal, j
Dim As Integer pack(80)
For i = 0 To 80
pack(i) = i
Next
 
For deal = 4 To 81 Step 4
For i = 80 To 1 Step -1
j = Int(Rnd * (i + 1))
Swap pack(i), pack(j)
Next
Dim As Integer hand(deal - 1)
For i = 0 To deal - 1
hand(i) = pack(i)
Next
showsets(hand())
Next
 
Sleep</syntaxhighlight>
 
=={{header|J}}==
Implementation:
<syntaxhighlight lang=J>deck=: >,{;:each'one two three';'red green purple';'solid striped open';'diamond oval squiggle'
deal=: (?#) { ]
 
sets=: {{ >;sets0\y }}
sets0=: {{ <;({:y) sets1\}:y }}
sets1=: {{ <~.;({:y) sets2 m\}:y }}
sets2=: {{ <(m,:n)<@,"2 1 y#~m isset n"1 y }}
isset=: {{ 1=#~.(m=n),(m=y),:n=y }}
 
disp=: <@(;:inv)"1</syntaxhighlight>
 
Task examples:
<syntaxhighlight lang=J> four=: 4 deal deck
eight=: 8 deal deck
twelve=: 12 deal deck
>disp four
one purple striped oval
one purple striped diamond
three green solid oval
two red solid oval
>disp eight
three green striped diamond
two green open squiggle
three purple striped squiggle
one purple solid squiggle
two green solid oval
three purple solid squiggle
two red solid oval
three purple solid diamond
>disp twelve
two red solid squiggle
three purple open squiggle
two purple open oval
one purple open oval
one green solid oval
three green striped oval
one green open oval
three green open squiggle
one red open squiggle
one purple striped squiggle
two purple striped diamond
two red open diamond
disp sets four
┌┐
││
└┘
disp sets eight
┌┐
││
└┘
disp sets twelve
┌─────────────────────────┬───────────────────────────┬──────────────────────────┐
│three green open squiggle│one purple striped squiggle│two red solid squiggle │
├─────────────────────────┼───────────────────────────┼──────────────────────────┤
│one green open oval │two red open diamond │three purple open squiggle│
├─────────────────────────┼───────────────────────────┼──────────────────────────┤
│three green open squiggle│two red open diamond │one purple open oval │
└─────────────────────────┴───────────────────────────┴──────────────────────────┘
</syntaxhighlight>
 
=={{header|Java}}==
<syntaxhighlight lang="java">
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
 
public final class SetTheCardGame {
 
public static void main(String[] args) {
List<Card> pack = createPackOfCards();
for ( int cardCount : List.of( 4, 8, 12 ) ) {
Collections.shuffle(pack);
List<Card> deal = pack.subList(0, cardCount);
System.out.println("Cards dealt: " + cardCount);
for ( Card card : deal ) {
System.out.println(card);
}
System.out.println();
System.out.println("Sets found: ");
for ( List<Card> combination : combinations(deal, 3) ) {
if ( isGameSet(combination) ) {
for ( Card card : combination ) {
System.out.print(card + " ");
}
System.out.println();
}
}
System.out.println("-------------------------" + System.lineSeparator());
}
}
private static interface Feature {}
private static enum Number implements Feature { ONE, TWO, THREE }
private static enum Colour implements Feature { GREEN, RED, PURPLE }
private static enum Shading implements Feature { OPEN, SOLID, STRIPED }
private static enum Shape implements Feature { DIAMOND, OVAL, SQUIGGLE }
private static record Card(Number number, Colour colour, Shading shading, Shape shape) {
public String toString() {
return "[" + number + " " + colour + " " + shading + " " + shape + "]";
}
}
private static List<Card> createPackOfCards() {
List<Card> pack = new ArrayList<Card>(81);
for ( Number number : Number.values() ) {
for ( Colour colour : Colour.values() ) {
for ( Shading shading : Shading.values() ) {
for ( Shape shape : Shape.values() ) {
pack.add( new Card(number, colour, shading, shape) );
}
}
}
}
return pack;
}
private static boolean isGameSet(List<Card> triple) {
return allSameOrAllDifferent(triple.stream().map( c -> (Feature) c.number ).toList()) &&
allSameOrAllDifferent(triple.stream().map( c -> (Feature) c.colour ).toList()) &&
allSameOrAllDifferent(triple.stream().map( c -> (Feature) c.shading ).toList()) &&
allSameOrAllDifferent(triple.stream().map( c -> (Feature) c.shape ).toList());
}
private static boolean allSameOrAllDifferent(List<Feature> features) {
Set<Feature> featureSet = new HashSet<Feature>(features);
return featureSet.size() == 1 || featureSet.size() == 3;
}
private static <T> List<List<T>> combinations(List<T> list, int choose) {
List<List<T>> combinations = new ArrayList<List<T>>();
List<Integer> combination = IntStream.range(0, choose).boxed().collect(Collectors.toList());
while ( combination.get(choose - 1) < list.size() ) {
combinations.add(combination.stream().map( i -> list.get(i) ).toList());
int temp = choose - 1;
while ( temp != 0 && combination.get(temp) == list.size() - choose + temp ) {
temp -= 1;
}
combination.set(temp, combination.get(temp) + 1);
for ( int i = temp + 1; i < choose; i++ ) {
combination.set(i, combination.get(i - 1) + 1);
}
}
return combinations;
}
 
}
</syntaxhighlight>
{{ out }}
<pre>
Cards dealt: 4
[TWO RED OPEN SQUIGGLE]
[THREE PURPLE OPEN DIAMOND]
[TWO PURPLE STRIPED DIAMOND]
[THREE RED STRIPED DIAMOND]
 
Sets found:
-------------------------
 
Cards dealt: 8
[ONE RED STRIPED SQUIGGLE]
[TWO RED SOLID OVAL]
[ONE PURPLE STRIPED OVAL]
[TWO GREEN OPEN SQUIGGLE]
[TWO GREEN STRIPED DIAMOND]
[THREE GREEN OPEN OVAL]
[TWO RED OPEN SQUIGGLE]
[ONE PURPLE SOLID SQUIGGLE]
 
Sets found:
[TWO RED SOLID OVAL] [ONE PURPLE STRIPED OVAL] [THREE GREEN OPEN OVAL]
-------------------------
 
Cards dealt: 12
[TWO PURPLE SOLID SQUIGGLE]
[TWO GREEN SOLID SQUIGGLE]
[THREE PURPLE OPEN DIAMOND]
[ONE RED SOLID DIAMOND]
[ONE PURPLE STRIPED OVAL]
[ONE PURPLE OPEN SQUIGGLE]
[TWO RED OPEN DIAMOND]
[THREE RED SOLID OVAL]
[THREE PURPLE SOLID SQUIGGLE]
[ONE GREEN STRIPED OVAL]
[ONE RED OPEN SQUIGGLE]
[ONE PURPLE OPEN OVAL]
 
Sets found:
[TWO PURPLE SOLID SQUIGGLE] [THREE PURPLE OPEN DIAMOND] [ONE PURPLE STRIPED OVAL]
[ONE RED SOLID DIAMOND] [ONE PURPLE OPEN SQUIGGLE] [ONE GREEN STRIPED OVAL]
[TWO RED OPEN DIAMOND] [THREE PURPLE SOLID SQUIGGLE] [ONE GREEN STRIPED OVAL]
-----------------------
</pre>
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">import BaseRandom: vec, string, printshuffle
import Random: shuffle
import Combinatorics: combinations
 
Line 44 ⟶ 768:
 
struct SetCard
numbert::Tuple{UInt8, UInt8, UInt8, UInt8}
shading::UInt8
color::UInt8
symbol::UInt8
function SetCard(num, sha, col, sym)
@assert all(i -> 1 <= i <= 3, (num, sha, col, sym))
return new(tuple(num, sha, col, sym))
end
end
 
numfunction Base.string(s::SetCard) = NUMBERS[s.number]
return "(" *
sha(s::SetCard) = SHADINGS[s.shading]
join([NUMBERS[s.t[1]], SHADINGS[s.t[2]], COLORS[s.t[3]], SYMBOLS[s.t[4]]], " ") *
col(s::SetCard) = COLORS[s.color]
(s.t[1] == 1 ? "" : "s") * ")"
sym(s::SetCard) = SYMBOLS[s.symbol]
Base.vec(sc::SetCard) = [sc.number, sc.shading, sc.color, sc.symbol]
function Base.string(sc::SetCard)
plu = sc.number == 1 ? "" : "s"
return "(" * join([num(sc), sha(sc), col(sc), sym(sc)], " ") * plu * ")"
end
Base.print(io:: IO, sc::SetCard) = print(io, string(sc))
Base.print(io:: IO, vsc::Vector{SetCard}) = print(io, "[" * join(string.(vsc), ", ") * "]")
 
""" True ifReturn thean 3iterator cards formfor a setvector according toof the Setsets gamefound rulesin the dealt `cards` """
function allsameordifferent(sc1::SetCard, sc2, sc3)
a, b, c = vec(sc1), vec(sc2), vec(sc3)
return all(i -> a[i] == b[i] == c[i] || a[i] != b[i] && a[i] != c[i] && b[i] != c[i], eachindex(a))
end
 
""" Return a vector of the sets in the vector of SetCards """
function process_deal(cards::Vector{SetCard})
return Iterators.filter(combo -> allsameordifferent(combo...), combinations(cards, 3)) do c
return all(i -> (c[1].t[i] + c[2].t[i] + c[3].t[i]) % 3 == 0, eachindex(c[1].t))
end
end
 
Line 132 ⟶ 845:
 
=={{header|Phix}}==
Cards are 0..80 in decimal, which is 0000..2222 in base 3, and we can just
subtract '/' from each digit to get indexes 1..3 to the constants.
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 139 ⟶ 854:
<span style="color: #000000;">symbols</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"diamond"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"oval"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"squiggle"</span><span style="color: #0000FF;">}</span>
<span style="color: #008080;">functionprocedure</span> <span style="color: #000000;">decodeshowcard</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">tcard</span><span style="color: #0000FF;">)</span>
<span style="color: #000000000080;">t</span> <span font-style="color: #0000FFitalic;">-=</span>- <spanaside: &-1 prevents style="color:JS does #000000;not support string subscript destructuring">1</span>
<span style="color: #004080;">integer</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">remaindersq_sub</span><span style="color: #0000FF;">(</span><span style="color: #0000007060A8;">tsprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%04a"</span><span style="color: #0000FF;">,{{</span><span style="color: #000000;">3</span><span style="color: #0000FF;">)+,</span><span style="color: #000000;">1card</span><span style="color: #0000FF;">}}),</span><span style="color: #008000;">'/'</span><span style="color: #0000FF;">)</span> <span style="color: #0000FF;">&</span> <span style="color: #0000FF;">-</span><span style="color: #000000;">1</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000008000;">"%s %s %s %s%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">nums</span><span style="color: #0000FF;">[</span><span style="color: #000000;">n</span><span style="color: #0000FF;">],</span><span style="color: #7060A8000000;">remaindershades</span><span style="color: #0000FF;">([</span><span style="color: #7060A8000000;">floors</span><span style="color: #0000FF;">(],</span><span style="color: #000000;">tcolours</span><span style="color: #0000FF;">[</span><span style="color: #000000;">c</span><span style="color: #0000FF;">],</span><span style="color: #000000;">3symbols</span><span style="color: #0000FF;">)[</span><span style="color: #000000;">m</span><span style="color: #0000FF;">],</span><span style="color: #7060A8;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">3n</span><span style="color: #0000FF;">)+=</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,?</span><span style="color: #008000;">""</span><span style="color: #0000FF;">:</span><span style="color: #008000;">"s"</span><span style="color: #0000FF;">)})</span>
<span style="color: #000000;">c</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">t</span><span style="color: #0000FF;">/</span><span style="color: #000000;">9</span><span style="color: #0000FF;">),</span><span style="color: #000000;">3</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">m</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">t</span><span style="color: #0000FF;">/</span><span style="color: #000000;">27</span><span style="color: #0000FF;">),</span><span style="color: #000000;">3</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">1</span>
<span style="color: #008080;">return</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span><span style="color: #0000FF;">?</span><span style="color: #008000;">""</span><span style="color: #0000FF;">:</span><span style="color: #008000;">"s"</span><span style="color: #0000FF;">)}</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">showcard</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">card</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">integer</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">card</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s %s %s %s%s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">nums</span><span style="color: #0000FF;">[</span><span style="color: #000000;">n</span><span style="color: #0000FF;">],</span><span style="color: #000000;">shades</span><span style="color: #0000FF;">[</span><span style="color: #000000;">s</span><span style="color: #0000FF;">],</span><span style="color: #000000;">colours</span><span style="color: #0000FF;">[</span><span style="color: #000000;">c</span><span style="color: #0000FF;">],</span><span style="color: #000000;">symbols</span><span style="color: #0000FF;">[</span><span style="color: #000000;">m</span><span style="color: #0000FF;">],</span><span style="color: #000000;">card</span><span style="color: #0000FF;">[</span><span style="color: #000000;">5</span><span style="color: #0000FF;">]})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
Line 156 ⟶ 863:
<span style="color: #004080;">integer</span> <span style="color: #000000;">lh</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hand</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Cards dealt: %d\n%n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">lh</span><span style="color: #0000FF;">,</span><span style="color: #000000;">lh</span><span style="color: #0000FF;">!=</span><span style="color: #000000;">81</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">lh</span><span style="color: #0000FF;">!=</span><span style="color: #000000;">81</span> <span style="color: #008080;">then</span> <span style="color: #7060A8;">papply</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hand</span><span style="color: #0000FF;">,</span><span style="color: #000000;">showcard</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">c</span> <span style="color: #008080;">in</span> <span style="color: #000000;">hand</span> <span style="color: #008080;">do</span> <span style="color: #000000;">showcard</span><span style="color: #0000FF;">(</span><span style="color: #000000;">decode</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">))</span> <span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">sets</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">t</span> <span style="color: #008080;">in</span> <span style="color: #7060A8;">combinations</span><span style="color: #0000FF;">(</span><span style="color: #000000;">hand</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">sequenceinteger</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">c1r3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c3</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #000000;">t</span><span style="color: #0000FF;">,</span><span style="color: #000000;">decode</span><span style="color: #0000FF;">)0</span>
<span style="color: #004080008080;">boolfor</span> <span style="color: #000000;">foundr</span> <span style="color: #008080;">in</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">9</span><span style="color: #0000FF;">,</span><span style="color: #000000;">27</span><span style="color: #0000FF;">}</span> <span style="color: #004600008080;">truedo</span>
<span style="color: #008080000000;">forr3</span> <span style="color: #0000000000FF;">i+=</span> <span style="color: #7060A8;">rmdr</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sum</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sq_rmdr</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sq_floor_div</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1t</span><span style="color: #0000FF;">,</span><span style="color: #008080000000;">tor</span><span style="color: #0000FF;">),</span><span style="color: #000000;">43</span><span style="color: #0000FF;">)),</span><span style="color: #008080000000;">3</span><span style="color: #0000FF;">do)</span>
<span style="color: #008080;">if</span> <span style="color: #008080;">not</span> <span style="color: #0000FF;">(</span><span style="color: #000000;">c1</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]=</span><span style="color: #000000;">c2</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">and</span> <span style="color: #000000;">c2</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]=</span><span style="color: #000000;">c3</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">])</span>
<span style="color: #008080;">and</span> <span style="color: #008080;">not</span> <span style="color: #0000FF;">(</span><span style="color: #000000;">c1</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]!=</span><span style="color: #000000;">c2</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">and</span> <span style="color: #000000;">c2</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]!=</span><span style="color: #000000;">c3</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">and</span> <span style="color: #000000;">c1</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]!=</span><span style="color: #000000;">c3</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">])</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">found</span> <span style="color: #0000FF;">=</span> <span style="color: #004600;">false</span>
<span style="color: #008080;">exit</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">foundr3</span><span style="color: #0000FF;">=</span><span style="color: #000000;">0</span> <span style="color: #008080;">then</span> <span style="color: #000000;">sets</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">sets</span><span style="color: #0000FF;">,</span><span style="color: #000000;">t</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">sets</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">sets</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">c1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c3</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\nSets present: %d\n\n"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">sets</span><span style="color: #0000FF;">))</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">lh</span><span style="color: #0000FF;">!=</span><span style="color: #000000;">81</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">s</span> <span style="color: #008080;">in</span> <span style="color: #000000;">sets</span> <span style="color: #008080;">do</span>
<span style="color: #0080807060A8;">forpapply</span> <span style="color: #0000000000FF;">c(</span> <span style="color: #008080;">in</span> <span style="color: #000000;">s</span> <span style="color: #0080800000FF;">do,</span> <span style="color: #000000;">showcard</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
Line 183 ⟶ 881:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">pack</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">tagsettagstart</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">81</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">deal</span> <span style="color: #008080;">in</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">4</span><span style="color: #0000FF;">,</span><span style="color: #000000;">8</span><span style="color: #0000FF;">,</span><span style="color: #000000;">12</span><span style="color: #0000FF;">,</span><span style="color: #000000;">81</span><span style="color: #0000FF;">}</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">pack</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">shuffle</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pack</span><span style="color: #0000FF;">)</span>
Line 401 ⟶ 1,099:
 
=={{header|Quackery}}==
 
Why does <code>isset</code>, the word that tests if three cards constitute a set, use <code>+</code> and <code>mod</code>?
 
If we map any of the properties, say colour, onto the numbers 0, 1 and 2, then the sum of three colours mod 3 is 0 if and only if all the colours are different or all the colours are the same. This can be confirmed exhaustively, or for the underlying mathematics see the first two paragraphs of the section "A Mathematical Perspective" (pages 7 and 8) in this paper:
 
::[https://web.math.princeton.edu/~charchan/SET.pdf SETs and Anti-SETs: The Math Behind the Game of SET, by Charlotte Chan]
 
<code>transpose</code> is defined at [[Matrix transposition#Quackery]].
Line 406 ⟶ 1,110:
<code>comb</code> and <code>arrange</code> are defined at [[Combinations#Quackery]].
 
<syntaxhighlight lang="Quackery"> [ true swap transpose witheach
witheach
[ 0 swap witheach +
3 mod 0if [ not conclude ] ] ] is isset ( [ --> ifb )
[ not conclude ] ] ] is isset ( [ --> b )
 
[ [ [] 81 times
[ i 4 times [ 3 /mod swap ]
[drop 3 /mod swaptimes ]join
drop
3 times join
nested join ] ] constant
shuffle swap split drop ] is cards ( n --> [ )
 
[ [] swap dup size swap 3 rot comb
dup size swap
3 rot comb
witheach
[ dip dup arrange
dup isset iff
[ nested rot join swap ]
else drop ] drop ] is sets ( [ --> [ )
join swap ]
else drop ]
drop ] is sets ( [ --> [ )
 
[ unpack dup dip
[ [ table
$ "one" $ "two" $ "three" ]
do echo$ "two"sp
$ "three" ] do echo$ sp
[ table
$ "solid" $ "striped" $ "open" ]
do echo$ "striped"sp
$ "open" ] do echo$ sp
[ table
$ "red" $ "green" $ "purple" ]
do echo$ "green"sp
$ "purple" ] do echo$ sp
[ table
$ "diamond" $ "squiggle" $ "oval" ]
do echo$ "squiggle"]
if [ say "s" ] cr ] is echocard ( [ --> )
$ "oval" ] do echo$ ]
0 > if [ say "s" ]
cr ] is echocard ( [ --> )
 
[ dup cards swap
cr say "Cards dealt: " echo cr cr
dup witheach echocard cr
cr
sets dup size
say "Sets present: " echo cr cr
witheach [ witheach echocard cr ] ] is play ( n --> )
witheach
[ witheach echocard
cr ] ] is play ( n --> )
 
' [ 4 8 12 ] witheach [ play say "-----" ]</syntaxhighlight>
[ play say "-----" ]</syntaxhighlight>
 
{{out}}
Line 524 ⟶ 1,211:
 
-----</pre>
 
=={{header|Raku}}==
 
<syntaxhighlight lang="raku" line>my @attributes = <one two three>, <solid striped open>, <red green purple>, <diamond oval squiggle>;
 
sub face ($_) { .polymod(3 xx 3).kv.map({ @attributes[$^k;$^v] }) ~ ('s' if $_%3) }
 
sub sets (@cards) { @cards.combinations(3).race.grep: { !(sum ([Z+] $_».polymod(3 xx 3)) »%» 3) } }
 
for 4,8,12 -> $deal {
my @cards = (^81).pick($deal);
my @sets = @cards.&sets;
say "\nCards dealt: $deal";
for @cards { put .&face };
say "\nSets found: {+@sets}";
for @sets { put .map(&face).join("\n"), "\n" };
}
 
say "\nIn the whole deck, there are {+(^81).&sets} sets.";</syntaxhighlight>
{{out|Sample output}}
<pre>Cards dealt: 4
one open purple squiggle
one striped red squiggle
three striped green diamonds
one open green diamond
 
Sets found: 0
 
Cards dealt: 8
three striped purple squiggles
three open green diamonds
one striped purple oval
three open red squiggles
two striped red diamonds
one solid purple diamond
one solid red oval
one solid green diamond
 
Sets found: 2
three open green diamonds
two striped red diamonds
one solid purple diamond
 
three open red squiggles
two striped red diamonds
one solid red oval
 
Cards dealt: 12
three open purple squiggles
one striped purple diamond
two striped red squiggles
two striped green squiggles
one solid green oval
three open red squiggles
two striped purple diamonds
three striped purple squiggles
one open red diamond
two striped red diamonds
two striped green ovals
one open green oval
 
Sets found: 3
three open purple squiggles
one solid green oval
two striped red diamonds
 
two striped red squiggles
two striped purple diamonds
two striped green ovals
 
one solid green oval
three open red squiggles
two striped purple diamonds
 
 
In the whole deck, there are 1080 sets.</pre>
=={{header|Ruby}}==
 
<syntaxhighlight lang="ruby" line>
ATTRIBUTES = [:number, :shading, :colour, :symbol]
Card = Struct.new(*ATTRIBUTES){ def to_s = values.join(" ") }
combis = %i[one two three].product(%i[solid striped open], %i[red green purple], %i[diamond oval squiggle])
PACK = combis.map{|combi| Card.new(*combi) }
 
def set?(trio) = ATTRIBUTES.none?{|attr| trio.map(&attr).uniq.size == 2 }
 
[4, 8, 12].each do |hand_size|
puts "#{"_"*40}\n\nCards dealt: #{hand_size}"
puts hand = PACK.sample(hand_size)
sets = hand.combination(3).select{|h| set? h }
puts "\n#{sets.size} sets found"
sets.each{|set| puts set, ""}
end</syntaxhighlight>
{{out|Sample output}}
<pre>________________________________________
 
Cards dealt: 4
one striped green squiggle
one open red squiggle
two striped green oval
three solid green diamond
 
0 sets found
________________________________________
 
Cards dealt: 8
three open green squiggle
three striped green diamond
three striped red oval
three open red oval
three solid red diamond
one solid purple diamond
two open red diamond
one striped red diamond
 
2 sets found
three striped green diamond
one solid purple diamond
two open red diamond
 
three solid red diamond
two open red diamond
one striped red diamond
 
________________________________________
 
Cards dealt: 12
one solid purple oval
one striped purple oval
one open red diamond
three striped purple squiggle
three striped purple oval
three solid green squiggle
three solid purple diamond
two solid green squiggle
two open green squiggle
three open green diamond
two open purple squiggle
one striped red squiggle
 
3 sets found
one striped purple oval
three solid purple diamond
two open purple squiggle
 
one open red diamond
three striped purple oval
two solid green squiggle
 
three solid green squiggle
two open purple squiggle
one striped red squiggle
</pre>
 
 
=={{header|Wren}}==
Line 530 ⟶ 1,371:
{{libheader|Wren-perm}}
Note that entering 81 for the number of cards to deal confirms that there are 1080 possible sets.
<syntaxhighlight lang="ecmascriptwren">import "random" for Random
import "./ioutil" for Input
import "./fmt" for Fmt
Line 585 ⟶ 1,426:
}
 
var prompt = "Enter number of cards to deal - 3 to 81 or 2q to exitquit: "
Input.quit = "q"
while(true) {
Random.new().shuffle(pack) // shuffle for each deal
var i = Input.integer(prompt, 23, 81)
if (i == 2Input.quit) return
var dealt = pack[0...i]
System.print()
Line 600 ⟶ 1,442:
Sample run:
<pre>
Enter number of cards to deal - 3 to 81 or 2q to exitquit: 4
 
three solid green diamonds
Line 609 ⟶ 1,451:
Sets present: 0
 
Enter number of cards to deal - 3 to 81 or 2q to exitquit: 8
 
one open green squiggle
Line 626 ⟶ 1,468:
one striped green squiggle
 
Enter number of cards to deal - 3 to 81 or 2q to exitquit: 12
 
three open green ovals
Line 655 ⟶ 1,497:
three solid red diamonds
 
Enter number of cards to deal - 3 to 81 or 2q to exitquit: 2q
</pre>
2,122

edits