55# %% auto #0
66__all__ = ['Deck' , 'draw_n' ]
77
8- # %% ../nbs/01_deck.ipynb #b51f5fbf
8+ # %% ../nbs/01_deck.ipynb #c82c3961
99from .card import *
1010from fastcore .utils import *
1111import random
1212
13- # %% ../nbs/01_deck.ipynb #802c4496
13+ # %% ../nbs/01_deck.ipynb #9f01cdee
1414class Deck :
1515 "A deck of 52 cards, not including jokers"
1616 def __init__ (self ): self .cards = [Card (s , r ) for s in range (4 ) for r in range (1 , 14 )]
@@ -23,21 +23,21 @@ def shuffle(self):
2323 "Shuffles the cards in this deck"
2424 random .shuffle (self .cards )
2525
26- # %% ../nbs/01_deck.ipynb #16a52ff8
26+ # %% ../nbs/01_deck.ipynb #8f2f72e1
2727@patch
2828def pop (self :Deck ,
2929 idx :int = - 1 ): # The index of the card to remove, defaulting to the last one
3030 "Remove one card from the deck"
3131 return self .cards .pop (idx )
3232
33- # %% ../nbs/01_deck.ipynb #97ba58dd
33+ # %% ../nbs/01_deck.ipynb #b155c9a2
3434@patch
3535def remove (self :Deck ,
3636 card :Card ): # Card to remove
3737 "Removes `card` from the deck or raises exception if it is not there"
3838 self .cards .remove (card )
3939
40- # %% ../nbs/01_deck.ipynb #ddc0c07d
40+ # %% ../nbs/01_deck.ipynb #c06f233e
4141def draw_n (n :int , # number of cards to draw
4242 replace :bool = True ): # whether or not draw with replacement
4343 "Draw `n` cards, with replacement iif `replace`"
0 commit comments