import random
def solution() -> list:
numbers = [x for x in range(13)]
card_names = ['H','C','D','S']
random.shuffle(card_names)
result = []
for card_name in card_names:
random.shuffle(numbers)
for number in numbers:
result.append(f'{card_name} {number}')
return result
import random
def random_card():
hs = random.choice(['H', 'C', 'D', 'S'])
ds = random.choice([i + 1 for i in range(13)])
s = hs + " " + str(ds)
return s
def solution() -> list:
li = []
for i in range(52):
while True:
s = random_card()
if s not in li:
li.append(s)
break
return li
deck1 = solution()
deck2 = solution()
assert len(set(deck1)) == 52
assert len(set(deck2)) == 52
assert deck1 != deck2
assert sorted(deck1) == sorted(deck2)`预先格式化的文本`
import random
def solution() -> list:
# H表示红桃:heart:、C表示梅花:clubs:、D表示:diamonds:、S表示:spades
card_list = []
flower_list = ['H', 'C', 'D', 'S']
num_list = [i for i in range(1, 14)]
random.shuffle(flower_list)
random.shuffle(num_list)
for flower in flower_list:
for num in num_list:
card_list.append(f"{flower} {num}")
return card_list