Deal cards for FreeCell: Difference between revisions

→‎{{header|Python}}: Modified code to run with both python2 and python3
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(→‎{{header|Python}}: Modified code to run with both python2 and python3)
Line 2,739:
=={{header|Python}}==
{{trans|D}}
<lang python>from sys import argv
 
def randomGenerator(seed=1):
Line 2,751:
def deal(seed):
nc = 52
cards = list(range(nc - 1, -1, -1))
rnd = randomGenerator(seed)
for i, r in zip(range(nc), rnd):
Line 2,759:
 
def show(cards):
l = ["A23456789TJQK"[int(c / 4)] + "CDHS"[c % 4] for c in cards]
for i in range(0, len(cards), 8):
print " ", (" ".join(l[i : i+8]))
 
if __name__ == '__main__':
from sys import argv
seed = int(argv[1]) if len(argv) == 2 else 11982
print ("Hand {}", .format(seed))
deck = deal(seed)
show(deck)</lang>
{{out}}
<pre>Hand 11982
AH AS 4H AC 2D 6S TS JS
3D 3H QS QC 8S 7H AD KS
KD 6H 5S 4D 9H JH 9S 3C
JC 5D 5C 8C 9D TD KH 7C
6C 2C TH QH 6D TC 4S 7S
JD 7D 8H 9C 2H QD 4C 5H
KC 8D 2S 3S</pre>
 
=={{header|Racket}}==