[Jprogramming] Challenge 3 - Dole a Mixed Pack
Linda Alvord
lindaalvord at verizon.net
Fri Dec 16 17:32:32 HKT 2011
Here's the next challenge. PLEASE DO NOT RESPOND UNTIL DECEMBER 23,2011 AT
12:00 AM EST. ALLOW THINKING TIME. THANKS.
The name has a small hint as it can be loosely translated as "Deal a
shuffled deck of cards".
Design 1 noun and 2 verbs called packla(your initials) , mixla(your
initials) and dolela(your initials. Use any nouns and verbs that you
require to make your final answers. Avoid @ .
First create a noun to form a traditional deck of cards. There are four
suits called spades, hearts, clubs and diamonds. Each suit has thirteen
cards ace, king, queen, jack, ten, nine, eight, seven, six, five, four,
three and two. When you are finished your 52 cards will look like:
packla=:
packla
AKQJT98765432AKQJT98765432AKQJT98765432AKQJT98765432
SSSSSSSSSSSSSHHHHHHHHHHHHHDDDDDDDDDDDDDCCCCCCCCCCCCC
Now define a monadic verb to shuffle the pack:
mixla=:
]52 mixla packla
T84T8AJK4739853T324K7J6556T64J7J6Q5AQ2KQ9283Q9KA972A
DHSCSHDDHSHDDHSHCSDSDSCSCSSDCHHCHDDCHCHSCDCDCSCDHCHS
]52 mixla packla
622A583897A652K79A5JK4763A7K4KTQQ58J4Q6T893J49J3Q2TT
SSCSCHDCSDHHDHSCDCSSDCHCHDSCSHSSDHDCHCDCSCSHDHDCHDHD
Repeat the use of mix twice to insure that a new shuffle has occurred. Now
shuffle the cards for game 1. Design a monadic verb dole to deal the
shuffled pack of cards.
]g1=:52 mixla packla
68898566QA6A724324J4TJQK59K5T329K7JA373T27QQ48TAJK95
HDCCHHDCCHSSDHHSCSSCSDDSCDHDDHDSCHCDCCDCSSHSDSHCHDHS
dolela=:
dolela g1
68Q72T5TK324J
HHCDCSCDCCSDH
85A24J937778K
DHHHSDDHHCSSD
8664JQK2J3QT9
CDSHSDHDCDHHH
96A34K59ATQA5
CCSSCSDSDCSCS
Note that this is the real deal! The first card goes in hand 1, the second
in hand 2 and so forth. Repeat for game 2.
]g2=:52 mixla packla
AT9JK2T457236QJ439QQK6839645T7JAAA6K8KQ487J72T835592
CCSDDHSCDDCHCDSHDDCSCSDCHDSCHCCHSDHHSSHDCHHSDDHSHSCS
dolela g2
AK563K9TA8825
CDDCDCHHSSCDH
T27Q9667AK7T5
CHDDDSDCDSHDS
9T2JQ84J6QJ89
SSCSCDSCHHHHC
J434Q35AK4732
DCHHSCCHHDSSS
Be sure you have a new deal.
4!:0 ;:'packla mixla dolela'
0 3 3
Have fun!
Linda
More information about the Programming
mailing list