Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Playing-cards/PARI-GP/playing-cards.parigp
Normal file
20
Task/Playing-cards/PARI-GP/playing-cards.parigp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
name(n)=Str(["A",2,3,4,5,6,7,8,9,10,"J","Q","K"][(n+3)>>2],["h","d","s","c"][n%4+1]);
|
||||
newdeck()={
|
||||
v=vector(52,i,i);
|
||||
};
|
||||
deal()={
|
||||
my(n=name(v[1]));
|
||||
v=vecextract(v,2^#v-2);
|
||||
n
|
||||
};
|
||||
printdeck(){
|
||||
apply(name,v)
|
||||
};
|
||||
shuffle()={
|
||||
forstep(n=#v,2,-1,
|
||||
my(i=random(n)+1,t=v[i]);
|
||||
v[i]=v[n];
|
||||
v[n]=t
|
||||
);
|
||||
v
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue