Skip to content

Instantly share code, notes, and snippets.

@katrinafyi
Last active September 21, 2019 09:43
Show Gist options
  • Save katrinafyi/e2cc52a4e58426746508d01f42e353fe to your computer and use it in GitHub Desktop.
Save katrinafyi/e2cc52a4e58426746508d01f42e353fe to your computer and use it in GitHub Desktop.
#!/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='')
@Moss1410
Copy link

Beautiful <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment