Last active
September 21, 2019 09:43
-
-
Save katrinafyi/e2cc52a4e58426746508d01f42e353fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
import string | |
import sys | |
from itertools import product | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print('specify number of cards as argument', file=sys.stderr) | |
sys.exit(1) | |
suits = 'SDCH' | |
ranks = string.hexdigits.lower().replace('0', ''); | |
cards = list(product(suits, ranks)) | |
n = int(sys.argv[1]) | |
if n > len(cards): | |
raise ValueError(f'{n} exceeds the maximum number of cards, {len(cards)}') | |
print(n) | |
random.shuffle(cards) | |
for i in range(n): | |
s, r = cards[i] | |
print(s, r, sep='') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beautiful <3