62 lines
1.2 KiB
Plaintext
62 lines
1.2 KiB
Plaintext
|
:: Hoon 101 - Week 6
|
||
|
:: ~bannum-magtus || s@p7.co.nz
|
||
|
::
|
||
|
:- %say
|
||
|
|= [[* eny=@uvJ *] [x=@ y=@ ~] ~]
|
||
|
:- %noun
|
||
|
?: (gth (mul x y) 52)
|
||
|
!!
|
||
|
=<
|
||
|
:: Im so sorry
|
||
|
(take-hands x y new-deck)
|
||
|
|%
|
||
|
++ take-hands
|
||
|
|= [x=@ y=@ d=(list tape)]
|
||
|
^- (list (list tape))
|
||
|
=/ hands=(list (list tape)) ~
|
||
|
|-
|
||
|
?: =(x 0)
|
||
|
hands
|
||
|
%= $
|
||
|
hands :-((scag y d) hands)
|
||
|
d (slag y d)
|
||
|
x (dec x)
|
||
|
==
|
||
|
++ suit-store
|
||
|
^- (list tape)
|
||
|
["H" "D" "C" "S" ~]
|
||
|
++ suit-donnees
|
||
|
^- (list tape)
|
||
|
["A" "2" "3" "4" "5" "6" "7" "8" "9" "10" "J" "Q" "K" ~]
|
||
|
++ new-deck
|
||
|
=/ nd=(list tape) ~
|
||
|
=/ s 0
|
||
|
|-
|
||
|
?: (gte s 4)
|
||
|
(shuffle-deck nd eny)
|
||
|
=/ v 0
|
||
|
|-
|
||
|
?. (lth v 13)
|
||
|
^$(s +(s))
|
||
|
%= $
|
||
|
v +(v)
|
||
|
nd :-((weld (snag v suit-donnees) (snag s suit-store)) nd)
|
||
|
==
|
||
|
++ shuffle-deck
|
||
|
|= [unshuffled=(list tape) entropy=@]
|
||
|
^- (list tape)
|
||
|
=| shuffled=(list tape)
|
||
|
=/ random ~(. og entropy)
|
||
|
=/ remaining (lent unshuffled)
|
||
|
|-
|
||
|
?: =(remaining 1)
|
||
|
:_ shuffled
|
||
|
(snag 0 unshuffled)
|
||
|
=^ index random (rads:random remaining)
|
||
|
%= $
|
||
|
shuffled (snag index unshuffled)^shuffled
|
||
|
remaining (dec remaining)
|
||
|
unshuffled (oust [index 1] unshuffled)
|
||
|
==
|
||
|
--
|