I found some interesting surprises in your solution. First, you can build
the shape of your array easily from the two lists.
$s
4
$c
13
$s,"0/c
4 13 2
$c,"0/s
13 4 2
Second, I liked how you use the shape of the deck to get your random cards.
This was an interesting extension of deal .
?~5 5
4 1 2 3 0
1 4 2 3 0
5 5 ?~ 5 5
1 3 0 2 4
3 0 1 4 2
?~5 5 5
1 4 2 0 3
4 3 0 2 1
4 1 2 0 3
However, in this example you have introduced a problem I didn't notice for
quite a while.
](i.15){"1 deckdwl
AKQJT98765432AK
ssssssssssssshh
]mixdwl (i.15){"1 deckdwl
867QKAA2K5JT394
ssssssshshsssss
If you have each row using an independent deal the cards don't stay
together. The two hearts are no longer the Ace and the King. In this case
you want only one deal.
mixdwl deckdwl
A797T8427K676QQTJ839Q4JAT228565Q4K368399K2J3AT455AKJ
dhshdccdsdhhcscdscdscsshdhhshdhsschhcccscddsddschhcd
In the example above there are two Jack of Spades. If you correct mix the
dole works much better than mine and your extension to allow a different
number of cards to more or fewer people is interesting.
5 doledwl2 deckdwl
A94Q72T5K83
ssshhhddccc
K83J6A94Q72
ssshhdddccc
Q72T5K83J6A
ssshhdddccs
J6A94Q72T5A
sshhhdddccs
T5K83J6A94A
sshhhddcccs
Here it would probably be better to deal fewer cards to each person. I
haven't figured out why all three cards filled in at the end are the Ace of
Spades rather than cycling throught the pack again.
In any case, I learned a lot and appreciate your more general approach.
Lindac
-----Original Message-----
From: David Ward Lambert [mailto:[email protected]]
Sent: Thursday, January 05, 2012 12:44 PM
To: Linda Alvord
Subject: jsoftware bridge deal challenge
NB. Our doles are similar
NB. The LA versions contain more 4s, 13s and 52s
NB. therefor the DWL versions are more general.
NB. doledwl is hard coded for 4 hands.
's c'=: ;:'shdc AKQJT98765432'
vdeckdwl=: [: |: [: ,/ ,"0~/
deckdwl=: s vdeckdwl c
mixdwl=: ({~ [: ?~ #)"1
doledwl=: [: |:"2 [: ({~ [: |: _4 [\ [: i. #) |:
NB. number_of_hands doledwl2 deck
NB. works for number of hands as a factor of the number of cards
doledwl2=: 4&$: :(4 : '([: |:"2 [: ({~ [: |: (-x) [\ [: i. #) |:)y')
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm