Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Playing-cards/Hy/playing-cards.hy
Normal file
29
Task/Playing-cards/Hy/playing-cards.hy
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
(import [random [shuffle]])
|
||||
(setv pips (.split "2 3 4 5 6 7 8 9 10 J Q K A"))
|
||||
(setv suits (.split "♥ ♦ ♣ ♠"))
|
||||
(setv cards_per_hand 5)
|
||||
|
||||
(defn make_deck [pips suits]
|
||||
(lfor
|
||||
x pips
|
||||
y suits
|
||||
(+ x y)))
|
||||
|
||||
(defn deal_hand [num_cards deck]
|
||||
(setv delt (cut deck None num_cards))
|
||||
(setv new_deck (lfor
|
||||
x deck
|
||||
:if (not (in x delt))
|
||||
x))
|
||||
[delt new_deck])
|
||||
|
||||
|
||||
(if (= __name__ "__main__")
|
||||
(do
|
||||
(setv deck (make_deck pips suits))
|
||||
(shuffle deck)
|
||||
(setv [first_hand deck] (deal_hand cards_per_hand deck))
|
||||
(setv [second_hand deck] (deal_hand cards_per_hand deck))
|
||||
(print "\nThe first hand delt was:" (.join " " (map str first_hand)))
|
||||
(print "\nThe second hand delt was:" (.join " " (map str second_hand)))
|
||||
(print "\nThe remaining cards in the deck are...\n" (.join " " (map str deck)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue