-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcartas.py
45 lines (33 loc) · 887 Bytes
/
cartas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import random
palos = ('o', 'c', 'e', 'b')
cartas = ('A', '2', '3', '4', '5', '6', '7', 's', 'c', 'r')
def crea_baraja():
baraja = []
for palo in palos:
for carta in cartas:
naipe = carta + palo
baraja.append(naipe)
return baraja
def mezclar(b):
br = []
while len(b) != len(br):
n = random.randint(0, len(b)-1)
while b[n] in br:
n = random.randint(0, len(b)-1)
br.append(b[n])
b[:] = br
return b
def repartir(b, players, cards):
res = []
for p in range(players):
res.append([])
for ic in range(cards):
for ij in range(players):
carta = b.pop(0)
res[ij].append(carta)
return res
def invertir(b):
for i in range (len(b)//2):
almacen = b[i]
b[i] = b[-1 -i]
b[-1 -i] = almacen